ppt_v2.go 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. package models
  2. import (
  3. "eta_gn/eta_api/global"
  4. "eta_gn/eta_api/utils"
  5. "time"
  6. "github.com/rdlucklib/rdluck_tools/paging"
  7. )
  8. type PptV2 struct {
  9. PptId int `gorm:"column:ppt_id;primaryKey;autoIncrement:true" description:"ppt的Id"`
  10. TemplateType int `gorm:"column:template_type" description:"模版类型"`
  11. BackgroundImg string `gorm:"column:background_img" description:"背景图片"`
  12. Title string `gorm:"column:title" description:"标题"`
  13. ReportType string `gorm:"column:report_type" description:"报告类型"`
  14. PptDate string `gorm:"column:ppt_date" description:"选择日期"`
  15. Content string `gorm:"column:content" description:"ppt内容"`
  16. PptUrl string `gorm:"column:ppt_url" description:"ppt下载地址"`
  17. PptxUrl string `gorm:"column:pptx_url" description:"pptx下载地址"`
  18. CreateTime time.Time `gorm:"column:create_time" description:"创建时间"`
  19. ModifyTime time.Time `gorm:"column:modify_time" description:"修改时间"`
  20. AdminId int `gorm:"column:admin_id" description:"系统用户id"`
  21. AdminRealName string `gorm:"column:admin_real_name" description:"系统用户名称"`
  22. PptVersion int8 `gorm:"column:ppt_version" description:"是否ppt的旧版本;1:旧的,2:新的"`
  23. ReportId int `gorm:"column:report_id" description:"关联的报告ID"`
  24. ReportCode string `gorm:"column:report_code" description:"关联的报告code"`
  25. IsShare int8 `gorm:"column:is_share" description:"是否分享,0:不分享,1:分享"`
  26. PublishTime time.Time `gorm:"column:publish_time" description:"发布时间"`
  27. CoverContent string `gorm:"column:cover_content" description:"PPT内容-JSON"`
  28. PptPage int `gorm:"column:ppt_page" description:"PPT页数"`
  29. TitleSetting string `gorm:"column:title_setting" description:"PPT标题设置"`
  30. }
  31. type PptV2Item struct {
  32. PptId int `gorm:"column:ppt_id;primaryKey" description:"ppt的Id"`
  33. TemplateType int `gorm:"column:template_type" description:"模版类型"`
  34. BackgroundImg string `gorm:"column:background_img" description:"背景图片"`
  35. Title string `gorm:"column:title" description:"标题"`
  36. ReportType string `gorm:"column:report_type" description:"报告类型"`
  37. PptDate string `gorm:"column:ppt_date" description:"选择日期"`
  38. Content string `gorm:"column:content" description:"ppt内容"`
  39. PptUrl string `gorm:"column:ppt_url" description:"ppt下载地址"`
  40. PptxUrl string `gorm:"column:pptx_url" description:"pptx下载地址"`
  41. CreateTime time.Time `gorm:"column:create_time" description:"创建时间"`
  42. ModifyTime time.Time `gorm:"column:modify_time" description:"修改时间"`
  43. AdminId int `gorm:"column:admin_id" description:"系统用户id"`
  44. AdminRealName string `gorm:"column:admin_real_name" description:"系统用户名称"`
  45. PptVersion int8 `gorm:"column:ppt_version" description:"是否ppt的旧版本;1:旧的,2:新的"`
  46. IsAuth bool `gorm:"column:is_auth" description:"true:有操作权限,false:无操作权限"`
  47. ReportId int `gorm:"column:report_id" description:"报告ID"`
  48. ReportCode string `gorm:"column:report_code" description:"关联的报告code"`
  49. IsShare int8 `gorm:"column:is_share" description:"是否分享,0:不分享,1:分享"`
  50. PublishTime time.Time `gorm:"column:publish_time" description:"发布时间"`
  51. CoverContent string `gorm:"column:cover_content" description:"PPT内容-JSON"`
  52. PptPage int `gorm:"column:ppt_page" description:"PPT页数"`
  53. TitleSetting string `gorm:"column:title_setting" description:"PPT标题设置"`
  54. }
  55. func GetPptV2List(condition string, pars []interface{}, startSize, pageSize int) (items []*PptV2Item, err error) {
  56. sql := `SELECT * FROM ppt_v2 WHERE 1=1 `
  57. if condition != "" {
  58. sql += condition
  59. }
  60. sql += `ORDER BY modify_time DESC LIMIT ?,?`
  61. pars = append(pars, startSize)
  62. pars = append(pars, pageSize)
  63. err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
  64. return
  65. }
  66. func GetPptV2ByCondition(condition string, pars []interface{}) (items []*PptV2, err error) {
  67. sql := `SELECT * FROM ppt_v2 WHERE 1=1 `
  68. if condition != "" {
  69. sql += condition
  70. }
  71. sql += `ORDER BY modify_time DESC`
  72. err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
  73. return
  74. }
  75. func GetPptV2ListCount(condition string, pars []interface{}) (count int, err error) {
  76. sql := `SELECT COUNT(1) AS count FROM ppt_v2 WHERE 1=1 `
  77. if condition != "" {
  78. sql += condition
  79. }
  80. err = global.DmSQL["rddp"].Raw(sql, pars...).Scan(&count).Error
  81. return
  82. }
  83. type PptV2ListResp struct {
  84. List []*PptV2Item
  85. Paging *paging.PagingItem `description:"分页数据"`
  86. }
  87. func AddPptV2(item *PptV2) (lastId int64, err error) {
  88. err = global.DmSQL["rddp"].Create(item).Error
  89. lastId = int64(item.PptId)
  90. return
  91. }
  92. func DeletePptV2(pptId int) (err error) {
  93. sql := `DELETE FROM ppt_v2 WHERE ppt_id=? `
  94. err = global.DmSQL["rddp"].Exec(sql, pptId).Error
  95. return
  96. }
  97. type AddPptV2Req struct {
  98. PptId int64 `description:"ppt_id"`
  99. FirstPage struct {
  100. Title string `description:"标题"`
  101. ReportType string `description:"类型"`
  102. PptDate string `description:"日期"`
  103. ImgUrl string `description:"图片"`
  104. BackIndex int `description:"背景图片下标"`
  105. TemplateType int `description:"模版id"`
  106. } `description:"首页"`
  107. Content string `description:"ppt的json数据"`
  108. GroupId int64 `description:"目录id"`
  109. CoverContent string `description:"封面图内容-JSON数据"`
  110. TitleSetting string `description:"PPT标题设置"`
  111. }
  112. type AddPptResp struct {
  113. PptId int64 `description:"PptId"`
  114. }
  115. func (item *PptV2) Update(cols []string) (err error) {
  116. err = global.DmSQL["rddp"].Select(cols).Updates(item).Error
  117. return
  118. }
  119. type DeletePptV2Req struct {
  120. PptId int `description:"PptId" `
  121. }
  122. type SavePptV2PathReq struct {
  123. PptId int `description:"PptId" `
  124. PptxUrl string `description:"PptxUrl" `
  125. }
  126. func GetPptV2ById(pptId int) (item *PptV2, err error) {
  127. sql := `SELECT * FROM ppt_v2 WHERE 1=1 AND ppt_id=? `
  128. err = global.DmSQL["rddp"].Raw(sql, pptId).Find(&item).Error
  129. return
  130. }
  131. func GetPptV2ByIds(pptIds []int) (list []*PptV2, err error) {
  132. err = global.DmSQL["rddp"].Table("ppt_v2").Where("ppt_id IN ?", pptIds).Find(&list).Error
  133. return
  134. }
  135. func EditPptV2Path(pptId int, pptxPath string) (err error) {
  136. sql := `UPDATE ppt_v2 SET pptx_url=?,modify_time=NOW(),publish_time=NOW() WHERE ppt_id=? `
  137. err = global.DmSQL["rddp"].Exec(sql, pptxPath, pptId).Error
  138. return
  139. }
  140. type PptV2PublishRecord struct {
  141. Id int `gorm:"primaryKey" `
  142. PptId int
  143. PptUrl string
  144. CreateTime time.Time
  145. }
  146. func AddPptV2PublishRecord(item *PptV2PublishRecord) (lastId int64, err error) {
  147. err = global.DmSQL["rddp"].Create(item).Error
  148. lastId = int64(item.Id)
  149. return
  150. }
  151. type PptV2SaveLog struct {
  152. Id int `gorm:"column:id;primaryKey;autoIncrement" description:"自增Id"`
  153. PptId int `gorm:"column:ppt_id" description:"ppt的Id"`
  154. TemplateType int `gorm:"column:template_type" description:"模版类型"`
  155. BackgroundImg string `gorm:"column:background_img" description:"背景图片"`
  156. Title string `gorm:"column:title" description:"标题"`
  157. ReportType string `gorm:"column:report_type" description:"报告类型"`
  158. PptDate string `gorm:"column:ppt_date" description:"选择日期"`
  159. Content string `gorm:"column:content" description:"ppt内容"`
  160. AdminId int `gorm:"column:admin_id" description:"系统用户id"`
  161. AdminRealName string `gorm:"column:admin_real_name" description:"系统用户名称"`
  162. CreateTime time.Time `gorm:"column:create_time" description:"创建时间"`
  163. CoverContent string `gorm:"column:cover_content" description:"PPT内容-JSON"`
  164. TitleSetting string `gorm:"column:title_setting" description:"PPT标题设置"`
  165. }
  166. func AddPptV2SaveLog(item *PptV2SaveLog) (lastId int64, err error) {
  167. err = global.DmSQL["rddp"].Create(item).Error
  168. lastId = int64(item.Id)
  169. return
  170. }
  171. type PptV2ConfigResp struct {
  172. PptNum int `description:"ppt数量" json:"ppt_num"`
  173. ChartNum int `description:"图片数量" json:"chart_num"`
  174. }
  175. type PPT2ReportReq struct {
  176. PptId int `description:"PPT主键"`
  177. ClassifyId int `description:"报告二级分类ID"`
  178. Title string `description:"标题"`
  179. }
  180. func AddPptV2Multi(list []*PptV2) (err error) {
  181. err = global.DmSQL["rddp"].CreateInBatches(list, utils.MultiAddNum).Error
  182. return
  183. }
  184. func GetAllPptTitle() (names []string, err error) {
  185. sql := "select title from ppt_v2"
  186. err = global.DmSQL["rddp"].Raw(sql).Scan(&names).Error
  187. return
  188. }
  189. type PPT2ReportResp struct {
  190. ReportId int `description:"关联的报告ID" json:"report_id"`
  191. ReportCode string `description:"关联的报告编码" json:"report_code"`
  192. }
  193. func GetPptV2ByReportId(reportId int) (item *PptV2, err error) {
  194. sql := `SELECT * FROM ppt_v2 WHERE 1=1 AND report_id=? LIMIT 1`
  195. err = global.DmSQL["rddp"].Raw(sql, reportId).First(&item).Error
  196. return
  197. }
  198. func GetSharePptV2(IsNewPpt int) (items []*PptV2, err error) {
  199. sql := `SELECT * FROM ppt_v2 WHERE 1=1 AND is_share = 1 `
  200. if IsNewPpt > 0 {
  201. sql += ` AND ppt_version = 2 `
  202. }
  203. sql += `ORDER BY create_time DESC`
  204. err = global.DmSQL["rddp"].Raw(sql).Find(&items).Error
  205. return
  206. }
  207. func GetAllPptV2List(condition string, pars []interface{}) (items []*PptV2Item, err error) {
  208. sql := `SELECT * FROM ppt_v2 WHERE 1=1 `
  209. if condition != "" {
  210. sql += condition
  211. }
  212. sql += `ORDER BY modify_time DESC `
  213. err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
  214. return
  215. }
  216. type EnPPT2CnReq struct {
  217. PptId int `description:"英文PPT主键"`
  218. GroupId int `description:"目录ID"`
  219. }
  220. type BatchEnPPT2CnReq struct {
  221. PptIds string `description:"英文PPT主键s"`
  222. GroupId int `description:"目录ID"`
  223. }
  224. func GetPptV2ByTitleAndId(title string, adminId int) (item *PptV2, err error) {
  225. sql := `SELECT * FROM ppt_v2 WHERE 1=1 AND title=? AND admin_id=? `
  226. err = global.DmSQL["rddp"].Raw(sql, title, adminId).First(&item).Error
  227. return
  228. }
  229. type PPTEditingReq struct {
  230. PptId int `description:"PPT主键ID"`
  231. Status int `description:"标记状态: 1-编辑中; 2-编辑完成"`
  232. }
  233. type PPTDetailResp struct {
  234. *PptV2
  235. Editor PPTEditingCache `description:"编辑人信息"`
  236. }
  237. type PPTEditingCache struct {
  238. IsEditing bool `description:"是否有人编辑"`
  239. AdminId int `description:"编辑者ID"`
  240. Editor string `description:"编辑者姓名"`
  241. Tips string `description:"提示信息"`
  242. }