ppt_v2.go 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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. }
  123. type AddPptResp struct {
  124. PptId int64 `description:"PptId"`
  125. }
  126. // Update 更新ppt基础信息
  127. func (item *PptV2) Update(cols []string) (err error) {
  128. o := orm.NewOrmUsingDB("rddp")
  129. _, err = o.Update(item, cols...)
  130. return
  131. }
  132. type DeletePptV2Req struct {
  133. PptId int `description:"PptId" `
  134. }
  135. // SavePptV2PathReq 保存ppt的下载地址请求
  136. type SavePptV2PathReq struct {
  137. PptId int `description:"PptId" `
  138. PptxUrl string `description:"PptxUrl" `
  139. }
  140. func GetPptV2ById(pptId int) (item *PptV2, err error) {
  141. o := orm.NewOrmUsingDB("rddp")
  142. sql := `SELECT * FROM ppt_v2 WHERE 1=1 AND ppt_id=? `
  143. err = o.Raw(sql, pptId).QueryRow(&item)
  144. return
  145. }
  146. func GetPptV2ByIds(pptIds []int) (list []*PptV2, err error) {
  147. _, err = orm.NewOrmUsingDB("rddp").
  148. QueryTable("ppt_v2").
  149. Filter("ppt_id__in", pptIds).
  150. All(&list)
  151. return
  152. }
  153. func GetPptV2ByTitle(title string) (item *PptV2, err error) {
  154. o := orm.NewOrmUsingDB("rddp")
  155. sql := `SELECT * FROM ppt_v2 WHERE 1=1 AND title=? `
  156. err = o.Raw(sql, title).QueryRow(&item)
  157. return
  158. }
  159. // EditPptV2Path 编辑Ppt的下载地址
  160. func EditPptV2Path(pptId int, pptxPath string) (err error) {
  161. sql := `UPDATE ppt_v2 SET pptx_url=?,modify_time=NOW(),publish_time=NOW() WHERE ppt_id=? `
  162. o := orm.NewOrmUsingDB("rddp")
  163. _, err = o.Raw(sql, pptxPath, pptId).Exec()
  164. return
  165. }
  166. // PptV2PublishRecord 发布记录表
  167. type PptV2PublishRecord struct {
  168. Id int `orm:"column(id);pk"`
  169. PptId int
  170. PptUrl string
  171. CreateTime time.Time
  172. }
  173. // AddPptV2PublishRecord 添加发布记录,主要是记录每次发布的时候,当前的ppt
  174. func AddPptV2PublishRecord(item *PptV2PublishRecord) (lastId int64, err error) {
  175. o := orm.NewOrmUsingDB("rddp")
  176. lastId, err = o.Insert(item)
  177. return
  178. }
  179. // PptV2SaveLog ppt记录表
  180. type PptV2SaveLog struct {
  181. Id int `orm:"column(id);pk" description:"自增Id"`
  182. PptId int `orm:"column(ppt_id)" description:"ppt的Id"`
  183. TemplateType int `description:"模版类型"`
  184. BackgroundImg string `description:"背景图片"`
  185. Title string `description:"标题"`
  186. ReportType string `description:"报告类型"`
  187. PptDate string `description:"选择日期"`
  188. Content string `description:"ppt内容"`
  189. AdminId int `description:"系统用户id"`
  190. AdminRealName string `description:"系统用户名称"`
  191. CreateTime time.Time `description:"创建时间"`
  192. CoverContent string `description:"PPT内容-JSON"`
  193. TitleSetting string `description:"PPT标题设置"`
  194. }
  195. // AddPptV2SaveLog 新增PPT日志
  196. func AddPptV2SaveLog(item *PptV2SaveLog) (lastId int64, err error) {
  197. o := orm.NewOrmUsingDB("rddp")
  198. lastId, err = o.Insert(item)
  199. return
  200. }
  201. type PptV2ConfigResp struct {
  202. PptNum int `description:"ppt数量" json:"ppt_num"`
  203. ChartNum int `description:"图片数量" json:"chart_num"`
  204. }
  205. type PPT2ReportReq struct {
  206. PptId int `description:"PPT主键"`
  207. ClassifyId int `description:"报告二级分类ID"`
  208. Title string `description:"标题"`
  209. }
  210. // AddPptV2Multi 批量新增ppt
  211. func AddPptV2Multi(list []*PptV2) (err error) {
  212. o := orm.NewOrmUsingDB("rddp")
  213. _, err = o.InsertMulti(1, list)
  214. return
  215. }
  216. // GetAllPptTitle 获取当前目录的所有名称
  217. func GetAllPptTitle() (names []string, err error) {
  218. o := orm.NewOrmUsingDB("rddp")
  219. sql := "select title from ppt_v2"
  220. _, err = o.Raw(sql).QueryRows(&names)
  221. return
  222. }
  223. // PPT2ReportResp PPT转报告响应体
  224. type PPT2ReportResp struct {
  225. ReportId int `description:"关联的报告ID" json:"report_id"`
  226. ReportCode string `description:"关联的报告编码" json:"report_code"`
  227. }
  228. // GetPptV2ByReportId 通过关联的报告ID获取PPT
  229. func GetPptV2ByReportId(reportId int) (item *PptV2, err error) {
  230. o := orm.NewOrmUsingDB("rddp")
  231. sql := `SELECT * FROM ppt_v2 WHERE 1=1 AND report_id=? LIMIT 1`
  232. err = o.Raw(sql, reportId).QueryRow(&item)
  233. return
  234. }
  235. // GetSharePptV2 获取公开分享的ppt
  236. func GetSharePptV2(IsNewPpt int) (items []*PptV2, err error) {
  237. o := orm.NewOrmUsingDB("rddp")
  238. sql := `SELECT * FROM ppt_v2 WHERE 1=1 AND is_share = 1 `
  239. if IsNewPpt > 0 {
  240. sql += ` AND ppt_version = 2 `
  241. }
  242. sql += `ORDER BY create_time DESC`
  243. //sql += `ORDER BY create_time DESC LIMIT ?,?`
  244. _, err = o.Raw(sql).QueryRows(&items)
  245. return
  246. }
  247. // GetAllPptV2List 根据条件获取所有的Ppt
  248. func GetAllPptV2List(condition string, pars []interface{}) (items []*PptV2Item, err error) {
  249. o := orm.NewOrmUsingDB("rddp")
  250. sql := `SELECT * FROM ppt_v2 WHERE 1=1 `
  251. if condition != "" {
  252. sql += condition
  253. }
  254. //
  255. sql += `ORDER BY modify_time DESC `
  256. _, err = o.Raw(sql, pars).QueryRows(&items)
  257. return
  258. }
  259. type EnPPT2CnReq struct {
  260. PptId int `description:"英文PPT主键"`
  261. GroupId int `description:"目录ID"`
  262. }
  263. type BatchEnPPT2CnReq struct {
  264. PptIds string `description:"英文PPT主键s"`
  265. GroupId int `description:"目录ID"`
  266. }
  267. func GetPptV2ByTitleAndId(title string, adminId int) (item *PptV2, err error) {
  268. o := orm.NewOrmUsingDB("rddp")
  269. sql := `SELECT * FROM ppt_v2 WHERE 1=1 AND title=? AND admin_id=? `
  270. err = o.Raw(sql, title, adminId).QueryRow(&item)
  271. return
  272. }
  273. // PPTEditingReq 标记编辑中请求体
  274. type PPTEditingReq struct {
  275. PptId int `description:"PPT主键ID"`
  276. Status int `description:"标记状态: 1-编辑中; 2-编辑完成"`
  277. }
  278. // PPTDetailResp PPT详情响应体
  279. type PPTDetailResp struct {
  280. *PptV2
  281. Editor ppt_english.PPTEditingCache `description:"编辑人信息"`
  282. }