ppt_english.go 13 KB

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