report.go 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. package models
  2. import (
  3. "eta_gn/eta_report/global"
  4. "eta_gn/eta_report/utils"
  5. "fmt"
  6. "strings"
  7. "time"
  8. )
  9. // 报告状态
  10. const (
  11. ReportStateUnpublished = 1 // 未发布
  12. ReportStatePublished = 2 // 已发布
  13. ReportStateWaitSubmit = 3 // 待提交
  14. ReportStateWaitApprove = 4 // 审批中
  15. ReportStateRefused = 5 // 已驳回
  16. ReportStatePass = 6 // 已通过
  17. )
  18. //type Report struct {
  19. // Id int `gorm:"primaryKey;autoIncrement;column:id"`
  20. // AddType int `gorm:"column:add_type" description:"新增方式:1:新增报告,2:继承报告"`
  21. // ClassifyIdFirst int `gorm:"column:classify_id_first" description:"一级分类id"`
  22. // ClassifyNameFirst string `gorm:"column:classify_name_first" description:"一级分类名称"`
  23. // ClassifyIdSecond int `gorm:"column:classify_id_second" description:"二级分类id"`
  24. // ClassifyNameSecond string `gorm:"column:classify_name_second" description:"二级分类名称"`
  25. // Title string `gorm:"column:title" description:"标题"`
  26. // Abstract string `gorm:"column:abstract" description:"摘要"`
  27. // Author string `gorm:"column:author" description:"作者"`
  28. // Frequency string `gorm:"column:frequency" description:"频度"`
  29. // CreateTime string `gorm:"column:create_time" description:"创建时间"`
  30. // ModifyTime string `gorm:"column:modify_time" description:"修改时间"`
  31. // State int `gorm:"column:state" description:"1:未发布,2:已发布"`
  32. // PublishTime string `gorm:"column:publish_time" description:"发布时间"`
  33. // PrePublishTime string `gorm:"column:pre_publish_time" description:"预发布时间"`
  34. // Stage int `gorm:"column:stage" description:"期数"`
  35. // MsgIsSend int `gorm:"column:msg_is_send" description:"消息是否已发送,0:否,1:是"`
  36. // Content string `gorm:"column:content" description:"内容"`
  37. // VideoUrl string `gorm:"column:video_url" description:"音频文件URL"`
  38. // VideoName string `gorm:"column:video_name" description:"音频文件名称"`
  39. // VideoPlaySeconds string `gorm:"column:video_play_seconds" description:"音频播放时长"`
  40. // VideoSize string `gorm:"column:video_size" description:"音频文件大小,单位M"`
  41. // ContentSub string `gorm:"column:content_sub" description:"内容前两个章节"`
  42. // IsShowNewLabel int `gorm:"column:is_show_new_label" description:"是否显示新标签"`
  43. // IsCurrentDate int `gorm:"column:is_current_date" description:"是否当前日期"`
  44. // ClassifyName string `gorm:"column:classify_name" description:"分类名称"`
  45. // HasChapter int `gorm:"column:has_chapter" description:"是否有章节"`
  46. // ContentStruct string `gorm:"column:content_struct" description:"内容组件"`
  47. // LastModifyAdminId int `gorm:"column:last_modify_admin_id" description:"最后更新人ID"`
  48. // LastModifyAdminName string `gorm:"column:last_modify_admin_name" description:"最后更新人姓名"`
  49. // ContentModifyTime string `gorm:"column:content_modify_time" description:"内容更新时间"`
  50. // Pv int `gorm:"column:pv" description:"pv"`
  51. // Uv int `gorm:"column:uv" description:"uv"`
  52. // HeadImg string `gorm:"column:head_img" description:"报告头图地址"`
  53. // EndImg string `gorm:"column:end_img" description:"报告尾图地址"`
  54. // HeadStyle string `gorm:"column:head_style" description:"版头样式"`
  55. // EndStyle string `gorm:"column:end_style" description:"版尾样式"`
  56. // CanvasColor string `gorm:"column:canvas_color" description:"画布颜色"`
  57. // NeedSplice int `gorm:"column:need_splice" description:"是否拼接版头版位的标记,主要是为了兼容历史报告。0-不需要 1-需要"`
  58. // HeadResourceId int `gorm:"column:head_resource_id" description:"版头资源ID"`
  59. // EndResourceId int `gorm:"column:end_resource_id" description:"版尾资源ID"`
  60. // ClassifyIdThird int `gorm:"column:classify_id_third" description:"三级分类id"`
  61. // ClassifyNameThird string `gorm:"column:classify_name_third" description:"三级分类名称"`
  62. // CollaborateType int8 `gorm:"column:collaborate_type" description:"协作方式,1:个人,2:多人协作。默认:1"`
  63. // ReportLayout int8 `gorm:"column:report_layout" description:"报告布局,1:常规布局,2:智能布局。默认:1"`
  64. // IsPublicPublish int8 `gorm:"column:is_public_publish" description:"是否公开发布,1:是,2:否"`
  65. // ReportCreateTime string `gorm:"column:report_create_time" description:"报告时间创建时间"`
  66. //}
  67. type Report struct {
  68. Id int `gorm:"column:id;primaryKey;autoIncrement" description:"报告Id"`
  69. AddType int `gorm:"column:add_type" description:"新增方式:1:新增报告,2:继承报告"`
  70. ClassifyIdFirst int `gorm:"column:classify_id_first" description:"一级分类id"`
  71. ClassifyNameFirst string `gorm:"column:classify_name_first" description:"一级分类名称"`
  72. ClassifyIdSecond int `gorm:"column:classify_id_second" description:"二级分类id"`
  73. ClassifyNameSecond string `gorm:"column:classify_name_second" description:"二级分类名称"`
  74. Title string `gorm:"column:title" description:"标题"`
  75. Abstract string `gorm:"column:abstract" description:"摘要"`
  76. Author string `gorm:"column:author" description:"作者"`
  77. Frequency string `gorm:"column:frequency" description:"频度"`
  78. CreateTime time.Time `gorm:"column:create_time" description:"创建时间"`
  79. ModifyTime time.Time `gorm:"column:modify_time;autoUpdateTime" description:"修改时间"`
  80. State int `gorm:"column:state" description:"1:未发布;2:已发布;3-待提交;4-待审批;5-已驳回;6-已通过"`
  81. PublishTime time.Time `gorm:"column:publish_time" description:"发布时间"`
  82. Stage int `gorm:"column:stage" description:"期数"`
  83. MsgIsSend int `gorm:"column:msg_is_send" description:"消息是否已发送,0:否,1:是"`
  84. ThsMsgIsSend int `gorm:"column:ths_msg_is_send" description:"客户群消息是否已发送,0:否,1:是"`
  85. Content string `gorm:"column:content" description:"内容"`
  86. VideoUrl string `gorm:"column:video_url" description:"音频文件URL"`
  87. VideoName string `gorm:"column:video_name" description:"音频文件名称"`
  88. VideoPlaySeconds string `gorm:"column:video_play_seconds" description:"音频播放时长"`
  89. VideoSize string `gorm:"column:video_size" description:"音频文件大小,单位M"`
  90. ContentSub string `gorm:"column:content_sub" description:"内容前两个章节"`
  91. ReportCode string `gorm:"column:report_code" description:"报告唯一编码"`
  92. ReportVersion int `gorm:"column:report_version" description:"1:旧版,2:新版"`
  93. HasChapter int `gorm:"column:has_chapter" description:"是否有章节 0-否 1-是"`
  94. ChapterType string `gorm:"column:chapter_type" description:"章节类型 day-晨报 week-周报"`
  95. OldReportId int `gorm:"column:old_report_id" description:"research_report表ID, 大于0则表示该报告为老后台同步过来的"`
  96. MsgSendTime time.Time `gorm:"column:msg_send_time" description:"模版消息发送时间"`
  97. AdminId int `gorm:"column:admin_id" description:"创建者账号"`
  98. AdminRealName string `gorm:"column:admin_real_name" description:"创建者姓名"`
  99. ApproveTime time.Time `gorm:"column:approve_time" description:"审批时间"`
  100. ApproveId int `gorm:"column:approve_id" description:"审批ID"`
  101. DetailImgUrl string `gorm:"column:detail_img_url" description:"报告详情长图地址"`
  102. DetailPdfUrl string `gorm:"column:detail_pdf_url" description:"报告详情PDF地址"`
  103. ContentStruct string `gorm:"column:content_struct" description:"内容组件"`
  104. LastModifyAdminId int `gorm:"column:last_modify_admin_id" description:"最后更新人ID"`
  105. LastModifyAdminName string `gorm:"column:last_modify_admin_name" description:"最后更新人姓名"`
  106. ContentModifyTime time.Time `gorm:"column:content_modify_time" description:"内容更新时间"`
  107. Pv int `gorm:"column:pv" description:"pv"`
  108. Uv int `gorm:"column:uv" description:"uv"`
  109. HeadImg string `gorm:"column:head_img" description:"报告头图地址"`
  110. EndImg string `gorm:"column:end_img" description:"报告尾图地址"`
  111. CanvasColor string `gorm:"column:canvas_color" description:"画布颜色"`
  112. NeedSplice int `gorm:"column:need_splice" description:"是否拼接版头版位的标记,主要是为了兼容历史报告。0-不需要 1-需要"`
  113. HeadResourceId int `gorm:"column:head_resource_id" description:"版头资源ID"`
  114. EndResourceId int `gorm:"column:end_resource_id" description:"版尾资源ID"`
  115. ClassifyIdThird int `gorm:"column:classify_id_third" description:"三级分类id"`
  116. ClassifyNameThird string `gorm:"column:classify_name_third" description:"三级分类名称"`
  117. CollaborateType int `gorm:"column:collaborate_type" description:"协作方式,1:个人,2:多人协作。默认:1"`
  118. ReportLayout int `gorm:"column:report_layout" description:"报告布局,1:常规布局,2:智能布局。默认:1"`
  119. IsPublicPublish int `gorm:"column:is_public_publish" description:"是否公开发布,1:是,2:否"`
  120. ReportCreateTime time.Time `gorm:"column:report_create_time" description:"报告时间创建时间"`
  121. InheritReportId int `gorm:"column:inherit_report_id" description:"待继承的报告ID"`
  122. VoiceGenerateType int `gorm:"column:voice_generate_type" description:"音频生成方式,0:系统生成,1:人工上传"`
  123. ReportSource int `gorm:"column:report_source" description:"报告来源:1-系统内;2-智力共享"`
  124. OutReportId string `gorm:"column:out_report_id" description:"外部报告ID(或编码)"`
  125. TopicEndTime time.Time `gorm:"column:topic_end_time" description:"课题结束时间"`
  126. HeadStyle string `gorm:"-"`
  127. EndStyle string `gorm:"-"`
  128. }
  129. func GetReportByCode(reportCode string) (item *Report, err error) {
  130. sql := `SELECT * FROM report WHERE report_code=?`
  131. err = global.DEFAULT_DmSQL.Raw(sql, reportCode).Scan(&item).Error
  132. return
  133. }
  134. type ReportShareDetailResp struct {
  135. Report *ReportItem `description:"报告"`
  136. Disclaimer string `description:"免责声明"`
  137. H5ShareName string `description:"研报分享抬头"`
  138. H5ReportShareImg string `description:"研报分享图片"`
  139. WatermarkChart string `description:"图表是否需要水印"`
  140. WatermarkReport string `description:"报告是否需要水印"`
  141. Hz int
  142. ReportLogo string `description:"报告logo"`
  143. }
  144. type ReportItem struct {
  145. *ReportShow
  146. ChapterList []*ReportChapter
  147. }
  148. // UpdateReportPv
  149. // @Description: 研报pv自增
  150. // @author: Roc
  151. // @datetime 2024-07-19 15:46:58
  152. // @param reportId int
  153. // @return err error
  154. func UpdateReportPv(reportId int) (err error) {
  155. sql := `UPDATE report SET pv = pv + 1 WHERE id = ?`
  156. err = global.DEFAULT_DmSQL.Exec(sql, reportId).Error
  157. return
  158. }
  159. func (m *Report) TableName() string {
  160. return "report"
  161. }
  162. func (m *Report) Update(cols []string) (err error) {
  163. err = global.DEFAULT_DmSQL.Select(cols).Updates(m).Error
  164. return
  165. }
  166. func (m *Report) Remove() (err error) {
  167. sql := fmt.Sprintf(`DELETE FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), "id")
  168. err = global.DEFAULT_DmSQL.Exec(sql, m.Id).Error
  169. return
  170. }
  171. func (m *Report) GetItemById(id int) (item *Report, err error) {
  172. sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), "id")
  173. err = global.DEFAULT_DmSQL.Raw(sql, id).First(&item).Error
  174. return
  175. }
  176. func (m *Report) GetItemByCondition(condition string, pars []interface{}, orderRule string) (item *Report, err error) {
  177. order := ``
  178. if orderRule != "" {
  179. order = ` ORDER BY ` + orderRule
  180. }
  181. sql := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s %s LIMIT 1`, m.TableName(), condition, order)
  182. err = global.DEFAULT_DmSQL.Raw(sql, pars...).First(&item).Error
  183. return
  184. }
  185. func (m *Report) GetCountByCondition(condition string, pars []interface{}) (count int, err error) {
  186. sql := fmt.Sprintf(`SELECT COUNT(1) FROM report WHERE 1=1 %s`, condition)
  187. err = global.DEFAULT_DmSQL.Raw(sql, pars...).Scan(&count).Error
  188. return
  189. }
  190. func (m *Report) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*Report, err error) {
  191. fields := strings.Join(fieldArr, ",")
  192. if len(fieldArr) == 0 {
  193. fields = `*`
  194. }
  195. order := `ORDER BY create_time DESC`
  196. if orderRule != "" {
  197. order = ` ORDER BY ` + orderRule
  198. }
  199. sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
  200. err = global.DEFAULT_DmSQL.Raw(sql, pars...).Find(&items).Error
  201. return
  202. }
  203. // CreateReportAndChapters 新增报告和章节
  204. func (m *Report) CreateReportAndChapters(newReport *Report, newChapters []*ReportChapter, newGrants []*ReportGrant, chapterGrantsMapping map[int][]int) (reportId int, err error) {
  205. if newReport == nil {
  206. err = fmt.Errorf("report is nil")
  207. return
  208. }
  209. tx := global.DEFAULT_DmSQL.Begin()
  210. defer func() {
  211. if err != nil {
  212. _ = tx.Rollback()
  213. return
  214. }
  215. _ = tx.Commit()
  216. }()
  217. // 新增报告
  218. if e := tx.Create(newReport).Error; e != nil {
  219. err = fmt.Errorf("insert report err: %v", e)
  220. return
  221. }
  222. reportId = newReport.Id
  223. // 新增报告授权
  224. if len(newGrants) > 0 {
  225. for _, v := range newGrants {
  226. v.ReportId = reportId
  227. }
  228. if e := tx.CreateInBatches(newGrants, utils.MultiAddNum).Error; e != nil {
  229. err = fmt.Errorf("insert report grants err: %v", e)
  230. return
  231. }
  232. }
  233. // 新增报告章节
  234. originNewChapterId := make(map[int]int) // 继承章节ID-新章节ID
  235. if len(newChapters) > 0 {
  236. for _, v := range newChapters {
  237. var originId int
  238. if v.ReportChapterId > 0 {
  239. originId = v.ReportChapterId
  240. v.ReportChapterId = 0
  241. }
  242. v.ReportId = reportId
  243. if e := tx.Create(v).Error; e != nil {
  244. err = fmt.Errorf("insert report chapter err: %v", e)
  245. return
  246. }
  247. if originId > 0 {
  248. originNewChapterId[originId] = v.ReportChapterId
  249. }
  250. }
  251. }
  252. //fmt.Printf("originNewChapterId: %v\n", originNewChapterId)
  253. // 新增章节授权
  254. if len(chapterGrantsMapping) == 0 {
  255. return
  256. }
  257. for k, v := range chapterGrantsMapping {
  258. if k <= 0 || len(v) == 0 {
  259. continue
  260. }
  261. chapterGrants := make([]*ReportChapterGrant, 0)
  262. for _, vv := range v {
  263. cg := &ReportChapterGrant{
  264. AdminId: vv,
  265. ReportChapterId: originNewChapterId[k],
  266. CreateTime: time.Now(),
  267. }
  268. chapterGrants = append(chapterGrants, cg)
  269. }
  270. if e := tx.Create(chapterGrants).Error; e != nil {
  271. err = fmt.Errorf("insert report chapter grants err: %v", e)
  272. return
  273. }
  274. }
  275. return
  276. }
  277. // EditReportAndClearGrant 编辑报告和移除授权
  278. func (m *Report) EditReportAndClearGrant(reportItem *Report, updateCols []string, chapterIds, removeGrants []int) (err error) {
  279. if reportItem == nil {
  280. err = fmt.Errorf("report is nil")
  281. return
  282. }
  283. tx := global.DEFAULT_DmSQL.Begin()
  284. defer func() {
  285. if err != nil {
  286. _ = tx.Rollback()
  287. return
  288. }
  289. _ = tx.Commit()
  290. }()
  291. // 更新报告
  292. if e := tx.Select(updateCols).Updates(reportItem).Error; e != nil {
  293. err = fmt.Errorf("update report err: %v", e)
  294. return
  295. }
  296. // 移除授权
  297. removeLen := len(removeGrants)
  298. if removeLen == 0 {
  299. return
  300. }
  301. sql := fmt.Sprintf(`DELETE FROM report_grant WHERE report_id = ? AND admin_id IN (%s)`, utils.GetOrmInReplace(removeLen))
  302. if e := tx.Exec(sql, reportItem.Id, removeGrants).Error; e != nil {
  303. err = fmt.Errorf("remove report grants err: %v", e)
  304. return
  305. }
  306. // 移除章节授权
  307. if len(chapterIds) == 0 {
  308. return
  309. }
  310. sql = fmt.Sprintf(`DELETE FROM report_chapter_grant WHERE report_chapter_id IN (%s) AND admin_id IN (%s)`, utils.GetOrmInReplace(len(chapterIds)), utils.GetOrmInReplace(removeLen))
  311. if e := tx.Exec(sql, chapterIds, removeGrants).Error; e != nil {
  312. err = fmt.Errorf("remove chapter grants err: %v", e)
  313. return
  314. }
  315. return
  316. }
  317. type ReportShow struct {
  318. Id int `gorm:"column:id;primaryKey;autoIncrement" description:"报告Id"`
  319. AddType int `gorm:"column:add_type" description:"新增方式:1:新增报告,2:继承报告"`
  320. ClassifyIdFirst int `gorm:"column:classify_id_first" description:"一级分类id"`
  321. ClassifyNameFirst string `gorm:"column:classify_name_first" description:"一级分类名称"`
  322. ClassifyIdSecond int `gorm:"column:classify_id_second" description:"二级分类id"`
  323. ClassifyNameSecond string `gorm:"column:classify_name_second" description:"二级分类名称"`
  324. Title string `gorm:"column:title" description:"标题"`
  325. Abstract string `gorm:"column:abstract" description:"摘要"`
  326. Author string `gorm:"column:author" description:"作者"`
  327. Frequency string `gorm:"column:frequency" description:"频度"`
  328. CreateTime string `gorm:"column:create_time" description:"创建时间"`
  329. ModifyTime string `gorm:"column:modify_time;autoUpdateTime" description:"修改时间"`
  330. State int `gorm:"column:state" description:"1:未发布;2:已发布;3-待提交;4-待审批;5-已驳回;6-已通过"`
  331. PublishTime string `gorm:"column:publish_time" description:"发布时间"`
  332. Stage int `gorm:"column:stage" description:"期数"`
  333. MsgIsSend int `gorm:"column:msg_is_send" description:"消息是否已发送,0:否,1:是"`
  334. ThsMsgIsSend int `gorm:"column:ths_msg_is_send" description:"客户群消息是否已发送,0:否,1:是"`
  335. Content string `gorm:"column:content" description:"内容"`
  336. VideoUrl string `gorm:"column:video_url" description:"音频文件URL"`
  337. VideoName string `gorm:"column:video_name" description:"音频文件名称"`
  338. VideoPlaySeconds string `gorm:"column:video_play_seconds" description:"音频播放时长"`
  339. VideoSize string `gorm:"column:video_size" description:"音频文件大小,单位M"`
  340. ContentSub string `gorm:"column:content_sub" description:"内容前两个章节"`
  341. ReportCode string `gorm:"column:report_code" description:"报告唯一编码"`
  342. ReportVersion int `gorm:"column:report_version" description:"1:旧版,2:新版"`
  343. HasChapter int `gorm:"column:has_chapter" description:"是否有章节 0-否 1-是"`
  344. ChapterType string `gorm:"column:chapter_type" description:"章节类型 day-晨报 week-周报"`
  345. OldReportId int `gorm:"column:old_report_id" description:"research_report表ID, 大于0则表示该报告为老后台同步过来的"`
  346. MsgSendTime string `gorm:"column:msg_send_time" description:"模版消息发送时间"`
  347. AdminId int `gorm:"column:admin_id" description:"创建者账号"`
  348. AdminRealName string `gorm:"column:admin_real_name" description:"创建者姓名"`
  349. ApproveTime string `gorm:"column:approve_time" description:"审批时间"`
  350. ApproveId int `gorm:"column:approve_id" description:"审批ID"`
  351. DetailImgUrl string `gorm:"column:detail_img_url" description:"报告详情长图地址"`
  352. DetailPdfUrl string `gorm:"column:detail_pdf_url" description:"报告详情PDF地址"`
  353. ContentStruct string `gorm:"column:content_struct" description:"内容组件"`
  354. LastModifyAdminId int `gorm:"column:last_modify_admin_id" description:"最后更新人ID"`
  355. LastModifyAdminName string `gorm:"column:last_modify_admin_name" description:"最后更新人姓名"`
  356. ContentModifyTime string `gorm:"column:content_modify_time" description:"内容更新时间"`
  357. Pv int `gorm:"column:pv" description:"pv"`
  358. Uv int `gorm:"column:uv" description:"uv"`
  359. HeadImg string `gorm:"column:head_img" description:"报告头图地址"`
  360. EndImg string `gorm:"column:end_img" description:"报告尾图地址"`
  361. CanvasColor string `gorm:"column:canvas_color" description:"画布颜色"`
  362. NeedSplice int `gorm:"column:need_splice" description:"是否拼接版头版位的标记,主要是为了兼容历史报告。0-不需要 1-需要"`
  363. HeadResourceId int `gorm:"column:head_resource_id" description:"版头资源ID"`
  364. EndResourceId int `gorm:"column:end_resource_id" description:"版尾资源ID"`
  365. ClassifyIdThird int `gorm:"column:classify_id_third" description:"三级分类id"`
  366. ClassifyNameThird string `gorm:"column:classify_name_third" description:"三级分类名称"`
  367. CollaborateType int `gorm:"column:collaborate_type" description:"协作方式,1:个人,2:多人协作。默认:1"`
  368. ReportLayout int `gorm:"column:report_layout" description:"报告布局,1:常规布局,2:智能布局。默认:1"`
  369. IsPublicPublish int `gorm:"column:is_public_publish" description:"是否公开发布,1:是,2:否"`
  370. ReportCreateTime string `gorm:"column:report_create_time" description:"报告时间创建时间"`
  371. InheritReportId int `gorm:"column:inherit_report_id" description:"待继承的报告ID"`
  372. VoiceGenerateType int `gorm:"column:voice_generate_type" description:"音频生成方式,0:系统生成,1:人工上传"`
  373. ReportSource int `gorm:"column:report_source" description:"报告来源:1-系统内;2-智力共享"`
  374. OutReportId string `gorm:"column:out_report_id" description:"外部报告ID(或编码)"`
  375. TopicEndTime string `gorm:"column:topic_end_time" description:"课题结束时间"`
  376. HeadStyle string `gorm:"-"`
  377. EndStyle string `gorm:"-"`
  378. }
  379. func (m *Report) Format2Item() (item *ReportShow) {
  380. if m == nil {
  381. return
  382. }
  383. item = new(ReportShow)
  384. item.Id = m.Id
  385. item.AddType = m.AddType
  386. item.ClassifyIdFirst = m.ClassifyIdFirst
  387. item.ClassifyNameFirst = m.ClassifyNameFirst
  388. item.ClassifyIdSecond = m.ClassifyIdSecond
  389. item.ClassifyNameSecond = m.ClassifyNameSecond
  390. item.Title = m.Title
  391. item.Abstract = m.Abstract
  392. item.Author = m.Author
  393. item.Frequency = m.Frequency
  394. item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, m.CreateTime)
  395. item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, m.ModifyTime)
  396. item.State = m.State
  397. item.PublishTime = utils.TimeTransferString(utils.FormatDateTime, m.PublishTime)
  398. item.Stage = m.Stage
  399. item.MsgIsSend = m.MsgIsSend
  400. item.ThsMsgIsSend = m.ThsMsgIsSend
  401. item.Content = m.Content
  402. item.VideoUrl = m.VideoUrl
  403. item.VideoName = m.VideoName
  404. item.VideoPlaySeconds = m.VideoPlaySeconds
  405. item.VideoSize = m.VideoSize
  406. item.ContentSub = m.ContentSub
  407. item.ReportCode = m.ReportCode
  408. item.ReportVersion = m.ReportVersion
  409. item.HasChapter = m.HasChapter
  410. item.ChapterType = m.ChapterType
  411. item.MsgSendTime = utils.TimeTransferString(utils.FormatDateTime, m.MsgSendTime)
  412. item.AdminId = m.AdminId
  413. item.AdminRealName = m.AdminRealName
  414. item.ApproveTime = utils.TimeTransferString(utils.FormatDateTime, m.ApproveTime)
  415. item.ApproveId = m.ApproveId
  416. item.DetailImgUrl = m.DetailImgUrl
  417. item.DetailPdfUrl = m.DetailPdfUrl
  418. item.ContentStruct = m.ContentStruct
  419. item.LastModifyAdminId = m.LastModifyAdminId
  420. item.LastModifyAdminName = m.LastModifyAdminName
  421. item.ContentModifyTime = utils.TimeTransferString(utils.FormatDateTime, m.ContentModifyTime)
  422. item.HeadImg = m.HeadImg
  423. item.EndImg = m.EndImg
  424. item.CanvasColor = m.CanvasColor
  425. item.NeedSplice = m.NeedSplice
  426. item.HeadResourceId = m.HeadResourceId
  427. item.EndResourceId = m.EndResourceId
  428. item.ClassifyIdThird = m.ClassifyIdThird
  429. item.ClassifyNameThird = m.ClassifyNameThird
  430. item.CollaborateType = m.CollaborateType
  431. item.ReportLayout = m.ReportLayout
  432. item.IsPublicPublish = m.IsPublicPublish
  433. item.ReportCreateTime = utils.TimeTransferString(utils.FormatDateTime, m.ReportCreateTime)
  434. item.InheritReportId = m.InheritReportId
  435. item.VoiceGenerateType = m.VoiceGenerateType
  436. item.ReportSource = m.ReportSource
  437. item.OutReportId = m.OutReportId
  438. item.TopicEndTime = utils.TimeTransferString(utils.FormatDateTime, m.TopicEndTime)
  439. item.HeadStyle = m.HeadStyle
  440. item.EndStyle = m.EndStyle
  441. return
  442. }