123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- package models
- import (
- "rdluck_tools/orm"
- "time"
- )
- type Ppt struct {
- PptId int `orm:"column(id)" description:"报告Id"`
- Title string `description:"标题"`
- TemplateType string `description:"模版类型"`
- PptDate string `description:"选择日期"`
- PptUrl string `description:"ppt地址"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"修改时间"`
- ReportType string `description:"报告类型"`
- }
- type PptImages struct {
- PptImagesId int `description:"Id"`
- ImageUrl string `description:"图片地址"`
- ImageType int `description:"图片类型,0:首页背景模板"`
- }
- type PptPages struct {
- PptPagesId int `orm:"column(ppt_pages_id)" description:"报告章节Id"`
- PptId int64 `description:"ppt_id"`
- Title string `description:"标题"`
- ImgUrl string `description:"图片路径"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"修改时间"`
- PageCode string `description:"编码"`
- Width int `description:"宽度"`
- Height int `description:"高端"`
- ResourceId int `description:"来源id,来自上海策略组提供的图表id"`
- }
- func GetPptList(condition string, pars []interface{}, startSize, pageSize int) (items []*Ppt, err error) {
- o := orm.NewOrm()
- o.Using("rddp")
- sql := `SELECT * FROM ppt WHERE 1=1 `
- if condition != "" {
- sql += condition
- }
- sql += `ORDER BY create_time DESC LIMIT ?,?`
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
- return
- }
- func GetPptListCount(condition string, pars []interface{}) (count int, err error) {
- o := orm.NewOrm()
- o.Using("rddp")
- sql := `SELECT COUNT(1) AS count FROM ppt WHERE 1=1 `
- if condition != "" {
- sql += condition
- }
- sql += `ORDER BY create_time DESC LIMIT ?,?`
- err = o.Raw(sql, pars).QueryRow(&count)
- return
- }
- type PptListResp struct {
- List []*Ppt
- Paging *PagingItem `description:"分页数据"`
- }
- //新增PPT
- func AddPpt(item *Ppt) (lastId int64, err error) {
- o := orm.NewOrm()
- o.Using("rddp")
- lastId, err = o.Insert(item)
- return
- }
- //删除ppt
- func DeletePpt(pptId int) (err error) {
- o := orm.NewOrm()
- o.Using("rddp")
- sql := `DELETE FROM ppt WHERE ppt_id=? `
- _, err = o.Raw(sql, pptId).Exec()
- return
- }
- type AddPptReq struct {
- FirstPage struct {
- Title string `json:"title"`
- ReportType string `json:"report_type"`
- PptDate string `json:"ppt_date"`
- ImgUrl string `json:"img_url"`
- } `json:"first_page"`
- ContentPage []ContentPageItems `json:"content_page"`
- }
- type ContentPageItems struct {
- PptId int64 `json:"ppt_id" description:"ppt_id" `
- PptPagesId int `json:"ppt_pages_id" description:"章节id,新增时传0"`
- Title string `json:"title" description:"标题"`
- ResourceId int `json:"resource_id" description:"来源id,来自上海策略组提供的图表id"`
- }
- func AddPptPages(item *PptPages) (lastId int64, err error) {
- o := orm.NewOrm()
- o.Using("rddp")
- lastId, err = o.Insert(item)
- return
- }
- type EditPptReq struct {
- PptId int64 `json:"ppt_id"`
- FirstPage struct {
- PptPagesId int `json:"ppt_pages_id" description:"ppt_page_id"`
- Title string `json:"title" description:"标题"`
- ReportType string `json:"report_type" description:"类型"`
- PptDate string `json:"ppt_date" description:"日期"`
- ImgUrl string `json:"img_url" description:"图片路径"`
- } `json:"first_page"`
- ContentPage []ContentPageItems `json:"content_page"`
- }
- func EditPpt(item *Ppt) (err error) {
- o := orm.NewOrm()
- o.Using("rddp")
- sql := `UPDATE ppt SET title = ?, ppt_date= ?, modify_time=NOW(), report_type=? WHERE ppt_id = ? `
- _, err = o.Raw(sql, item.Title, item.PptDate, item.ReportType, item.PptId).Exec()
- return
- }
- func EditPptPages(item *PptPages) (err error) {
- o := orm.NewOrm()
- o.Using("rddp")
- sql := `UPDATE ppt_pages SET title= ?, img_url= ?, modify_time = now(), resource_id = ? WHERE ppt_pages_id= ? `
- _, err = o.Raw(sql, item.Title, item.ImgUrl, item.ResourceId, item.PptPagesId).Exec()
- return
- }
- type DeletePptReq struct {
- PptId int `json:"ppt_id" description:"ppt_id" `
- }
- func GetPptById(pptId int) (item *Ppt, err error) {
- o := orm.NewOrm()
- o.Using("rddp")
- sql := `SELECT * FROM ppt WHERE 1=1 AND id=? `
- err = o.Raw(sql, pptId).QueryRow(&item)
- return
- }
- func GetPptPagesById(pptId int) (items []*PptPages, err error) {
- o := orm.NewOrm()
- o.Using("rddp")
- sql := `SELECT * FROM ppt_pages WHERE ppt_id=? `
- _, err = o.Raw(sql, pptId).QueryRows(&items)
- return
- }
- type PptDetailResp struct {
- PptPages []*PptPages `description:"ppt详情数据"`
- Ppt *Ppt `description:"ppt数据"`
- }
- type Base64UploadReq struct {
- Img string `json:"img" description:"图片img base64" `
- PptId string `json:"title" description:"ppt_id"`
- ResourceId int `json:"resource_id" description:"来源id,来自上海策略组提供的图表id"`
- }
- //编辑ppt章节图片
- func ModifyPptPages(imgUrl string, resourceId, pptId, pptPagesId, width, height int) (err error) {
- sql := "UPDATE ppt_pages SET img_url=?,width=?,height=? WHERE ppt_pages_id=? AND ppt_id=? AND resource_id=? "
- o := orm.NewOrm()
- o.Using("rddp")
- _, err = o.Raw(sql, imgUrl, width, height, pptPagesId, pptId, resourceId).Exec()
- return
- }
- func GetImages(imageType int) (items []*PptImages, err error) {
- sql := `SELECT * FROM ppt_images WHERE image_type=? `
- o := orm.NewOrm()
- o.Using("rddp")
- _, err = o.Raw(sql, imageType).QueryRows(&items)
- return
- }
- type PptImagesResp struct {
- List []*PptImages `description:"ppt背景图片"`
- }
- type PptPublishReq struct {
- PptId int `json:"ppt_id"`
- ScreenHeight int `description:"屏幕宽高"`
- }
- func GetPptFirstPage(pptId int) (item *PptPages, err error) {
- sql := `SELECT * FROM ppt_pages WHERE ppt_id=? ORDER BY ppt_pages_id ASC LIMIT 1 `
- o := orm.NewOrm()
- o.Using("rddp")
- err = o.Raw(sql, pptId).QueryRow(&item)
- return
- }
- func GetPptContentPages(pptId, pptPageId int) (item []*PptPages, err error) {
- sql := `SELECT * FROM ppt_pages WHERE ppt_id=? AND ppt_pages_id<>? ORDER BY ppt_pages_id ASC `
- o := orm.NewOrm()
- o.Using("rddp")
- _, err = o.Raw(sql, pptId, pptPageId).QueryRows(&item)
- return
- }
- func EditPptPath(pptId int, pptPath string) (err error) {
- sql := `UPDATE ppt SET ppt_url=? WHERE ppt_id=? `
- o := orm.NewOrm()
- o.Using("rddp")
- _, err = o.Raw(sql, pptPath, pptId).Exec()
- return
- }
|