ppt_english.go 13 KB

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