ppt_v2.go 11 KB

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