ppt_english.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. package ppt_english
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "time"
  6. )
  7. // PptEnglish 表
  8. type PptEnglish 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. PptxUrl string `description:"pptx下载地址"`
  17. CreateTime time.Time `description:"创建时间"`
  18. ModifyTime time.Time `description:"修改时间"`
  19. AdminId int `description:"系统用户id"`
  20. AdminRealName string `description:"系统用户名称"`
  21. ReportId int `description:"关联的报告ID"`
  22. ReportCode string `description:"关联的报告code"`
  23. IsShare int8 `description:"是否分享,0:不分享,1:分享"`
  24. PublishTime time.Time `description:"发布时间"`
  25. CoverContent string `description:"PPT内容-JSON"`
  26. }
  27. type PptEnglishItem struct {
  28. PptId int `orm:"column(ppt_id);pk" description:"ppt的Id"`
  29. TemplateType int `description:"模版类型"`
  30. BackgroundImg string `description:"背景图片"`
  31. Title string `description:"标题"`
  32. ReportType string `description:"报告类型"`
  33. PptDate string `description:"选择日期"`
  34. Content string `description:"ppt内容"`
  35. PptxUrl string `description:"pptx下载地址"`
  36. CreateTime time.Time `description:"创建时间"`
  37. ModifyTime time.Time `description:"修改时间"`
  38. AdminId int `description:"系统用户id"`
  39. AdminRealName string `description:"系统用户名称"`
  40. IsAuth bool `description:"true:有操作权限,false:无操作权限"`
  41. ReportId int `description:"报告ID"`
  42. ReportCode string `description:"关联的报告code"`
  43. IsShare int8 `description:"是否分享,0:不分享,1:分享"`
  44. PublishTime time.Time `description:"发布时间"`
  45. CoverContent string `description:"PPT内容-JSON"`
  46. }
  47. func GetPptEnglishList(condition string, pars []interface{}, startSize, pageSize int) (items []*PptEnglishItem, err error) {
  48. o := orm.NewOrmUsingDB("rddp")
  49. sql := `SELECT * FROM ppt_english WHERE 1=1 `
  50. if condition != "" {
  51. sql += condition
  52. }
  53. //
  54. sql += `ORDER BY modify_time DESC LIMIT ?,?`
  55. //sql += `ORDER BY create_time DESC LIMIT ?,?`
  56. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  57. return
  58. }
  59. func GetPptEnglishByCondition(condition string, pars []interface{}) (items []*PptEnglish, err error) {
  60. o := orm.NewOrmUsingDB("rddp")
  61. sql := `SELECT * FROM ppt_english WHERE 1=1 `
  62. if condition != "" {
  63. sql += condition
  64. }
  65. //
  66. sql += `ORDER BY modify_time DESC`
  67. //sql += `ORDER BY create_time DESC LIMIT ?,?`
  68. _, err = o.Raw(sql, pars).QueryRows(&items)
  69. return
  70. }
  71. func GetPptEnglishListCount(condition string, pars []interface{}) (count int, err error) {
  72. o := orm.NewOrmUsingDB("rddp")
  73. sql := `SELECT COUNT(1) AS count FROM ppt_english WHERE 1=1 `
  74. if condition != "" {
  75. sql += condition
  76. }
  77. err = o.Raw(sql, pars).QueryRow(&count)
  78. return
  79. }
  80. type PptEnglishListResp struct {
  81. List []*PptEnglishItem
  82. Paging *paging.PagingItem `description:"分页数据"`
  83. }
  84. // AddPptEnglish 新增PPT
  85. func AddPptEnglish(item *PptEnglish) (lastId int64, err error) {
  86. o := orm.NewOrmUsingDB("rddp")
  87. lastId, err = o.Insert(item)
  88. return
  89. }
  90. // DeletePptEnglish 删除ppt
  91. func DeletePptEnglish(pptId int) (err error) {
  92. o := orm.NewOrmUsingDB("rddp")
  93. sql := `DELETE FROM ppt_english WHERE ppt_id=? `
  94. _, err = o.Raw(sql, pptId).Exec()
  95. return
  96. }
  97. type AddPptEnglishReq struct {
  98. PptId int64 `description:"ppt_id"`
  99. FirstPage struct {
  100. Title string `description:"标题"`
  101. ReportType string `description:"类型"`
  102. PptDate string `description:"日期"`
  103. ImgUrl string `description:"图片"`
  104. BackIndex int `description:"背景图片下标"`
  105. TemplateType int `description:"模版id"`
  106. } `description:"首页"`
  107. Content string `description:"ppt的json数据"`
  108. GroupId int64 `description:"目录id"`
  109. CoverContent string `description:"PPT内容-JSON"`
  110. }
  111. type AddPptEnglishResp struct {
  112. PptId int64 `description:"PptId"`
  113. }
  114. type ContentPageItems struct {
  115. PptId int64 `json:"PptId" description:"ppt_id" `
  116. PptPagesId int `json:"PptPagesId" description:"章节id,新增时传0"`
  117. Title string `json:"Title" description:"标题"`
  118. ResourceId string `json:"ResourceId" description:"来源id,来自上海策略组提供的图表id"`
  119. Timestamp int `description:"时间戳"`
  120. }
  121. type EditPptEnglishReq struct {
  122. PptId int64 `description:"pptId"`
  123. FirstPage struct {
  124. PptPagesId int `description:"ppt_page_id"`
  125. Title string `description:"标题"`
  126. ReportType string `description:"类型"`
  127. PptDate string `description:"日期"`
  128. ImgUrl string `description:"图片路径"`
  129. BackIndex int `description:"背景图片下标"`
  130. }
  131. ContentPage []ContentPageItems
  132. }
  133. // Update 更新ppt基础信息
  134. func (item *PptEnglish) Update(cols []string) (err error) {
  135. o := orm.NewOrmUsingDB("rddp")
  136. _, err = o.Update(item, cols...)
  137. return
  138. }
  139. // EditPptEnglish 编辑ppt
  140. func EditPptEnglish(item *PptEnglish) (err error) {
  141. o := orm.NewOrmUsingDB("rddp")
  142. sql := `UPDATE ppt_english SET title = ?,ppt_date= ?, report_type=?,modify_time=NOW() WHERE ppt_id = ? `
  143. _, err = o.Raw(sql, item.Title, item.PptDate, item.ReportType, item.PptId).Exec()
  144. return
  145. }
  146. type DeletePptEnglishReq struct {
  147. PptId int `description:"PptId" `
  148. }
  149. // SavePptEnglishPathReq 保存ppt的下载地址请求
  150. type SavePptEnglishPathReq struct {
  151. PptId int `description:"PptId" `
  152. PptxUrl string `description:"PptxUrl" `
  153. }
  154. func GetPptEnglishById(pptId int) (item *PptEnglish, err error) {
  155. o := orm.NewOrmUsingDB("rddp")
  156. sql := `SELECT * FROM ppt_english WHERE 1=1 AND ppt_id=? `
  157. err = o.Raw(sql, pptId).QueryRow(&item)
  158. return
  159. }
  160. func GetPptEnglishByIds(pptIds []int) (list []*PptEnglish, err error) {
  161. _, err = orm.NewOrmUsingDB("rddp").
  162. QueryTable("ppt_english").
  163. Filter("ppt_id__in", pptIds).
  164. All(&list)
  165. return
  166. }
  167. func GetPptEnglishByTitle(title string) (item *PptEnglish, err error) {
  168. o := orm.NewOrmUsingDB("rddp")
  169. sql := `SELECT * FROM ppt_english WHERE 1=1 AND title=? `
  170. err = o.Raw(sql, title).QueryRow(&item)
  171. return
  172. }
  173. type PptPages struct {
  174. PptPagesId int `orm:"column(ppt_pages_id);pk" description:"报告章节Id"`
  175. PptId int64 `description:"ppt_id"`
  176. Title string `description:"标题"`
  177. ImgUrl string `description:"图片路径"`
  178. CreateTime time.Time `description:"创建时间"`
  179. ModifyTime time.Time `description:"修改时间"`
  180. PageCode string `description:"编码"`
  181. Width int `description:"宽度"`
  182. Height int `description:"高端"`
  183. ResourceId string `description:"来源id,来自上海策略组提供的图表id"`
  184. Timestamp int `description:"时间戳"`
  185. BackIndex int `description:"背景图片下标"`
  186. }
  187. type PptEnglishDetailResp struct {
  188. PptPages []*PptPages `description:"ppt详情数据"`
  189. Ppt *PptEnglish `description:"ppt数据"`
  190. }
  191. type PptEnglishPublishReq struct {
  192. PptId int `description:"PptId"`
  193. ScreenHeight int `description:"屏幕宽高"`
  194. }
  195. // EditPptEnglishPath 编辑Ppt的下载地址
  196. func EditPptEnglishPath(pptId int, pptxPath string) (err error) {
  197. sql := `UPDATE ppt_english SET pptx_url=?,modify_time=NOW(),publish_time=NOW() WHERE ppt_id=? `
  198. o := orm.NewOrmUsingDB("rddp")
  199. _, err = o.Raw(sql, pptxPath, pptId).Exec()
  200. return
  201. }
  202. // AddPptEnglishPublishRecord 发布记录表
  203. type PptEnglishPublishRecord struct {
  204. Id int `orm:"column(id);pk"`
  205. PptId int
  206. PptUrl string
  207. CreateTime time.Time
  208. }
  209. // AddPptEnglishPublishRecord 添加发布记录,主要是记录每次发布的时候,当前的ppt
  210. func AddPptEnglishPublishRecord(item *PptEnglishPublishRecord) (lastId int64, err error) {
  211. o := orm.NewOrmUsingDB("rddp")
  212. lastId, err = o.Insert(item)
  213. return
  214. }
  215. // PptEnglishSaveLog ppt记录表
  216. type PptEnglishSaveLog struct {
  217. Id int `orm:"column(id);pk" description:"自增Id"`
  218. PptId int `orm:"column(ppt_id)" description:"ppt的Id"`
  219. TemplateType int `description:"模版类型"`
  220. BackgroundImg string `description:"背景图片"`
  221. Title string `description:"标题"`
  222. ReportType string `description:"报告类型"`
  223. PptDate string `description:"选择日期"`
  224. Content string `description:"ppt内容"`
  225. AdminId int `description:"系统用户id"`
  226. AdminRealName string `description:"系统用户名称"`
  227. CreateTime time.Time `description:"创建时间"`
  228. CoverContent string `description:"PPT内容-JSON"`
  229. }
  230. // AddPptEnglishSaveLog 新增PPT日志
  231. func AddPptEnglishSaveLog(item *PptEnglishSaveLog) (lastId int64, err error) {
  232. o := orm.NewOrmUsingDB("rddp")
  233. lastId, err = o.Insert(item)
  234. return
  235. }
  236. type PptEnglishConfigResp struct {
  237. PptNum int `description:"ppt数量" json:"ppt_num"`
  238. ChartNum int `description:"图片数量" json:"chart_num"`
  239. }
  240. type PPT2ReportReq struct {
  241. PptId int `description:"PPT主键"`
  242. ClassifyIdSecond int `description:"报告二级分类ID"`
  243. Title string `description:"标题"`
  244. }
  245. // AddPptEnglishMulti 批量新增ppt
  246. func AddPptEnglishMulti(list []*PptEnglish) (err error) {
  247. o := orm.NewOrmUsingDB("rddp")
  248. _, err = o.InsertMulti(1, list)
  249. return
  250. }
  251. // GetAllPptTitle 获取当前目录的所有名称
  252. func GetAllPptTitle() (names []string, err error) {
  253. o := orm.NewOrmUsingDB("rddp")
  254. sql := "select title from ppt_english"
  255. _, err = o.Raw(sql).QueryRows(&names)
  256. return
  257. }
  258. // PPT2ReportResp PPT转报告响应体
  259. type PPT2ReportResp struct {
  260. ReportId int `description:"关联的报告ID" json:"report_id"`
  261. ReportCode string `description:"关联的报告编码" json:"report_code"`
  262. }
  263. // GetPptEnglishByReportId 通过关联的报告ID获取PPT
  264. func GetPptEnglishByReportId(reportId int) (item *PptEnglish, err error) {
  265. o := orm.NewOrmUsingDB("rddp")
  266. sql := `SELECT * FROM ppt_english WHERE 1=1 AND report_id=? LIMIT 1`
  267. err = o.Raw(sql, reportId).QueryRow(&item)
  268. return
  269. }
  270. // GetSharePptEnglish 获取公开分享的ppt
  271. func GetSharePptEnglish() (items []*PptEnglish, err error) {
  272. o := orm.NewOrmUsingDB("rddp")
  273. sql := `SELECT * FROM ppt_english WHERE 1=1 AND is_share = 1 ORDER BY create_time DESC `
  274. _, err = o.Raw(sql).QueryRows(&items)
  275. return
  276. }
  277. // GetAllPptEnglishList 根据条件获取所有的Ppt
  278. func GetAllPptEnglishList(condition string, pars []interface{}) (items []*PptEnglishItem, err error) {
  279. o := orm.NewOrmUsingDB("rddp")
  280. sql := `SELECT * FROM ppt_english WHERE 1=1 `
  281. if condition != "" {
  282. sql += condition
  283. }
  284. //
  285. sql += `ORDER BY modify_time DESC `
  286. _, err = o.Raw(sql, pars).QueryRows(&items)
  287. return
  288. }
  289. // GetSyncReportPptList 获取所有已经同步了报告的ppt
  290. func GetSyncReportPptList() (list []*PptEnglish, err error) {
  291. sql := `SELECT * FROM ppt_english WHERE report_id>0 `
  292. o := orm.NewOrmUsingDB("rddp")
  293. _, err = o.Raw(sql).QueryRows(&list)
  294. return
  295. }
  296. // GetPPTTitleList 获取PPT标题列表
  297. func GetPPTTitleList() (list []string, err error) {
  298. o := orm.NewOrmUsingDB("rddp")
  299. sql := `SELECT title FROM ppt_english`
  300. _, err = o.Raw(sql).QueryRows(&list)
  301. return
  302. }
  303. // EnglishPPT2ReportReq 英文PPT转报告请求体
  304. type EnglishPPT2ReportReq struct {
  305. PptId int `description:"PPT主键"`
  306. ClassifyIdFirst int `description:"一级分类ID"`
  307. ClassifyIdSecond int `description:"二级分类ID"`
  308. Title string `description:"标题"`
  309. Abstract string `description:"摘要"`
  310. }
  311. // PPTEditingCache PPT编辑缓存信息
  312. type PPTEditingCache struct {
  313. IsEditing bool `description:"是否有人编辑"`
  314. AdminId int `description:"编辑者ID"`
  315. Editor string `description:"编辑者姓名"`
  316. Tips string `description:"提示信息"`
  317. }
  318. func GetPptEnglishByTitleAndId(title string, adminId int) (item *PptEnglish, err error) {
  319. o := orm.NewOrmUsingDB("rddp")
  320. sql := `SELECT * FROM ppt_english WHERE 1=1 AND title=? AND admin_id=? `
  321. err = o.Raw(sql, title, adminId).QueryRow(&item)
  322. return
  323. }
  324. // EnglishPPTDetailResp 英文PPT详情响应体
  325. type EnglishPPTDetailResp struct {
  326. *PptEnglish
  327. Editor PPTEditingCache `description:"编辑人信息"`
  328. }