ppt_v2.go 9.9 KB

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