ppt_v2.go 10 KB

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