ppt.go 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "time"
  6. )
  7. type Ppt struct {
  8. PptId int `orm:"column(ppt_id);pk" description:"报告Id"`
  9. Title string `description:"标题"`
  10. TemplateType string `description:"模版类型"`
  11. PptDate string `description:"选择日期"`
  12. PptUrl string `description:"ppt地址"`
  13. CreateTime time.Time `description:"创建时间"`
  14. ModifyTime time.Time `description:"修改时间"`
  15. ReportType string `description:"报告类型"`
  16. AdminId int `description:"系统用户id"`
  17. AdminRealName string `description:"系统用户名称"`
  18. Version int `description:"1:第一版,2:第二版"`
  19. }
  20. type PptItem struct {
  21. PptId int `orm:"column(ppt_id);pk" description:"报告Id"`
  22. Title string `description:"标题"`
  23. TemplateType string `description:"模版类型"`
  24. PptDate string `description:"选择日期"`
  25. PptUrl string `description:"ppt地址"`
  26. PptxUrl string `description:"ppt地址"`
  27. CreateTime time.Time `description:"创建时间"`
  28. ModifyTime time.Time `description:"修改时间"`
  29. ReportType string `description:"报告类型"`
  30. AdminId int `description:"系统用户id"`
  31. AdminRealName string `description:"系统用户名称"`
  32. IsAuth bool `description:"true:有操作权限,false:无操作权限"`
  33. Version int `description:"1:第一版,2:第二版"`
  34. }
  35. type PptImages struct {
  36. PptImagesId int `description:"Id"`
  37. ImageUrl string `description:"图片地址"`
  38. ImageType int `description:"图片类型,0:首页背景模板"`
  39. }
  40. type PptPages struct {
  41. PptPagesId int `orm:"column(ppt_pages_id);pk" description:"报告章节Id"`
  42. PptId int64 `description:"ppt_id"`
  43. Title string `description:"标题"`
  44. ImgUrl string `description:"图片路径"`
  45. CreateTime time.Time `description:"创建时间"`
  46. ModifyTime time.Time `description:"修改时间"`
  47. PageCode string `description:"编码"`
  48. Width int `description:"宽度"`
  49. Height int `description:"高端"`
  50. ResourceId string `description:"来源id,来自上海策略组提供的图表id"`
  51. Timestamp int `description:"时间戳"`
  52. BackIndex int `description:"背景图片下标"`
  53. }
  54. func GetPptList(condition string, pars []interface{}, startSize, pageSize int) (items []*PptItem, err error) {
  55. o := orm.NewOrmUsingDB("rddp")
  56. sql := `SELECT * FROM ppt WHERE 1=1 `
  57. if condition != "" {
  58. sql += condition
  59. }
  60. //
  61. sql += `ORDER BY modify_time DESC LIMIT ?,?`
  62. //sql += `ORDER BY create_time DESC LIMIT ?,?`
  63. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  64. return
  65. }
  66. func GetPptListCount(condition string, pars []interface{}) (count int, err error) {
  67. o := orm.NewOrmUsingDB("rddp")
  68. sql := `SELECT COUNT(1) AS count FROM ppt WHERE 1=1 `
  69. if condition != "" {
  70. sql += condition
  71. }
  72. err = o.Raw(sql, pars).QueryRow(&count)
  73. return
  74. }
  75. type PptListResp struct {
  76. List []*PptItem
  77. Paging *paging.PagingItem `description:"分页数据"`
  78. }
  79. //新增PPT
  80. func AddPpt(item *Ppt) (lastId int64, err error) {
  81. o := orm.NewOrmUsingDB("rddp")
  82. lastId, err = o.Insert(item)
  83. return
  84. }
  85. //删除ppt
  86. func DeletePpt(pptId int) (err error) {
  87. o := orm.NewOrmUsingDB("rddp")
  88. sql := `DELETE FROM ppt WHERE ppt_id=? `
  89. _, err = o.Raw(sql, pptId).Exec()
  90. return
  91. }
  92. //删除ppt_pages
  93. func DeletePptPages(pptId int64) (err error) {
  94. o := orm.NewOrmUsingDB("rddp")
  95. sql := `DELETE FROM ppt_pages WHERE ppt_id =? `
  96. _, err = o.Raw(sql, pptId).Exec()
  97. return
  98. }
  99. type AddPptReq struct {
  100. PptId int64 `description:"ppt_id"`
  101. FirstPage struct {
  102. Title string `description:"标题"`
  103. ReportType string `description:"类型"`
  104. PptDate string `description:"日期"`
  105. ImgUrl string `description:"图片"`
  106. BackIndex int `description:"背景图片下标"`
  107. } `description:"首页"`
  108. ContentPage []ContentPageItems `description:"内容页"`
  109. }
  110. type AddPptResp struct {
  111. PptId int64 `description:"PptId"`
  112. }
  113. type ContentPageItems struct {
  114. PptId int64 `json:"PptId" description:"ppt_id" `
  115. PptPagesId int `json:"PptPagesId" description:"章节id,新增时传0"`
  116. Title string `json:"Title" description:"标题"`
  117. ResourceId string `json:"ResourceId" description:"来源id,来自上海策略组提供的图表id"`
  118. Timestamp int `description:"时间戳"`
  119. }
  120. func AddPptPages(item *PptPages) (lastId int64, err error) {
  121. o := orm.NewOrmUsingDB("rddp")
  122. lastId, err = o.Insert(item)
  123. return
  124. }
  125. type EditPptReq struct {
  126. PptId int64 `description:"pptId"`
  127. FirstPage struct {
  128. PptPagesId int `description:"ppt_page_id"`
  129. Title string `description:"标题"`
  130. ReportType string `description:"类型"`
  131. PptDate string `description:"日期"`
  132. ImgUrl string `description:"图片路径"`
  133. BackIndex int `description:"背景图片下标"`
  134. }
  135. ContentPage []ContentPageItems
  136. }
  137. func EditPpt(item *Ppt) (err error) {
  138. o := orm.NewOrmUsingDB("rddp")
  139. sql := `UPDATE ppt SET title = ?, ppt_date= ?, modify_time=NOW(), report_type=? WHERE ppt_id = ? `
  140. _, err = o.Raw(sql, item.Title, item.PptDate, item.ReportType, item.PptId).Exec()
  141. return
  142. }
  143. func EditPptPages(item *PptPages) (err error) {
  144. o := orm.NewOrmUsingDB("rddp")
  145. sql := `UPDATE ppt_pages SET title= ?, img_url= ?, modify_time = now(), resource_id = ? WHERE ppt_pages_id= ? `
  146. _, err = o.Raw(sql, item.Title, item.ImgUrl, item.ResourceId, item.PptPagesId).Exec()
  147. return
  148. }
  149. type DeletePptReq struct {
  150. PptId int `description:"PptId" `
  151. }
  152. func GetPptById(pptId int) (item *Ppt, err error) {
  153. o := orm.NewOrmUsingDB("rddp")
  154. sql := `SELECT * FROM ppt WHERE 1=1 AND ppt_id=? `
  155. err = o.Raw(sql, pptId).QueryRow(&item)
  156. return
  157. }
  158. func GetPptByTitle(title string) (item *Ppt, err error) {
  159. o := orm.NewOrmUsingDB("rddp")
  160. sql := `SELECT * FROM ppt WHERE 1=1 AND title=? `
  161. err = o.Raw(sql, title).QueryRow(&item)
  162. return
  163. }
  164. func GetPptPagesById(pptId int) (items []*PptPages, err error) {
  165. o := orm.NewOrmUsingDB("rddp")
  166. sql := `SELECT * FROM ppt_pages WHERE ppt_id=? `
  167. _, err = o.Raw(sql, pptId).QueryRows(&items)
  168. return
  169. }
  170. type PptDetailResp struct {
  171. PptPages []*PptPages `description:"ppt详情数据"`
  172. Ppt *Ppt `description:"ppt数据"`
  173. }
  174. type Base64UploadReq struct {
  175. Img string `json:"img" description:"图片img base64" `
  176. PptId string `json:"title" description:"ppt_id"`
  177. ResourceId int `json:"resource_id" description:"来源id,来自上海策略组提供的图表id"`
  178. }
  179. //编辑ppt章节图片
  180. func ModifyPptPages(imgUrl string, pptId, pptPagesId, width, height int) (err error) {
  181. sql := "UPDATE ppt_pages SET img_url=?,width=?,height=?,modify_time=NOW() WHERE ppt_pages_id=? AND ppt_id=? "
  182. o := orm.NewOrmUsingDB("rddp")
  183. _, err = o.Raw(sql, imgUrl, width, height, pptPagesId, pptId).Exec()
  184. return
  185. }
  186. func GetImages(imageType int) (items []*PptImages, err error) {
  187. sql := `SELECT * FROM ppt_images WHERE image_type=? `
  188. o := orm.NewOrmUsingDB("rddp")
  189. _, err = o.Raw(sql, imageType).QueryRows(&items)
  190. return
  191. }
  192. type PptImagesResp struct {
  193. List []*PptImages `description:"ppt背景图片"`
  194. }
  195. type PptPublishReq struct {
  196. PptId int `description:"PptId"`
  197. ScreenHeight int `description:"屏幕宽高"`
  198. }
  199. func GetPptFirstPage(pptId int) (item *PptPages, err error) {
  200. sql := `SELECT * FROM ppt_pages WHERE ppt_id=? ORDER BY ppt_pages_id ASC LIMIT 1 `
  201. o := orm.NewOrmUsingDB("rddp")
  202. err = o.Raw(sql, pptId).QueryRow(&item)
  203. return
  204. }
  205. func GetPptContentPages(pptId, pptPageId int) (item []*PptPages, err error) {
  206. sql := `SELECT * FROM ppt_pages WHERE ppt_id=? AND ppt_pages_id<>? ORDER BY ppt_pages_id ASC `
  207. o := orm.NewOrmUsingDB("rddp")
  208. _, err = o.Raw(sql, pptId, pptPageId).QueryRows(&item)
  209. return
  210. }
  211. func EditPptPath(pptId int, pptxPath, pptPath string) (err error) {
  212. sql := `UPDATE ppt SET pptx_url=?,ppt_url=?,modify_time=NOW() WHERE ppt_id=? `
  213. o := orm.NewOrmUsingDB("rddp")
  214. _, err = o.Raw(sql, pptxPath, pptPath, pptId).Exec()
  215. return
  216. }
  217. type PptPublishRecord struct {
  218. Id int `orm:"column(id);pk"`
  219. PptId int
  220. PptUrl string
  221. CreateTime time.Time
  222. }
  223. func AddPptPublishRecord(item *PptPublishRecord) (lastId int64, err error) {
  224. o := orm.NewOrmUsingDB("rddp")
  225. lastId, err = o.Insert(item)
  226. return
  227. }
  228. func GetPptPagesContent(pptId int, resourceId string) (count int, err error) {
  229. sql := `SELECT COUNT(1) AS count FROM ppt_pages WHERE ppt_id=? AND resource_id=? `
  230. o := orm.NewOrmUsingDB("rddp")
  231. err = o.Raw(sql, pptId, resourceId).QueryRow(&count)
  232. return
  233. }
  234. type Base64UploadBatchReq struct {
  235. Img string
  236. ResourceId string
  237. PptId int
  238. PptPagesId int
  239. }