ppt_v2.go 11 KB

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