ppt_v2.go 9.5 KB

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