ppt_v2.go 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. package models
  2. import (
  3. "eta_gn/eta_api/global"
  4. "eta_gn/eta_api/utils"
  5. "fmt"
  6. "strings"
  7. "time"
  8. "github.com/rdlucklib/rdluck_tools/paging"
  9. )
  10. // PptV2 表
  11. type PptV2 struct {
  12. PptId int `gorm:"column:ppt_id;primaryKey;autoIncrement:true" description:"ppt的Id"`
  13. TemplateType int `gorm:"column:template_type" description:"模版类型"`
  14. BackgroundImg string `gorm:"column:background_img" description:"现在实际存的封面图(前端改动太大,不知道该字段之前谁定义的)"`
  15. Title string `gorm:"column:title" description:"标题"`
  16. Abstract string `gorm:"column:abstract" description:"摘要"`
  17. ReportType string `gorm:"column:report_type" description:"报告类型"`
  18. PptDate string `gorm:"column:ppt_date" description:"选择日期"`
  19. Content string `gorm:"column:content" description:"ppt内容"`
  20. PptUrl string `gorm:"column:ppt_url" description:"ppt下载地址"`
  21. PptxUrl string `gorm:"column:pptx_url" description:"pptx下载地址"`
  22. CreateTime time.Time `gorm:"column:create_time" description:"创建时间"`
  23. ModifyTime time.Time `gorm:"column:modify_time" description:"修改时间"`
  24. AdminId int `gorm:"column:admin_id" description:"系统用户id"`
  25. AdminRealName string `gorm:"column:admin_real_name" description:"系统用户名称"`
  26. PptVersion int8 `gorm:"column:ppt_version" description:"是否ppt的旧版本;1:旧的,2:新的"`
  27. ReportId int `gorm:"column:report_id" description:"关联的报告ID"`
  28. ReportCode string `gorm:"column:report_code" description:"关联的报告code"`
  29. IsShare int8 `gorm:"column:is_share" description:"是否分享,0:不分享,1:分享"`
  30. PublishTime time.Time `gorm:"column:publish_time" description:"发布时间"`
  31. CoverContent string `gorm:"column:cover_content" description:"PPT内容-JSON"`
  32. PptPage int `gorm:"column:ppt_page" description:"PPT页数"`
  33. TitleSetting string `gorm:"column:title_setting" description:"PPT标题设置"`
  34. ClassifyId int `gorm:"column:classify_id" description:"报告分类ID"`
  35. AddType int `gorm:"column:add_type" description:"新增方式:1-新增报告;2-继承报告"`
  36. InheritReportId int `gorm:"column:inherit_report_id" description:"继承的报告ID"`
  37. CollaborateType int `gorm:"column:collaborate_type" description:"协作方式:1-个人;2-多人协作"`
  38. CollaborateUsers string `gorm:"column:collaborate_users" description:"协作人IDs, 英文逗号分隔"`
  39. IsPublicPublish int `gorm:"column:is_public_publish" description:"是否公开发布:1-是;2-否"`
  40. SubmitTime time.Time `gorm:"column:submit_time" description:"提交时间"`
  41. ApproveTime time.Time `gorm:"column:approve_time" description:"审批时间"`
  42. ReportSource int `gorm:"column:report_source" description:"报告来源:1-系统内;2-智力共享"`
  43. OutReportId string `gorm:"column:out_report_id" description:"外部报告ID(或编码)"`
  44. State int `gorm:"column:state" description:"报告状态:1-未发布;2-已发布;3-待提交;4-待审批;5-已驳回;6-已通过"`
  45. TopicEndTime time.Time `gorm:"column:topic_end_time" description:"课题结束时间"`
  46. CurrentBackgroundImg string `gorm:"column:current_background_img" description:"背景图片"`
  47. BackCoverImg string `gorm:"column:back_cover_img" description:"封底图片"`
  48. CurrentBackgroundImgId int `gorm:"column:current_background_img_id" description:"背景图片id"`
  49. BackCoverImgId int `gorm:"column:back_cover_img_id" description:"封底图片id"`
  50. BackgroundImgId int `gorm:"column:background_img_id" description:"封面图id"`
  51. }
  52. type PptV2Item struct {
  53. PptId int `gorm:"column:ppt_id;primaryKey" description:"ppt的Id"`
  54. TemplateType int `gorm:"column:template_type" description:"模版类型"`
  55. BackgroundImg string `gorm:"column:background_img" description:"背景图片"`
  56. Title string `gorm:"column:title" description:"标题"`
  57. ReportType string `gorm:"column:report_type" description:"报告类型"`
  58. PptDate string `gorm:"column:ppt_date" description:"选择日期"`
  59. Content string `gorm:"column:content" description:"ppt内容"`
  60. PptUrl string `gorm:"column:ppt_url" description:"ppt下载地址"`
  61. PptxUrl string `gorm:"column:pptx_url" description:"pptx下载地址"`
  62. CreateTime time.Time `gorm:"column:create_time" description:"创建时间"`
  63. ModifyTime time.Time `gorm:"column:modify_time" description:"修改时间"`
  64. AdminId int `gorm:"column:admin_id" description:"系统用户id"`
  65. AdminRealName string `gorm:"column:admin_real_name" description:"系统用户名称"`
  66. PptVersion int8 `gorm:"column:ppt_version" description:"是否ppt的旧版本;1:旧的,2:新的"`
  67. IsAuth bool `gorm:"column:is_auth" description:"true:有操作权限,false:无操作权限"`
  68. ReportId int `gorm:"column:report_id" description:"报告ID"`
  69. ReportCode string `gorm:"column:report_code" description:"关联的报告code"`
  70. IsShare int8 `gorm:"column:is_share" description:"是否分享,0:不分享,1:分享"`
  71. PublishTime time.Time `gorm:"column:publish_time" description:"发布时间"`
  72. CoverContent string `gorm:"column:cover_content" description:"PPT内容-JSON"`
  73. PptPage int `gorm:"column:ppt_page" description:"PPT页数"`
  74. TitleSetting string `gorm:"column:title_setting" description:"PPT标题设置"`
  75. }
  76. func GetPptV2List(condition string, pars []interface{}, startSize, pageSize int) (items []*PptV2Item, err error) {
  77. sql := `SELECT * FROM ppt_v2 WHERE 1=1 `
  78. if condition != "" {
  79. sql += condition
  80. }
  81. //
  82. sql += `ORDER BY modify_time DESC LIMIT ?,?`
  83. pars = append(pars, startSize)
  84. pars = append(pars, pageSize)
  85. err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
  86. return
  87. }
  88. func GetPptV2ByCondition(condition string, pars []interface{}) (items []*PptV2, err error) {
  89. sql := `SELECT * FROM ppt_v2 WHERE 1=1 `
  90. if condition != "" {
  91. sql += condition
  92. }
  93. //
  94. sql += `ORDER BY modify_time DESC`
  95. err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
  96. return
  97. }
  98. func GetPptV2ListCount(condition string, pars []interface{}) (count int, err error) {
  99. sql := `SELECT COUNT(1) AS count FROM ppt_v2 WHERE 1=1 `
  100. if condition != "" {
  101. sql += condition
  102. }
  103. err = global.DmSQL["rddp"].Raw(sql, pars...).Scan(&count).Error
  104. return
  105. }
  106. type PptV2ListResp struct {
  107. List []*PptV2Item
  108. Paging *paging.PagingItem `description:"分页数据"`
  109. }
  110. // AddPptV2 新增PPT
  111. func AddPptV2(item *PptV2) (lastId int64, err error) {
  112. err = global.DmSQL["rddp"].Create(item).Error
  113. lastId = int64(item.PptId)
  114. return
  115. }
  116. // DeletePptV2 删除ppt
  117. func DeletePptV2(pptId int) (err error) {
  118. sql := `DELETE FROM ppt_v2 WHERE ppt_id=? `
  119. err = global.DmSQL["rddp"].Exec(sql, pptId).Error
  120. return
  121. }
  122. type AddPptV2Req struct {
  123. PptId int64 `description:"ppt_id"`
  124. FirstPage struct {
  125. Title string `description:"标题"`
  126. ReportType string `description:"类型"`
  127. PptDate string `description:"日期"`
  128. ImgUrl string `description:"封面图片"`
  129. CurrentBackgroundImg string `description:"背景图片"`
  130. BackCoverImg string `description:"封底图片"`
  131. CurrentBackgroundImgId int `description:"背景图片id"`
  132. BackCoverImgId int `description:"封底图片id"`
  133. BackgroundImgId int `description:"封面图id"`
  134. BackIndex int `description:"背景图片下标"`
  135. TemplateType int `description:"模版id"`
  136. } `description:"首页"`
  137. Abstract string `description:"摘要"`
  138. CollaborateUsers string `description:"协作人IDs, 英文逗号分隔"`
  139. Content string `description:"ppt的json数据"`
  140. GroupId int64 `description:"目录id"`
  141. CoverContent string `description:"封面图内容-JSON数据"`
  142. TitleSetting string `description:"PPT标题设置"`
  143. }
  144. type AddPptResp struct {
  145. PptId int64 `description:"PptId"`
  146. }
  147. // Update 更新ppt基础信息
  148. func (item *PptV2) Update(cols []string) (err error) {
  149. err = global.DmSQL["rddp"].Select(cols).Updates(item).Error
  150. return
  151. }
  152. type DeletePptV2Req struct {
  153. PptId int `description:"PptId" `
  154. }
  155. // SavePptV2PathReq 保存ppt的下载地址请求
  156. type SavePptV2PathReq struct {
  157. PptId int `description:"PptId" `
  158. PptxUrl string `description:"PptxUrl" `
  159. }
  160. func GetPptV2ById(pptId int) (item *PptV2, err error) {
  161. sql := `SELECT * FROM ppt_v2 WHERE 1=1 AND ppt_id=? `
  162. err = global.DmSQL["rddp"].Raw(sql, pptId).Find(&item).Error
  163. return
  164. }
  165. func GetPptV2ByIds(pptIds []int) (list []*PptV2, err error) {
  166. err = global.DmSQL["rddp"].Table("ppt_v2").Where("ppt_id IN ?", pptIds).Find(&list).Error
  167. return
  168. }
  169. // EditPptV2Path 编辑Ppt的下载地址
  170. func EditPptV2Path(pptId int, pptxPath string) (err error) {
  171. sql := `UPDATE ppt_v2 SET pptx_url=?,modify_time=NOW(),publish_time=NOW() WHERE ppt_id=? `
  172. err = global.DmSQL["rddp"].Exec(sql, pptxPath, pptId).Error
  173. return
  174. }
  175. // PptV2PublishRecord 发布记录表
  176. type PptV2PublishRecord struct {
  177. Id int `gorm:"primaryKey" `
  178. PptId int
  179. PptUrl string
  180. CreateTime time.Time
  181. }
  182. // AddPptV2PublishRecord 添加发布记录,主要是记录每次发布的时候,当前的ppt
  183. func AddPptV2PublishRecord(item *PptV2PublishRecord) (lastId int64, err error) {
  184. err = global.DmSQL["rddp"].Create(item).Error
  185. lastId = int64(item.Id)
  186. return
  187. }
  188. // PptV2SaveLog ppt记录表
  189. type PptV2SaveLog struct {
  190. Id int `gorm:"column:id;primaryKey;autoIncrement" description:"自增Id"`
  191. PptId int `gorm:"column:ppt_id" description:"ppt的Id"`
  192. TemplateType int `gorm:"column:template_type" description:"模版类型"`
  193. BackgroundImg string `gorm:"column:background_img" description:"背景图片"`
  194. Title string `gorm:"column:title" description:"标题"`
  195. ReportType string `gorm:"column:report_type" description:"报告类型"`
  196. PptDate string `gorm:"column:ppt_date" description:"选择日期"`
  197. Content string `gorm:"column:content" description:"ppt内容"`
  198. AdminId int `gorm:"column:admin_id" description:"系统用户id"`
  199. AdminRealName string `gorm:"column:admin_real_name" description:"系统用户名称"`
  200. CreateTime time.Time `gorm:"column:create_time" description:"创建时间"`
  201. CoverContent string `gorm:"column:cover_content" description:"PPT内容-JSON"`
  202. TitleSetting string `gorm:"column:title_setting" description:"PPT标题设置"`
  203. CurrentBackgroundImg string `gorm:"column:current_background_img" description:"背景图片"`
  204. BackCoverImg string `gorm:"column:back_cover_img" description:"封底图片"`
  205. }
  206. // AddPptV2SaveLog 新增PPT日志
  207. func AddPptV2SaveLog(item *PptV2SaveLog) (lastId int64, err error) {
  208. err = global.DmSQL["rddp"].Create(item).Error
  209. lastId = int64(item.Id)
  210. return
  211. }
  212. type PptV2ConfigResp struct {
  213. PptNum int `description:"ppt数量" json:"ppt_num"`
  214. ChartNum int `description:"图片数量" json:"chart_num"`
  215. }
  216. type PPT2ReportReq struct {
  217. PptId int `description:"PPT主键"`
  218. ClassifyId int `description:"报告二级分类ID"`
  219. Title string `description:"标题"`
  220. }
  221. // AddPptV2Multi 批量新增ppt
  222. func AddPptV2Multi(list []*PptV2) (err error) {
  223. err = global.DmSQL["rddp"].CreateInBatches(list, utils.MultiAddNum).Error
  224. return
  225. }
  226. // GetAllPptTitle 获取当前目录的所有名称
  227. func GetAllPptTitle() (names []string, err error) {
  228. sql := "select title from ppt_v2"
  229. err = global.DmSQL["rddp"].Raw(sql).Scan(&names).Error
  230. return
  231. }
  232. // PPT2ReportResp PPT转报告响应体
  233. type PPT2ReportResp struct {
  234. ReportId int `description:"关联的报告ID" json:"report_id"`
  235. ReportCode string `description:"关联的报告编码" json:"report_code"`
  236. }
  237. // GetPptV2ByReportId 通过关联的报告ID获取PPT
  238. func GetPptV2ByReportId(reportId int) (item *PptV2, err error) {
  239. sql := `SELECT * FROM ppt_v2 WHERE 1=1 AND report_id=? LIMIT 1`
  240. err = global.DmSQL["rddp"].Raw(sql, reportId).First(&item).Error
  241. return
  242. }
  243. // GetSharePptV2 获取公开分享的ppt
  244. func GetSharePptV2(IsNewPpt int) (items []*PptV2, err error) {
  245. sql := `SELECT * FROM ppt_v2 WHERE 1=1 AND is_share = 1 `
  246. if IsNewPpt > 0 {
  247. sql += ` AND ppt_version = 2 `
  248. }
  249. sql += `ORDER BY create_time DESC`
  250. err = global.DmSQL["rddp"].Raw(sql).Find(&items).Error
  251. return
  252. }
  253. // GetAllPptV2List 根据条件获取所有的Ppt
  254. func GetAllPptV2List(condition string, pars []interface{}) (items []*PptV2Item, err error) {
  255. sql := `SELECT * FROM ppt_v2 WHERE 1=1 `
  256. if condition != "" {
  257. sql += condition
  258. }
  259. //
  260. sql += `ORDER BY modify_time DESC `
  261. err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
  262. return
  263. }
  264. type EnPPT2CnReq struct {
  265. PptId int `description:"英文PPT主键"`
  266. GroupId int `description:"目录ID"`
  267. }
  268. type BatchEnPPT2CnReq struct {
  269. PptIds string `description:"英文PPT主键s"`
  270. GroupId int `description:"目录ID"`
  271. }
  272. func GetPptV2ByTitleAndId(title string, adminId int) (item *PptV2, err error) {
  273. sql := `SELECT * FROM ppt_v2 WHERE 1=1 AND title=? AND admin_id=? `
  274. err = global.DmSQL["rddp"].Raw(sql, title, adminId).First(&item).Error
  275. return
  276. }
  277. // PPTEditingReq 标记编辑中请求体
  278. type PPTEditingReq struct {
  279. PptId int `description:"PPT主键ID"`
  280. Status int `description:"标记状态: 1-编辑中; 2-编辑完成"`
  281. }
  282. // PPTDetailResp PPT详情响应体
  283. type PPTDetailResp struct {
  284. *PptV2
  285. Editor PPTEditingCache `description:"编辑人信息"`
  286. HasAuth bool `description:"是否有权限"`
  287. }
  288. // PPTEditingCache PPT编辑缓存信息
  289. type PPTEditingCache struct {
  290. IsEditing bool `description:"是否有人编辑"`
  291. AdminId int `description:"编辑者ID"`
  292. Editor string `description:"编辑者姓名"`
  293. Tips string `description:"提示信息"`
  294. }
  295. func (m *PptV2) TableName() string {
  296. return "ppt_v2"
  297. }
  298. func (m *PptV2) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*PptV2, err error) {
  299. fields := strings.Join(fieldArr, ",")
  300. if len(fieldArr) == 0 {
  301. fields = `*`
  302. }
  303. order := `ORDER BY create_time DESC`
  304. if orderRule != "" {
  305. order = ` ORDER BY ` + orderRule
  306. }
  307. sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
  308. err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
  309. return
  310. }
  311. func (m *PptV2) GetPageItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string, startSize, pageSize int) (items []*PptV2, err error) {
  312. fields := strings.Join(fieldArr, ",")
  313. if len(fieldArr) == 0 {
  314. fields = `*`
  315. }
  316. order := `ORDER BY create_time DESC`
  317. if orderRule != "" {
  318. order = ` ORDER BY ` + orderRule
  319. }
  320. sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s LIMIT ?,?`, fields, m.TableName(), condition, order)
  321. pars = append(pars, startSize, pageSize)
  322. err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
  323. return
  324. }
  325. func (m *PptV2) GetPageItemsByConditionWithAdminId(condition string, pars []interface{}, fieldArr []string, orderRule string, adminId, startSize, pageSize int) (items []*PptV2, err error) {
  326. fields := strings.Join(fieldArr, ",")
  327. if len(fieldArr) == 0 {
  328. fields = `*`
  329. }
  330. order := `ORDER BY create_time DESC`
  331. if orderRule != "" {
  332. order = ` ORDER BY ` + orderRule
  333. }
  334. sql := fmt.Sprintf(`
  335. SELECT %s FROM %s WHERE 1=1 AND classify_id NOT IN (
  336. SELECT DISTINCT "classify_id" FROM "classify_visible") %s
  337. UNION ALL
  338. SELECT %s FROM %s WHERE 1=1 AND classify_id IN (
  339. SELECT DISTINCT "classify_id" FROM "classify_visible" WHERE "admin_id" = %d) %s %s LIMIT ?,? `, fields, m.TableName(), condition, fields, m.TableName(), adminId, condition, order)
  340. pars = append(pars, pars...)
  341. pars = append(pars, startSize, pageSize)
  342. err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
  343. return
  344. }
  345. func (m *PptV2) GetCountByCondition(condition string, pars []interface{}) (count int, err error) {
  346. sql := fmt.Sprintf(`SELECT COUNT(1) FROM %s WHERE 1=1 %s`, m.TableName(), condition)
  347. err = global.DmSQL["rddp"].Raw(sql, pars...).Scan(&count).Error
  348. return
  349. }
  350. func (m *PptV2) GetCountByConditionWithAdminId(condition string, pars []interface{}, adminId int) (count int, err error) {
  351. sql := fmt.Sprintf(`
  352. SELECT (
  353. (SELECT COUNT(1) FROM %s WHERE 1=1 AND classify_id NOT IN (
  354. SELECT DISTINCT "classify_id" FROM "classify_visible") %s)
  355. +
  356. (SELECT COUNT(1) FROM %s WHERE 1=1 AND classify_id IN (
  357. SELECT DISTINCT "classify_id" FROM "classify_visible" WHERE "admin_id" = %d) %s)
  358. ) AS count `, m.TableName(), condition, m.TableName(), adminId, condition)
  359. pars = append(pars, pars...)
  360. err = global.DmSQL["rddp"].Raw(sql, pars...).Scan(&count).Error
  361. return
  362. }
  363. // PptReportQueryFields 除富文本的常用查询字段
  364. var PptReportQueryFields = []string{
  365. "ppt_id", "title", "classify_id", "ppt_version", "pptx_url", "ppt_page", "title_setting", "state", "report_source", "publish_time", "submit_time", "approve_time", "create_time", "modify_time", "admin_id", "admin_real_name", "collaborate_type", "collaborate_users",
  366. }
  367. type PptReportItem struct {
  368. PptId int `description:"主键Id"`
  369. Title string `description:"标题"`
  370. ClassifyId int `description:"报告分类ID"`
  371. PptVersion int `description:"是否ppt的旧版本;1:旧的,2:新的"`
  372. PptxUrl string `description:"pptx下载地址"`
  373. PptPage int `description:"PPT总页数"`
  374. //Content string `description:"内容"`
  375. TitleSetting string `description:"PPT标题设置"`
  376. State int `description:"报告状态:1-未发布;2-已发布;3-待提交;4-待审批;5-已驳回;6-已通过"`
  377. ReportSource int `description:"报告来源:1-系统内;2-智力共享"`
  378. PublishTime string `description:"发布时间"`
  379. SubmitTime string `description:"提交时间"`
  380. ApproveTime string `description:"审批时间"`
  381. CreateTime string `description:"创建时间"`
  382. ModifyTime string `description:"更新时间"`
  383. FullClassify string `description:"分类完整路径, /分隔"`
  384. CollaborateType int `description:"协作方式:1-个人;2-多人协作"`
  385. CollaborateUsers []PptReportCollaborateUser `description:"协作人信息"`
  386. HasAuth bool `description:"是否创建人/协作人"`
  387. Editor PPTEditingCache `description:"编辑人信息"`
  388. AdminId int `description:"创建人ID"`
  389. AdminRealName string `description:"创建人姓名"`
  390. }
  391. type PptReportCollaborateUser struct {
  392. AdminId int `description:"用户ID"`
  393. RealName string `description:"用户姓名"`
  394. }
  395. func (m *PptV2) Format2ReportItem(origin *PptV2) (item *PptReportItem) {
  396. if origin == nil {
  397. return
  398. }
  399. item = new(PptReportItem)
  400. item.PptId = origin.PptId
  401. item.Title = origin.Title
  402. item.ClassifyId = origin.ClassifyId
  403. item.PptVersion = int(origin.PptVersion)
  404. item.PptxUrl = origin.PptxUrl
  405. item.PptPage = origin.PptPage
  406. //item.Content = origin.Content
  407. item.TitleSetting = origin.TitleSetting
  408. item.State = origin.State
  409. item.ReportSource = origin.ReportSource
  410. item.PublishTime = utils.TimeTransferString(utils.FormatDateTime, origin.PublishTime)
  411. item.SubmitTime = utils.TimeTransferString(utils.FormatDateTime, origin.SubmitTime)
  412. item.ApproveTime = utils.TimeTransferString(utils.FormatDateTime, origin.ApproveTime)
  413. item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
  414. item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
  415. item.AdminId = origin.AdminId
  416. item.AdminRealName = origin.AdminRealName
  417. item.CollaborateType = origin.CollaborateType
  418. return
  419. }
  420. type PptReportClassifyItem struct {
  421. Id int `description:"分类ID"`
  422. ClassifyName string `description:"分类名称"`
  423. Sort int `description:"排序"`
  424. ParentId int `description:"父级分类ID"`
  425. Enabled int `description:"是否可用,1可用,0禁用"`
  426. Level int `description:"层级"`
  427. HasChild int `description:"是否有子级别,0:下面没有子分类,1:下面有子分类;默认:0"`
  428. ClassifyType int `description:"分类类型:1-研报;2-PPT"`
  429. ReportNum int `description:"分类下的报告数"`
  430. PptList []*PptReportItem `description:"ppt报告"`
  431. Child []*PptReportClassifyItem `description:"子分类"`
  432. }
  433. type PptPageReportResp struct {
  434. List []*PptReportItem
  435. Paging *paging.PagingItem `description:"分页数据"`
  436. }
  437. type PptReportCreateReq struct {
  438. Title string `description:"标题"`
  439. ClassifyId int `description:"分类ID"`
  440. Abstract string `description:"摘要"`
  441. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  442. InheritPptId int `description:"待继承的报告ID"`
  443. CollaborateType int `description:"协作方式,1:个人,2:多人协作。默认:1"`
  444. CollaborateUserIds []int `description:"协作人IDs"`
  445. FirstPage struct {
  446. Title string `description:"标题"`
  447. ReportType string `description:"类型"`
  448. PptDate string `description:"日期"`
  449. ImgUrl string `description:"图片"`
  450. CurrentBackgroundImg string `description:"背景图片"`
  451. BackCoverImg string `description:"封底图片"`
  452. CurrentBackgroundImgId int `description:"背景图片id"`
  453. BackCoverImgId int `description:"封底图片id"`
  454. BackgroundImgId int `description:"封面图id"`
  455. BackIndex int `description:"背景图片下标"`
  456. TemplateType int `description:"模版id"`
  457. } `description:"首页"`
  458. Content string `description:"ppt的json数据"`
  459. CoverContent string `description:"封面图内容-JSON数据"`
  460. TitleSetting string `description:"PPT标题设置"`
  461. }
  462. // MovePptReportClassify 转移PPT报告分类
  463. func MovePptReportClassify(newClassifyId, originClassifyId int) (err error) {
  464. sql := `UPDATE ppt_v2 SET classify_id = ? WHERE classify_id = ?`
  465. err = global.DmSQL["rddp"].Exec(sql, newClassifyId, originClassifyId).Error
  466. return
  467. }
  468. // GetPptByImageIdCount 根据图片id查询ppt信息
  469. func GetPptByImageIdCount(imageId int) (count int, err error) {
  470. sql := `SELECT COUNT(1) FROM ppt_v2 WHERE current_background_img_id = ? or back_cover_img_id = ? or background_img_id = ?`
  471. err = global.DmSQL["rddp"].Raw(sql, imageId, imageId, imageId).Scan(&count).Error
  472. return
  473. }