ppt_v2.go 23 KB

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