ppt_english.go 11 KB

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