report_chapter.go 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  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. }
  166. type EditTickList struct {
  167. Label string
  168. Ticker string
  169. Sort int
  170. }
  171. // GetReportChapterInfoById 根据主键获取报告章节
  172. func GetReportChapterInfoById(reportChapterId int) (item *ReportChapter, err error) {
  173. sql := ` SELECT * FROM report_chapter WHERE report_chapter_id = ? `
  174. err = global.DmSQL["rddp"].Raw(sql, reportChapterId).First(&item).Error
  175. return
  176. }
  177. // GetReportChapterItemById
  178. // @Description: 根据主键获取报告章节(时间格式为字符串的数据)
  179. // @author: Roc
  180. // @datetime 2024-06-27 14:10:29
  181. // @param reportChapterId int
  182. // @return item *ReportChapterItem
  183. // @return err error
  184. func GetReportChapterItemById(reportChapterId int) (item *ReportChapterItem, err error) {
  185. sql := ` SELECT * FROM report_chapter WHERE report_chapter_id = ? `
  186. err = global.DmSQL["rddp"].Raw(sql, reportChapterId).First(&item).Error
  187. return
  188. }
  189. // Add
  190. // @Description: 新增章节报告
  191. // @author: Roc
  192. // @receiver chapterInfo
  193. // @datetime 2024-06-04 15:14:41
  194. // @return err error
  195. func (chapterChapterInfo *ReportChapter) Add() (err error) {
  196. err = global.DmSQL["rddp"].Create(chapterChapterInfo).Error
  197. return
  198. }
  199. // UpdateChapter 更新报表章节
  200. func (chapterChapterInfo *ReportChapter) UpdateChapter(cols []string) (err error) {
  201. err = global.DmSQL["rddp"].Select(cols).Updates(chapterChapterInfo).Error
  202. return
  203. }
  204. // EditChapterTrendTagReq 编辑章节趋势标签请求体
  205. type EditChapterTrendTagReq struct {
  206. ReportChapterId int `description:"章节ID"`
  207. Trend string `description:"趋势"`
  208. }
  209. // UpdateChapterAndTicker 更新章节及ticker
  210. func UpdateChapterAndTicker(reportInfo *Report, chapterInfo *ReportChapter, updateCols []string, tickerList []*ReportChapterTicker) (err error) {
  211. // 更新报告的最近编辑人信息
  212. if err = reportInfo.UpdateReport([]string{"LastModifyAdminId", "LastModifyAdminName", "ModifyTime"}); err != nil {
  213. return
  214. }
  215. // 更新章节
  216. if err = chapterInfo.UpdateChapter(updateCols); err != nil {
  217. return
  218. }
  219. // 清空并新增章节ticker
  220. if err = ClearReportChapterTicker(chapterInfo.ReportChapterId); err != nil {
  221. return
  222. }
  223. tickerLen := len(tickerList)
  224. if tickerLen > 0 {
  225. for i := 0; i < tickerLen; i++ {
  226. _, tmpErr := InsertChapterTicker(tickerList[i])
  227. if tmpErr != nil {
  228. return
  229. }
  230. }
  231. }
  232. return
  233. }
  234. // ReportChapterVideoList 报告章节音频列表
  235. type ReportChapterVideoList struct {
  236. ReportId int `gorm:"column:report_id"` //`description:"报告ID"`
  237. ReportChapterId int `gorm:"column:report_chapter_id"` //`description:"报告章节ID"`
  238. VideoUrl string `gorm:"column:video_url"` //`description:"音频文件URL"`
  239. VideoName string `gorm:"column:video_name"` //`description:"音频文件名称"`
  240. VideoPlaySeconds string `gorm:"column:video_play_seconds"` //`description:"音频播放时长"`
  241. }
  242. // GetReportChapterVideoList 获取报告章节音频列表
  243. func GetReportChapterVideoList(reportId int) (list []*ReportChapterVideoList, err error) {
  244. sql := ` SELECT
  245. report_id,
  246. report_chapter_id,
  247. video_url,
  248. video_name,
  249. video_play_seconds
  250. FROM
  251. report_chapter
  252. WHERE
  253. report_id = ? AND publish_state = 2 AND video_url != ""
  254. ORDER BY
  255. report_chapter_id ASC `
  256. err = global.DmSQL["rddp"].Raw(sql, reportId).Find(&list).Error
  257. return
  258. }
  259. // GetReportChapterVideoListByReportIds 根据报告ID集合获取报告章节音频列表
  260. func GetReportChapterVideoListByReportIds(reportIds []int) (list []*ReportChapterVideoList, err error) {
  261. if len(reportIds) == 0 {
  262. return
  263. }
  264. sql := ` SELECT
  265. report_id,
  266. report_chapter_id,
  267. video_url,
  268. video_name,
  269. video_play_seconds
  270. FROM
  271. report_chapter
  272. WHERE
  273. report_id IN (` + utils.GetOrmInReplace(len(reportIds)) + `) AND publish_state = 2 AND video_url != ''
  274. ORDER BY
  275. report_chapter_id ASC `
  276. err = global.DmSQL["rddp"].Raw(sql, reportIds).Find(&list).Error
  277. return
  278. }
  279. // GetReportChapterVideoListByChapterIds 根据章节ID集合获取报告章节音频列表
  280. func GetReportChapterVideoListByChapterIds(chapterIds []int) (list []*ReportChapterVideoList, err error) {
  281. if len(chapterIds) == 0 {
  282. return
  283. }
  284. sql := ` SELECT
  285. report_id,
  286. report_chapter_id,
  287. video_url,
  288. video_name,
  289. video_play_seconds
  290. FROM
  291. report_chapter
  292. WHERE
  293. report_chapter_id IN (` + utils.GetOrmInReplace(len(chapterIds)) + `) AND publish_state = 2
  294. ORDER BY
  295. report_chapter_id ASC `
  296. err = global.DmSQL["rddp"].Raw(sql, chapterIds).Find(&list).Error
  297. return
  298. }
  299. // PublishReportChapterReq 发布报告章节请求体
  300. type PublishReportChapterReq struct {
  301. ReportChapterId int `description:"报告章节ID"`
  302. PublishReport int `description:"是否同时发布报告"`
  303. }
  304. // GetUnPublishedChapterList
  305. // @Description: 获取报告未发布的章节列表
  306. // @author: Roc
  307. // @datetime 2024-06-14 15:59:23
  308. // @param reportId int
  309. // @return list []*ReportChapter
  310. // @return err error
  311. func GetUnPublishedChapterList(reportId int) (list []*ReportChapter, err error) {
  312. sql := ` SELECT report_chapter_id,report_id,title FROM report_chapter WHERE report_id = ? AND publish_state = 1 ORDER BY sort ASC`
  313. err = global.DmSQL["rddp"].Raw(sql, reportId).Find(&list).Error
  314. return
  315. }
  316. // GetChapterListByChapterIds 根据ReportId获取章节列表
  317. func GetChapterListByChapterIds(chapterIds []int) (list []*ReportChapter, err error) {
  318. if len(chapterIds) == 0 {
  319. return
  320. }
  321. sql := ` SELECT * FROM report_chapter WHERE report_chapter_id IN (` + utils.GetOrmInReplace(len(chapterIds)) + `) ORDER BY sort ASC`
  322. err = global.DmSQL["rddp"].Raw(sql, chapterIds).Find(&list).Error
  323. return
  324. }
  325. // UpdateReportChapterTypeNameByTypeId 更新章节类型名称
  326. func UpdateReportChapterTypeNameByTypeId(typeId int, typeName string) (err error) {
  327. sql := `UPDATE report_chapter SET type_name = ? WHERE type_id = ?`
  328. err = global.DmSQL["rddp"].Exec(sql, typeName, typeId).Error
  329. return
  330. }
  331. // CountReportChapterByTypeId 通过章节类型ID获取章节数
  332. func CountReportChapterByTypeId(typeId int) (count int, err error) {
  333. sql := ` SELECT COUNT(1) AS ct FROM report_chapter WHERE type_id = ?`
  334. err = global.DmSQL["rddp"].Raw(sql, typeId).Scan(&count).Error
  335. return
  336. }
  337. // AddReportChapter
  338. // @Description: 待添加的报告章节
  339. type AddReportChapter struct {
  340. ReportChapter *ReportChapter
  341. GrantList []*report.ReportChapterGrant
  342. GrantPermissionList []*report.ReportChapterPermissionMapping
  343. }
  344. // EditReportChapterBaseInfoAndPermissionReq
  345. // @Description: 编辑报告章节的基础信息请求
  346. type EditReportChapterBaseInfoAndPermissionReq struct {
  347. ReportChapterId int `description:"报告章节ID"`
  348. Title string `description:"标题"`
  349. PermissionIdList []int `description:"报告关联的品种权限"`
  350. AdminIdList []int `description:"授权的编辑人id列表"`
  351. }
  352. // GetReportChapterIdList
  353. // @Description: 获取报告的所有章节id列表
  354. // @author: Roc
  355. // @datetime 2024-06-05 11:09:40
  356. // @param reportId int
  357. // @return list []int
  358. // @return err error
  359. func GetReportChapterIdList(reportId int) (list []int, err error) {
  360. sql := ` SELECT report_chapter_id FROM report_chapter
  361. WHERE report_id = ?
  362. ORDER BY report_chapter_id ASC `
  363. err = global.DmSQL["rddp"].Raw(sql, reportId).Scan(&list).Error
  364. return
  365. }
  366. // ReportChapterMoveReq
  367. // @Description: 报告章节移动请求
  368. type ReportChapterMoveReq struct {
  369. ReportChapterId int `description:"报告章节id"`
  370. PrevReportChapterId int `description:"上一个兄弟节点报告章节id"`
  371. NextReportChapterId int `description:"下一个兄弟节点报告章节id"`
  372. }
  373. // GetReportChapterById
  374. // @Description: 获取具体章节
  375. // @author: Roc
  376. // @receiver r
  377. // @datetime 2024-06-06 09:32:40
  378. // @param reportChapterId int
  379. // @return item *ReportChapter
  380. // @return err error
  381. func (chapterChapterInfo *ReportChapter) GetReportChapterById(reportChapterId int) (item *ReportChapter, err error) {
  382. sql := ` SELECT * FROM report_chapter WHERE report_chapter_id = ?`
  383. err = global.DmSQL["rddp"].Raw(sql, reportChapterId).First(&item).Error
  384. return
  385. }
  386. // UpdateReportChapterSortByReportId
  387. // @Description: 根据父类id更新排序
  388. // @author: Roc
  389. // @receiver chapterChapterInfo
  390. // @datetime 2024-06-06 09:39:28
  391. // @param reportId int
  392. // @param reportChapterId int
  393. // @param nowSort int
  394. // @param updateSort string
  395. // @return err error
  396. func (chapterChapterInfo *ReportChapter) UpdateReportChapterSortByReportId(reportId, reportChapterId, nowSort int, updateSort string) (err error) {
  397. pars := make([]interface{}, 0)
  398. sql := ` update report_chapter set sort = ` + updateSort + ` WHERE report_id = ? AND sort > ?`
  399. pars = append(pars, reportId, nowSort)
  400. if reportChapterId > 0 {
  401. sql += ` or ( report_chapter_id > ? and sort = ? )`
  402. pars = append(pars, reportChapterId, nowSort)
  403. }
  404. err = global.DmSQL["rddp"].Exec(sql, pars...).Error
  405. return
  406. }
  407. // GetFirstReportChapterByReportId
  408. // @Description: 获取当前报告下,且排序数相同 的排序第一条的数据
  409. // @author: Roc
  410. // @receiver chapterChapterInfo
  411. // @datetime 2024-06-06 09:45:32
  412. // @param reportId int
  413. // @return item *ReportChapter
  414. // @return err error
  415. func (chapterChapterInfo *ReportChapter) GetFirstReportChapterByReportId(reportId int) (item *ReportChapter, err error) {
  416. sql := ` SELECT * FROM report_chapter WHERE 1 = 1 AND report_id = ? ORDER BY sort ASC, report_chapter_id ASC LIMIT 1`
  417. err = global.DmSQL["rddp"].Raw(sql, reportId).First(&item).Error
  418. return
  419. }
  420. // GetMaxSortByReportId
  421. // @Description: 获取最大的排序值
  422. // @author: Roc
  423. // @receiver chapterChapterInfo
  424. // @datetime 2024-06-06 09:44:13
  425. // @param reportId int
  426. // @return maxSort int
  427. // @return err error
  428. func (chapterChapterInfo *ReportChapter) GetMaxSortByReportId(reportId int) (maxSort int, err error) {
  429. sql := `SELECT COALESCE(MAX(sort), 0) AS sort FROM report_chapter WHERE report_id = ?`
  430. err = global.DmSQL["rddp"].Raw(sql, reportId).Scan(&maxSort).Error
  431. return
  432. }
  433. // Update
  434. // @Description: 数据变更
  435. // @author: Roc
  436. // @receiver chapterChapterInfo
  437. // @datetime 2024-06-06 09:47:46
  438. // @param cols []string
  439. // @return err error
  440. func (chapterChapterInfo *ReportChapter) Update(cols []string) (err error) {
  441. err = global.DmSQL["rddp"].Select(cols).Updates(chapterChapterInfo).Error
  442. return
  443. }
  444. // DelReportChapterReq
  445. // @Description: 删除报告章节请求体
  446. type DelReportChapterReq struct {
  447. ReportChapterId int `description:"报告章节ID"`
  448. }
  449. // GetCountReportChapterByCondition
  450. // @Description: 根据条件获取章节数量
  451. // @author: Roc
  452. // @datetime 2024-07-15 15:37:50
  453. // @param condition string
  454. // @param pars []interface{}
  455. // @return count int
  456. // @return err error
  457. func GetCountReportChapterByCondition(condition string, pars []interface{}) (count int, err error) {
  458. sql := ` SELECT COUNT(1) AS count FROM report_chapter WHERE 1=1 `
  459. if condition != "" {
  460. sql += condition
  461. }
  462. err = global.DmSQL["rddp"].Raw(sql, pars...).Scan(&count).Error
  463. return
  464. }