ppt_v2.go 10 KB

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