report_chapter.go 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. package models
  2. import (
  3. "eta_gn/eta_api/global"
  4. "eta_gn/eta_api/models/report"
  5. "eta_gn/eta_api/utils"
  6. "time"
  7. )
  8. // ReportChapter 报告章节
  9. type ReportChapter struct {
  10. ReportChapterId int `gorm:"column:report_chapter_id;primaryKey;autoIncrement:true;not null" description:"报告章节ID"`
  11. ReportId int `gorm:"column:report_id" description:"报告ID"`
  12. ReportType string `gorm:"column:report_type" description:"报告类型 day-晨报 week-周报"`
  13. ClassifyIdFirst int `gorm:"column:classify_id_first" description:"一级分类id"`
  14. ClassifyNameFirst string `gorm:"column:classify_name_first" description:"一级分类名称"`
  15. TypeId int `gorm:"column:type_id" description:"品种ID"`
  16. TypeName string `gorm:"column:type_name" description:"品种名称"`
  17. Title string `gorm:"column:title" description:"标题"`
  18. Abstract string `gorm:"column:abstract" description:"摘要"`
  19. AddType int `gorm:"column:add_type" description:"新增方式:1:新增报告,2:继承报告"`
  20. Author string `gorm:"column:author" description:"作者"`
  21. Content string `gorm:"column:content" description:"内容"`
  22. ContentSub string `gorm:"column:content_sub" description:"内容前两个章节"`
  23. Stage int `gorm:"column:stage" description:"期数"`
  24. Trend string `gorm:"column:trend" description:"趋势观点"`
  25. Sort int `gorm:"column:sort" description:"排序: 数值越小越靠前"`
  26. IsEdit int `gorm:"column:is_edit" description:"是否已编辑 0-待编辑 1-已编辑"`
  27. PublishState int `gorm:"column:publish_state" description:"发布状态 1-待发布,2-已发布"`
  28. PublishTime time.Time `gorm:"column:publish_time" description:"发布时间"`
  29. VideoUrl string `gorm:"column:video_url" description:"音频文件URL"`
  30. VideoName string `gorm:"column:video_name" description:"音频文件名称"`
  31. VideoPlaySeconds string `gorm:"column:video_play_seconds" description:"音频播放时长"`
  32. VideoSize string `gorm:"column:video_size" description:"音频文件大小,单位M"`
  33. VideoKind int `gorm:"column:video_kind" description:"音频生成方式:1,手动上传,2:自动生成"`
  34. CreateTime time.Time `gorm:"column:create_time" description:"创建时间"`
  35. ModifyTime time.Time `gorm:"column:modify_time" description:"修改时间"`
  36. OriginalVideoUrl string `gorm:"column:original_video_url" description:"原始音频文件URL"`
  37. ContentStruct string `gorm:"column:content_struct" description:"内容组件"`
  38. LastModifyAdminId int `gorm:"column:last_modify_admin_id" description:"最后更新人ID"`
  39. LastModifyAdminName string `gorm:"column:last_modify_admin_name" description:"最后更新人姓名"`
  40. ContentModifyTime time.Time `gorm:"column:content_modify_time" description:"内容更新时间"`
  41. ReportLayout int8 `gorm:"column:report_layout" description:"报告布局,1:常规布局,2:智能布局。默认:1"`
  42. ReportCreateTime time.Time `gorm:"column:report_create_time" description:"报告时间创建时间"`
  43. VoiceGenerateType int `gorm:"column:voice_generate_type" description:"音频生成方式,0:系统生成,1:人工上传"`
  44. }
  45. // ReportChapterItem 报告章节详情
  46. type ReportChapterItem struct {
  47. ReportChapterId int `gorm:"column:report_chapter_id;primaryKey;autoIncrement:true;not null" description:"报告章节ID"`
  48. ReportId int `gorm:"column:report_id" description:"报告ID"`
  49. ReportType string `gorm:"column:report_type" description:"报告类型 day-晨报 week-周报"`
  50. ClassifyIdFirst int `gorm:"column:classify_id_first" description:"一级分类id"`
  51. ClassifyNameFirst string `gorm:"column:classify_name_first" description:"一级分类名称"`
  52. TypeId int `gorm:"column:type_id" description:"品种ID"`
  53. TypeName string `gorm:"column:type_name" description:"品种名称"`
  54. Title string `gorm:"column:title" description:"标题"`
  55. Abstract string `gorm:"column:abstract" description:"摘要"`
  56. AddType int `gorm:"column:add_type" description:"新增方式:1:新增报告,2:继承报告"`
  57. Author string `gorm:"column:author" description:"作者"`
  58. Content string `gorm:"column:content" description:"内容"`
  59. ContentSub string `gorm:"column:content_sub" description:"内容前两个章节"`
  60. Stage int `gorm:"column:stage" description:"期数"`
  61. Trend string `gorm:"column:trend" description:"趋势观点"`
  62. Sort int `gorm:"column:sort" description:"排序: 数值越小越靠前"`
  63. IsEdit int `gorm:"column:is_edit" description:"是否已编辑 0-待编辑 1-已编辑"`
  64. PublishState int `gorm:"column:publish_state" description:"发布状态 1-待发布,2-已发布"`
  65. PublishTime string `gorm:"column:publish_time" description:"发布时间"`
  66. VideoUrl string `gorm:"column:video_url" description:"音频文件URL"`
  67. VideoName string `gorm:"column:video_name" description:"音频文件名称"`
  68. VideoPlaySeconds string `gorm:"column:video_play_seconds" description:"音频播放时长"`
  69. VideoSize string `gorm:"column:video_size" description:"音频文件大小,单位M"`
  70. VideoKind int `gorm:"column:video_kind" description:"音频生成方式:1,手动上传,2:自动生成"`
  71. CreateTime string `gorm:"column:create_time" description:"创建时间"`
  72. ModifyTime string `gorm:"column:modify_time" description:"修改时间"`
  73. OriginalVideoUrl string `gorm:"column:original_video_url" description:"原始音频文件URL"`
  74. ContentStruct string `gorm:"column:content_struct" description:"内容组件"`
  75. LastModifyAdminId int `gorm:"column:last_modify_admin_id" description:"最后更新人ID"`
  76. LastModifyAdminName string `gorm:"column:last_modify_admin_name" description:"最后更新人姓名"`
  77. ContentModifyTime string `gorm:"column:content_modify_time" description:"内容更新时间"`
  78. ReportLayout int8 `gorm:"column:report_layout" description:"报告布局,1:常规布局,2:智能布局。默认:1"`
  79. ReportCreateTime string `gorm:"column:report_create_time" description:"报告时间创建时间"`
  80. }
  81. // ReportChapterItemResp
  82. // @Description: 章节详情(带有一些额外的数据)
  83. type ReportChapterItemResp struct {
  84. ReportChapterItem
  85. GrandAdminIdList []int `description:"授权的用户id列表"`
  86. PermissionIdList []int `description:"关联的品种id列表"`
  87. CanEdit bool `description:"是否可编辑"`
  88. Editor string `description:"编辑人"`
  89. HeadImg string `description:"报告头图地址"`
  90. EndImg string `description:"报告尾图地址"`
  91. HeadStyle string `description:"版头样式"`
  92. EndStyle string `description:"版尾样式"`
  93. }
  94. type ReportChapterResp struct {
  95. ReportChapterId int `description:"报告章节ID"`
  96. ReportId int `description:"报告ID"`
  97. ReportType string `description:"报告类型 day-晨报 week-周报"`
  98. TypeId int `description:"品种ID"`
  99. TypeName string `description:"品种名称"`
  100. TypeEditImg string `description:"后台编辑时的图片"`
  101. Title string `description:"标题"`
  102. Abstract string `description:"摘要"`
  103. Author string `description:"作者"`
  104. Content string `description:"内容"`
  105. ContentSub string `description:"内容前两个章节"`
  106. Stage int `description:"期数"`
  107. Trend string `description:"趋势观点"`
  108. Sort int `description:"排序: 数值越小越靠前"`
  109. IsEdit int `description:"是否已编辑 0-待编辑 1-已编辑"`
  110. PublishState int `description:"发布状态 1-待发布,2-已发布"`
  111. VideoUrl string `description:"音频文件URL"`
  112. VideoName string `description:"音频文件名称"`
  113. VideoPlaySeconds string `description:"音频播放时长"`
  114. VideoSize string `description:"音频文件大小,单位M"`
  115. VideoKind int `description:"音频生成方式:1,手动上传,2:自动生成"`
  116. PublishTime string `description:"发布时间"`
  117. CreateTime string `description:"创建时间"`
  118. ModifyTime string `description:"修改时间"`
  119. GrandAdminIdList []int `description:"授权的用户id列表"`
  120. PermissionIdList []int `description:"关联的品种id列表"`
  121. CanEdit bool `description:"是否可编辑"`
  122. Editor string `description:"编辑人"`
  123. IsAuth bool `description:"是否有权限"`
  124. }
  125. // GetChapterListByReportId 根据ReportId获取章节列表
  126. func GetChapterListByReportId(reportId int) (list []*ReportChapter, err error) {
  127. sql := ` SELECT * FROM report_chapter WHERE report_id = ? ORDER BY sort ASC`
  128. err = global.DmSQL["rddp"].Raw(sql, reportId).Find(&list).Error
  129. return
  130. }
  131. // GetPublishedChapterListByReportId 根据ReportId获取已发布章节列表
  132. func GetPublishedChapterListByReportId(reportId int) (list []*ReportChapter, err error) {
  133. sql := ` SELECT * FROM report_chapter WHERE report_id = ? AND publish_state = 2 ORDER BY sort ASC`
  134. err = global.DmSQL["rddp"].Raw(sql, reportId).Find(&list).Error
  135. return
  136. }
  137. // AddReportChapterReq
  138. // @Description: 新增报告章节请求体
  139. type AddReportChapterReq struct {
  140. ReportId int `description:"报告ID"`
  141. Title string `description:"标题"`
  142. PermissionIdList []int `description:"报告关联的品种权限"`
  143. AdminIdList []int `description:"授权的编辑人id列表"`
  144. }
  145. // EditReportChapterReq 编辑报告章节请求体
  146. type EditReportChapterReq struct {
  147. ReportChapterId int `description:"报告章节ID"`
  148. Title string `description:"标题"`
  149. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  150. Author string `description:"作者"`
  151. Content string `description:"内容"`
  152. TickerList []EditTickList `description:"指标信息"`
  153. CreateTime string `description:"发布时间"`
  154. VideoUrl string `description:"音频文件URL"`
  155. VideoName string `description:"音频文件名称"`
  156. VideoPlaySeconds string `description:"音频播放时长"`
  157. VideoSize string `description:"音频文件大小,单位M"`
  158. // 以下是智能研报相关
  159. ContentStruct string `description:"内容组件"`
  160. HeadImg string `description:"报告头图地址"`
  161. EndImg string `description:"报告尾图地址"`
  162. CanvasColor string `description:"画布颜色"`
  163. HeadResourceId int `description:"版头资源ID"`
  164. EndResourceId int `description:"版尾资源ID"`
  165. IsManualSave bool `description:"是否手动保存:true:手动 false:自动"`
  166. }
  167. type EditTickList struct {
  168. Label string
  169. Ticker string
  170. Sort int
  171. }
  172. // GetReportChapterInfoById 根据主键获取报告章节
  173. func GetReportChapterInfoById(reportChapterId int) (item *ReportChapter, err error) {
  174. sql := ` SELECT * FROM report_chapter WHERE report_chapter_id = ? `
  175. err = global.DmSQL["rddp"].Raw(sql, reportChapterId).First(&item).Error
  176. return
  177. }
  178. // GetReportChapterItemById
  179. // @Description: 根据主键获取报告章节(时间格式为字符串的数据)
  180. // @author: Roc
  181. // @datetime 2024-06-27 14:10:29
  182. // @param reportChapterId int
  183. // @return item *ReportChapterItem
  184. // @return err error
  185. func GetReportChapterItemById(reportChapterId int) (item *ReportChapterItem, err error) {
  186. sql := ` SELECT * FROM report_chapter WHERE report_chapter_id = ? `
  187. err = global.DmSQL["rddp"].Raw(sql, reportChapterId).First(&item).Error
  188. return
  189. }
  190. // Add
  191. // @Description: 新增章节报告
  192. // @author: Roc
  193. // @receiver chapterInfo
  194. // @datetime 2024-06-04 15:14:41
  195. // @return err error
  196. func (chapterChapterInfo *ReportChapter) Add() (err error) {
  197. err = global.DmSQL["rddp"].Create(chapterChapterInfo).Error
  198. return
  199. }
  200. // UpdateChapter 更新报表章节
  201. func (chapterChapterInfo *ReportChapter) UpdateChapter(cols []string) (err error) {
  202. err = global.DmSQL["rddp"].Select(cols).Updates(chapterChapterInfo).Error
  203. return
  204. }
  205. // EditChapterTrendTagReq 编辑章节趋势标签请求体
  206. type EditChapterTrendTagReq struct {
  207. ReportChapterId int `description:"章节ID"`
  208. Trend string `description:"趋势"`
  209. }
  210. // UpdateChapterAndTicker 更新章节及ticker
  211. func UpdateChapterAndTicker(reportInfo *Report, chapterInfo *ReportChapter, updateCols []string, tickerList []*ReportChapterTicker) (err error) {
  212. // 更新报告的最近编辑人信息
  213. if err = reportInfo.UpdateReport([]string{"LastModifyAdminId", "LastModifyAdminName", "ModifyTime"}); err != nil {
  214. return
  215. }
  216. // 更新章节
  217. if err = chapterInfo.UpdateChapter(updateCols); err != nil {
  218. return
  219. }
  220. // 清空并新增章节ticker
  221. if err = ClearReportChapterTicker(chapterInfo.ReportChapterId); err != nil {
  222. return
  223. }
  224. tickerLen := len(tickerList)
  225. if tickerLen > 0 {
  226. for i := 0; i < tickerLen; i++ {
  227. _, tmpErr := InsertChapterTicker(tickerList[i])
  228. if tmpErr != nil {
  229. return
  230. }
  231. }
  232. }
  233. return
  234. }
  235. // ReportChapterVideoList 报告章节音频列表
  236. type ReportChapterVideoList struct {
  237. ReportId int `gorm:"column:report_id"` //`description:"报告ID"`
  238. ReportChapterId int `gorm:"column:report_chapter_id"` //`description:"报告章节ID"`
  239. VideoUrl string `gorm:"column:video_url"` //`description:"音频文件URL"`
  240. VideoName string `gorm:"column:video_name"` //`description:"音频文件名称"`
  241. VideoPlaySeconds string `gorm:"column:video_play_seconds"` //`description:"音频播放时长"`
  242. }
  243. // GetReportChapterVideoList 获取报告章节音频列表
  244. func GetReportChapterVideoList(reportId int) (list []*ReportChapterVideoList, err error) {
  245. sql := ` SELECT
  246. report_id,
  247. report_chapter_id,
  248. video_url,
  249. video_name,
  250. video_play_seconds
  251. FROM
  252. report_chapter
  253. WHERE
  254. report_id = ? AND publish_state = 2 AND video_url != ""
  255. ORDER BY
  256. report_chapter_id ASC `
  257. err = global.DmSQL["rddp"].Raw(sql, reportId).Find(&list).Error
  258. return
  259. }
  260. // GetReportChapterVideoListByReportIds 根据报告ID集合获取报告章节音频列表
  261. func GetReportChapterVideoListByReportIds(reportIds []int) (list []*ReportChapterVideoList, err error) {
  262. if len(reportIds) == 0 {
  263. return
  264. }
  265. sql := ` SELECT
  266. report_id,
  267. report_chapter_id,
  268. video_url,
  269. video_name,
  270. video_play_seconds
  271. FROM
  272. report_chapter
  273. WHERE
  274. report_id IN (` + utils.GetOrmInReplace(len(reportIds)) + `) AND publish_state = 2 AND video_url != ''
  275. ORDER BY
  276. report_chapter_id ASC `
  277. err = global.DmSQL["rddp"].Raw(sql, reportIds).Find(&list).Error
  278. return
  279. }
  280. // GetReportChapterVideoListByChapterIds 根据章节ID集合获取报告章节音频列表
  281. func GetReportChapterVideoListByChapterIds(chapterIds []int) (list []*ReportChapterVideoList, err error) {
  282. if len(chapterIds) == 0 {
  283. return
  284. }
  285. sql := ` SELECT
  286. report_id,
  287. report_chapter_id,
  288. video_url,
  289. video_name,
  290. video_play_seconds
  291. FROM
  292. report_chapter
  293. WHERE
  294. report_chapter_id IN (` + utils.GetOrmInReplace(len(chapterIds)) + `) AND publish_state = 2
  295. ORDER BY
  296. report_chapter_id ASC `
  297. err = global.DmSQL["rddp"].Raw(sql, chapterIds).Find(&list).Error
  298. return
  299. }
  300. // PublishReportChapterReq 发布报告章节请求体
  301. type PublishReportChapterReq struct {
  302. ReportChapterId int `description:"报告章节ID"`
  303. PublishReport int `description:"是否同时发布报告"`
  304. }
  305. // GetUnPublishedChapterList
  306. // @Description: 获取报告未发布的章节列表
  307. // @author: Roc
  308. // @datetime 2024-06-14 15:59:23
  309. // @param reportId int
  310. // @return list []*ReportChapter
  311. // @return err error
  312. func GetUnPublishedChapterList(reportId int) (list []*ReportChapter, err error) {
  313. sql := ` SELECT report_chapter_id,report_id,title FROM report_chapter WHERE report_id = ? AND publish_state = 1 ORDER BY sort ASC`
  314. err = global.DmSQL["rddp"].Raw(sql, reportId).Find(&list).Error
  315. return
  316. }
  317. // GetChapterListByChapterIds 根据ReportId获取章节列表
  318. func GetChapterListByChapterIds(chapterIds []int) (list []*ReportChapter, err error) {
  319. if len(chapterIds) == 0 {
  320. return
  321. }
  322. sql := ` SELECT * FROM report_chapter WHERE report_chapter_id IN (` + utils.GetOrmInReplace(len(chapterIds)) + `) ORDER BY sort ASC`
  323. err = global.DmSQL["rddp"].Raw(sql, chapterIds).Find(&list).Error
  324. return
  325. }
  326. // UpdateReportChapterTypeNameByTypeId 更新章节类型名称
  327. func UpdateReportChapterTypeNameByTypeId(typeId int, typeName string) (err error) {
  328. sql := `UPDATE report_chapter SET type_name = ? WHERE type_id = ?`
  329. err = global.DmSQL["rddp"].Exec(sql, typeName, typeId).Error
  330. return
  331. }
  332. // CountReportChapterByTypeId 通过章节类型ID获取章节数
  333. func CountReportChapterByTypeId(typeId int) (count int, err error) {
  334. sql := ` SELECT COUNT(1) AS ct FROM report_chapter WHERE type_id = ?`
  335. err = global.DmSQL["rddp"].Raw(sql, typeId).Scan(&count).Error
  336. return
  337. }
  338. // AddReportChapter
  339. // @Description: 待添加的报告章节
  340. type AddReportChapter struct {
  341. ReportChapter *ReportChapter
  342. GrantList []*report.ReportChapterGrant
  343. GrantPermissionList []*report.ReportChapterPermissionMapping
  344. }
  345. // EditReportChapterBaseInfoAndPermissionReq
  346. // @Description: 编辑报告章节的基础信息请求
  347. type EditReportChapterBaseInfoAndPermissionReq struct {
  348. ReportChapterId int `description:"报告章节ID"`
  349. Title string `description:"标题"`
  350. PermissionIdList []int `description:"报告关联的品种权限"`
  351. AdminIdList []int `description:"授权的编辑人id列表"`
  352. }
  353. // GetReportChapterIdList
  354. // @Description: 获取报告的所有章节id列表
  355. // @author: Roc
  356. // @datetime 2024-06-05 11:09:40
  357. // @param reportId int
  358. // @return list []int
  359. // @return err error
  360. func GetReportChapterIdList(reportId int) (list []int, err error) {
  361. sql := ` SELECT report_chapter_id FROM report_chapter
  362. WHERE report_id = ?
  363. ORDER BY report_chapter_id ASC `
  364. err = global.DmSQL["rddp"].Raw(sql, reportId).Scan(&list).Error
  365. return
  366. }
  367. // ReportChapterMoveReq
  368. // @Description: 报告章节移动请求
  369. type ReportChapterMoveReq struct {
  370. ReportChapterId int `description:"报告章节id"`
  371. PrevReportChapterId int `description:"上一个兄弟节点报告章节id"`
  372. NextReportChapterId int `description:"下一个兄弟节点报告章节id"`
  373. }
  374. // GetReportChapterById
  375. // @Description: 获取具体章节
  376. // @author: Roc
  377. // @receiver r
  378. // @datetime 2024-06-06 09:32:40
  379. // @param reportChapterId int
  380. // @return item *ReportChapter
  381. // @return err error
  382. func (chapterChapterInfo *ReportChapter) GetReportChapterById(reportChapterId int) (item *ReportChapter, err error) {
  383. sql := ` SELECT * FROM report_chapter WHERE report_chapter_id = ?`
  384. err = global.DmSQL["rddp"].Raw(sql, reportChapterId).First(&item).Error
  385. return
  386. }
  387. // UpdateReportChapterSortByReportId
  388. // @Description: 根据父类id更新排序
  389. // @author: Roc
  390. // @receiver chapterChapterInfo
  391. // @datetime 2024-06-06 09:39:28
  392. // @param reportId int
  393. // @param reportChapterId int
  394. // @param nowSort int
  395. // @param updateSort string
  396. // @return err error
  397. func (chapterChapterInfo *ReportChapter) UpdateReportChapterSortByReportId(reportId, reportChapterId, nowSort int, updateSort string) (err error) {
  398. pars := make([]interface{}, 0)
  399. sql := ` update report_chapter set sort = ` + updateSort + ` WHERE report_id = ? AND sort > ?`
  400. pars = append(pars, reportId, nowSort)
  401. if reportChapterId > 0 {
  402. sql += ` or ( report_chapter_id > ? and sort = ? )`
  403. pars = append(pars, reportChapterId, nowSort)
  404. }
  405. err = global.DmSQL["rddp"].Exec(sql, pars...).Error
  406. return
  407. }
  408. // GetFirstReportChapterByReportId
  409. // @Description: 获取当前报告下,且排序数相同 的排序第一条的数据
  410. // @author: Roc
  411. // @receiver chapterChapterInfo
  412. // @datetime 2024-06-06 09:45:32
  413. // @param reportId int
  414. // @return item *ReportChapter
  415. // @return err error
  416. func (chapterChapterInfo *ReportChapter) GetFirstReportChapterByReportId(reportId int) (item *ReportChapter, err error) {
  417. sql := ` SELECT * FROM report_chapter WHERE 1 = 1 AND report_id = ? ORDER BY sort ASC, report_chapter_id ASC LIMIT 1`
  418. err = global.DmSQL["rddp"].Raw(sql, reportId).First(&item).Error
  419. return
  420. }
  421. // GetMaxSortByReportId
  422. // @Description: 获取最大的排序值
  423. // @author: Roc
  424. // @receiver chapterChapterInfo
  425. // @datetime 2024-06-06 09:44:13
  426. // @param reportId int
  427. // @return maxSort int
  428. // @return err error
  429. func (chapterChapterInfo *ReportChapter) GetMaxSortByReportId(reportId int) (maxSort int, err error) {
  430. sql := `SELECT COALESCE(MAX(sort), 0) AS sort FROM report_chapter WHERE report_id = ?`
  431. err = global.DmSQL["rddp"].Raw(sql, reportId).Scan(&maxSort).Error
  432. return
  433. }
  434. // Update
  435. // @Description: 数据变更
  436. // @author: Roc
  437. // @receiver chapterChapterInfo
  438. // @datetime 2024-06-06 09:47:46
  439. // @param cols []string
  440. // @return err error
  441. func (chapterChapterInfo *ReportChapter) Update(cols []string) (err error) {
  442. err = global.DmSQL["rddp"].Select(cols).Updates(chapterChapterInfo).Error
  443. return
  444. }
  445. // DelReportChapterReq
  446. // @Description: 删除报告章节请求体
  447. type DelReportChapterReq struct {
  448. ReportChapterId int `description:"报告章节ID"`
  449. }
  450. // GetCountReportChapterByCondition
  451. // @Description: 根据条件获取章节数量
  452. // @author: Roc
  453. // @datetime 2024-07-15 15:37:50
  454. // @param condition string
  455. // @param pars []interface{}
  456. // @return count int
  457. // @return err error
  458. func GetCountReportChapterByCondition(condition string, pars []interface{}) (count int, err error) {
  459. sql := ` SELECT COUNT(1) AS count FROM report_chapter WHERE 1=1 `
  460. if condition != "" {
  461. sql += condition
  462. }
  463. err = global.DmSQL["rddp"].Raw(sql, pars...).Scan(&count).Error
  464. return
  465. }