ppt_v2.go 9.8 KB

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