ppt_v2.go 9.0 KB

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