ppt_v2.go 10 KB

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