report.go 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552
  1. package models
  2. import (
  3. "errors"
  4. "eta/eta_api/utils"
  5. "fmt"
  6. "github.com/beego/beego/v2/client/orm"
  7. "github.com/rdlucklib/rdluck_tools/paging"
  8. "strings"
  9. "time"
  10. )
  11. // 报告状态
  12. const (
  13. ReportStateUnpublished = 1 // 未发布
  14. ReportStatePublished = 2 // 已发布
  15. ReportStateWaitSubmit = 3 // 待提交
  16. ReportStateWaitApprove = 4 // 审批中
  17. ReportStateRefused = 5 // 已驳回
  18. ReportStatePass = 6 // 已通过
  19. )
  20. // 报告操作
  21. const (
  22. ReportOperateAdd = 1 // 新增报告
  23. ReportOperateEdit = 2 // 编辑报告
  24. ReportOperatePublish = 3 // 发布报告
  25. ReportOperateCancelPublish = 4 // 取消发布报告
  26. ReportOperateSubmitApprove = 5 // 提交审批
  27. ReportOperateCancelApprove = 6 // 撤回审批
  28. )
  29. type Report struct {
  30. Id int `orm:"column(id)" description:"报告Id"`
  31. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  32. ClassifyIdFirst int `description:"一级分类id"`
  33. ClassifyNameFirst string `description:"一级分类名称"`
  34. ClassifyIdSecond int `description:"二级分类id"`
  35. ClassifyNameSecond string `description:"二级分类名称"`
  36. Title string `description:"标题"`
  37. Abstract string `description:"摘要"`
  38. Author string `description:"作者"`
  39. Frequency string `description:"频度"`
  40. CreateTime string `description:"创建时间"`
  41. ModifyTime time.Time `description:"修改时间"`
  42. State int `description:"1:未发布;2:已发布;3-待提交;4-待审批;5-已驳回;6-已通过"`
  43. PublishTime time.Time `description:"发布时间"`
  44. Stage int `description:"期数"`
  45. MsgIsSend int `description:"消息是否已发送,0:否,1:是"`
  46. ThsMsgIsSend int `description:"客户群消息是否已发送,0:否,1:是"`
  47. Content string `description:"内容"`
  48. VideoUrl string `description:"音频文件URL"`
  49. VideoName string `description:"音频文件名称"`
  50. VideoPlaySeconds string `description:"音频播放时长"`
  51. VideoSize string `description:"音频文件大小,单位M"`
  52. ContentSub string `description:"内容前两个章节"`
  53. ReportCode string `description:"报告唯一编码"`
  54. ReportVersion int `description:"1:旧版,2:新版"`
  55. HasChapter int `description:"是否有章节 0-否 1-是"`
  56. ChapterType string `description:"章节类型 day-晨报 week-周报"`
  57. OldReportId int `description:"research_report表ID, 大于0则表示该报告为老后台同步过来的"`
  58. MsgSendTime time.Time `description:"模版消息发送时间"`
  59. AdminId int `description:"创建者账号"`
  60. AdminRealName string `description:"创建者姓名"`
  61. ApproveTime time.Time `description:"审批时间"`
  62. ApproveId int `description:"审批ID"`
  63. DetailImgUrl string `description:"报告详情长图地址"`
  64. DetailPdfUrl string `description:"报告详情PDF地址"`
  65. ContentStruct string `description:"内容组件"`
  66. LastModifyAdminId int `description:"最后更新人ID"`
  67. LastModifyAdminName string `description:"最后更新人姓名"`
  68. ContentModifyTime time.Time `description:"内容更新时间"`
  69. Pv int `description:"pv"`
  70. Uv int `description:"uv"`
  71. HeadImg string `description:"报告头图地址"`
  72. EndImg string `description:"报告尾图地址"`
  73. CanvasColor string `description:"画布颜色"`
  74. NeedSplice int `description:"是否拼接版头版位的标记,主要是为了兼容历史报告。0-不需要 1-需要"`
  75. HeadResourceId int `description:"版头资源ID"`
  76. EndResourceId int `description:"版尾资源ID"`
  77. ClassifyIdThird int `description:"三级分类id"`
  78. ClassifyNameThird string `description:"三级分类名称"`
  79. CollaborateType int8 `description:"协作方式,1:个人,2:多人协作。默认:1"`
  80. ReportLayout int8 `description:"报告布局,1:常规布局,2:智能布局。默认:1"`
  81. IsPublicPublish int8 `description:"是否公开发布,1:是,2:否"`
  82. ReportCreateTime time.Time `description:"报告时间创建时间"`
  83. InheritReportId int `description:"待继承的报告ID"`
  84. VoiceGenerateType int `description:"音频生成方式,0:系统生成,1:人工上传"`
  85. }
  86. type ReportList struct {
  87. Id int `description:"报告Id"`
  88. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  89. ClassifyIdFirst int `description:"一级分类id"`
  90. ClassifyNameFirst string `description:"一级分类名称"`
  91. ClassifyIdSecond int `description:"二级分类id"`
  92. ClassifyNameSecond string `description:"二级分类名称"`
  93. Title string `description:"标题"`
  94. Abstract string `description:"摘要"`
  95. Author string `description:"作者"`
  96. Frequency string `description:"频度"`
  97. CreateTime string `description:"创建时间"`
  98. ModifyTime string `description:"修改时间"`
  99. State int `description:"1:未发布;2:已发布;3-待提交;4-待审批;5-已驳回;6-已通过"`
  100. PublishTime string `description:"发布时间"`
  101. PrePublishTime string `description:"预发布时间"`
  102. Stage int `description:"期数"`
  103. MsgIsSend int `description:"模板消息是否已发送,0:否,1:是"`
  104. Content string `description:"内容"`
  105. VideoUrl string `description:"音频文件URL"`
  106. VideoName string `description:"音频文件名称"`
  107. VideoPlaySeconds string `description:"音频播放时长"`
  108. ContentSub string `description:"内容前两个章节"`
  109. Pv int `description:"Pv"`
  110. Uv int `description:"Uv"`
  111. ReportCode string `description:"报告唯一编码"`
  112. ReportVersion int `description:"1:旧版,2:新版"`
  113. ThsMsgIsSend int `description:"客户群消息是否已发送,0:否,1:是"`
  114. NeedThsMsg int `description:"是否需要推送客群消息 0-否 1-是"`
  115. HasChapter int `description:"是否有章节 0-否 1-是"`
  116. ChapterType string `description:"章节类型 day-晨报 week-周报"`
  117. ChapterVideoList []*ReportChapterVideoList `description:"章节音频列表"`
  118. OldReportId int `description:"research_report表ID, 大于0则表示该报告为老后台同步过来的"`
  119. MsgSendTime string `description:"模版消息发送时间"`
  120. CanEdit bool `description:"是否可编辑"`
  121. HasAuth bool `description:"是否可操作"`
  122. Editor string `description:"编辑人"`
  123. AdminId int `description:"创建者账号"`
  124. AdminRealName string `description:"创建者姓名"`
  125. ApproveTime string `description:"审批时间"`
  126. DetailImgUrl string `description:"报告详情长图地址"`
  127. DetailPdfUrl string `description:"报告详情PDF地址"`
  128. CollaborateType int8 `description:"协作方式,1:个人,2:多人协作。默认:1"`
  129. ReportLayout int8 `description:"报告布局,1:常规布局,2:智能布局。默认:1"`
  130. IsPublicPublish int8 `description:"是否公开发布,1:是,2:否"`
  131. ReportCreateTime time.Time `description:"报告时间创建时间"`
  132. ContentStruct string `description:"内容组件"`
  133. LastModifyAdminId int `description:"最后更新人ID"`
  134. LastModifyAdminName string `description:"最后更新人姓名"`
  135. ContentModifyTime time.Time `description:"内容更新时间"`
  136. HeadImg string `description:"报告头图地址"`
  137. EndImg string `description:"报告尾图地址"`
  138. CanvasColor string `description:"画布颜色"`
  139. NeedSplice int `description:"是否拼接版头版位的标记,主要是为了兼容历史报告。0-不需要 1-需要"`
  140. HeadResourceId int `description:"版头资源ID"`
  141. EndResourceId int `description:"版尾资源ID"`
  142. ClassifyIdThird int `description:"三级分类id"`
  143. ClassifyNameThird string `description:"三级分类名称"`
  144. InheritReportId int `description:"待继承的报告ID"`
  145. }
  146. type ReportListResp struct {
  147. List []*ReportList
  148. Paging *paging.PagingItem `description:"分页数据"`
  149. }
  150. // GetReportListCountV1
  151. // @Description: 获取普通报告列表的报告数量
  152. // @author: Roc
  153. // @datetime 2024-05-30 15:14:43
  154. // @param condition string
  155. // @param pars []interface{}
  156. // @return count int
  157. // @return err error
  158. func GetReportListCountV1(condition string, pars []interface{}) (count int, err error) {
  159. o := orm.NewOrmUsingDB("rddp")
  160. sql := `SELECT COUNT(1) AS count FROM report as a WHERE 1=1 `
  161. if condition != "" {
  162. sql += condition
  163. }
  164. err = o.Raw(sql, pars).QueryRow(&count)
  165. return
  166. }
  167. // GetReportListV1
  168. // @Description: 获取普通报告列表的数据
  169. // @author: Roc
  170. // @datetime 2024-05-30 15:14:25
  171. // @param condition string
  172. // @param pars []interface{}
  173. // @param startSize int
  174. // @param pageSize int
  175. // @return items []*ReportList
  176. // @return err error
  177. func GetReportListV1(condition string, pars []interface{}, startSize, pageSize int) (items []*ReportList, err error) {
  178. o := orm.NewOrmUsingDB("rddp")
  179. sql := `SELECT * FROM report as a WHERE 1=1 `
  180. if condition != "" {
  181. sql += condition
  182. }
  183. // 排序:1:未发布;2:已发布;3-待提交;4-待审批;5-已驳回;6-已通过
  184. sql += ` ORDER BY FIELD(state,3,1,4,5,6,2), modify_time DESC LIMIT ?,?`
  185. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  186. return
  187. }
  188. // GetReportListByCondition 获取报告列表
  189. func GetReportListByCondition(condition string, pars []interface{}, startSize, pageSize int) (items []*ReportList, err error) {
  190. o := orm.NewOrmUsingDB("rddp")
  191. sql := `SELECT * FROM report as a WHERE 1=1 `
  192. if condition != "" {
  193. sql += condition
  194. }
  195. sql += ` LIMIT ?,?`
  196. _, err = o.Raw(sql, pars, (startSize-1)*pageSize, pageSize).QueryRows(&items)
  197. return
  198. }
  199. type ReportPvUv struct {
  200. ReportId int
  201. PvTotal int
  202. UvTotal int
  203. }
  204. func GetReportPvUvByReportIdList(reportIdList []int) (items []ReportPvUv, err error) {
  205. num := len(reportIdList)
  206. if num <= 0 {
  207. return
  208. }
  209. o := orm.NewOrmUsingDB("rddp")
  210. sql := `SELECT report_id, COUNT(1) as pv_total,COUNT(DISTINCT user_id) as uv_total FROM report_view_record WHERE report_id in (` + utils.GetOrmInReplace(num) + `) GROUP BY report_id`
  211. _, err = o.Raw(sql, reportIdList).QueryRows(&items)
  212. return
  213. }
  214. // GetReportListCountByGrant
  215. // @Description: 获取共享报告列表的报告数量
  216. // @author: Roc
  217. // @datetime 2024-05-30 15:14:01
  218. // @param condition string
  219. // @param pars []interface{}
  220. // @return count int
  221. // @return err error
  222. func GetReportListCountByGrant(condition string, pars []interface{}) (count int, err error) {
  223. o := orm.NewOrmUsingDB("rddp")
  224. sql := `SELECT a.id FROM report as a
  225. JOIN report_grant b on a.id=b.report_id
  226. WHERE 1=1 `
  227. if condition != "" {
  228. sql += condition
  229. }
  230. sql += " GROUP BY a.id "
  231. sql = `SELECT COUNT(1) AS count FROM (` + sql + `) d`
  232. err = o.Raw(sql, pars).QueryRow(&count)
  233. return
  234. }
  235. // GetReportListByGrant
  236. // @Description: 获取共享报告列表的数据
  237. // @author: Roc
  238. // @datetime 2024-05-30 15:15:07
  239. // @param condition string
  240. // @param pars []interface{}
  241. // @param startSize int
  242. // @param pageSize int
  243. // @return items []*ReportList
  244. // @return err error
  245. func GetReportListByGrant(condition string, pars []interface{}, startSize, pageSize int) (items []*ReportList, err error) {
  246. o := orm.NewOrmUsingDB("rddp")
  247. sql := `SELECT a.* FROM report as a JOIN report_grant b on a.id = b.report_id WHERE 1=1 `
  248. if condition != "" {
  249. sql += condition
  250. }
  251. // 排序:1:未发布;2:已发布;3-待提交;4-待审批;5-已驳回;6-已通过
  252. sql += ` GROUP BY a.id ORDER BY FIELD(state,3,1,4,5,6,2), a.modify_time DESC LIMIT ?,?`
  253. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  254. return
  255. }
  256. func GetReportListCount(condition string, pars []interface{}) (count int, err error) {
  257. oRddp := orm.NewOrmUsingDB("rddp")
  258. sql := `SELECT COUNT(1) AS count FROM report WHERE 1=1 `
  259. if condition != "" {
  260. sql += condition
  261. }
  262. err = oRddp.Raw(sql, pars).QueryRow(&count)
  263. return
  264. }
  265. func GetReportList(condition string, pars []interface{}, startSize, pageSize int) (items []*ReportList, err error) {
  266. o := orm.NewOrmUsingDB("rddp")
  267. sql := `SELECT *,
  268. (SELECT COUNT(1) FROM report_view_record AS rvr WHERE rvr.report_id=report.id) AS pv,
  269. (SELECT COUNT(DISTINCT user_id) FROM report_view_record AS rvr WHERE rvr.report_id=report.id) AS uv
  270. FROM report WHERE 1=1 `
  271. if condition != "" {
  272. sql += condition
  273. }
  274. // 排序:1:未发布;2:已发布;3-待提交;4-待审批;5-已驳回;6-已通过
  275. sql += `ORDER BY FIELD(state,3,1,4,5,6,2), modify_time DESC LIMIT ?,?`
  276. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  277. return
  278. }
  279. // PublishReport 发布报告
  280. func PublishReport(reportIds []int) (err error) {
  281. if len(reportIds) == 0 {
  282. return
  283. }
  284. o := orm.NewOrmUsingDB("rddp")
  285. sql := `UPDATE report SET state=2,publish_time=now(),modify_time=NOW() WHERE id IN (` + utils.GetOrmInReplace(len(reportIds)) + `)`
  286. _, err = o.Raw(sql).Exec()
  287. return
  288. }
  289. // PublishCancelReport 取消发布报告
  290. func PublishCancelReport(reportId, state int, publishTimeNullFlag bool, lastModifyAdminId int, lastModifyAdminName string) (err error) {
  291. o := orm.NewOrmUsingDB("rddp")
  292. var sql string
  293. if publishTimeNullFlag {
  294. sql = ` UPDATE report SET state=?, publish_time=null, pre_publish_time=null, pre_msg_send=0,last_modify_admin_id=?,last_modify_admin_name=?,modify_time = NOW() WHERE id =?`
  295. } else {
  296. sql = ` UPDATE report SET state=?, pre_publish_time=null, pre_msg_send=0,last_modify_admin_id=?,last_modify_admin_name=?,modify_time = NOW() WHERE id =?`
  297. }
  298. _, err = o.Raw(sql, state, lastModifyAdminId, lastModifyAdminName, reportId).Exec()
  299. return
  300. }
  301. // 删除报告
  302. func DeleteReport(reportIds int) (err error) {
  303. o := orm.NewOrmUsingDB("rddp")
  304. sql := ` DELETE FROM report WHERE id =? `
  305. _, err = o.Raw(sql, reportIds).Exec()
  306. return
  307. }
  308. type ReportDetail struct {
  309. Id int `orm:"column(id)" description:"报告Id"`
  310. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  311. ClassifyIdFirst int `description:"一级分类id"`
  312. ClassifyNameFirst string `description:"一级分类名称"`
  313. ClassifyIdSecond int `description:"二级分类id"`
  314. ClassifyNameSecond string `description:"二级分类名称"`
  315. Title string `description:"标题"`
  316. Abstract string `description:"摘要"`
  317. Author string `description:"作者"`
  318. Frequency string `description:"频度"`
  319. CreateTime string `description:"创建时间"`
  320. ModifyTime string `description:"修改时间"`
  321. State int `description:"1:未发布,2:已发布"`
  322. PublishTime string `description:"发布时间"`
  323. PrePublishTime string `description:"预发布时间"`
  324. Stage int `description:"期数"`
  325. MsgIsSend int `description:"消息是否已发送,0:否,1:是"`
  326. PreMsgSend int `description:"定时发布成功后是否立即推送模版消息:0否,1是"`
  327. Content string `description:"内容"`
  328. VideoUrl string `description:"音频文件URL"`
  329. VideoName string `description:"音频文件名称"`
  330. VideoPlaySeconds string `description:"音频播放时长"`
  331. ContentSub string `description:"内容前两个章节"`
  332. ThsMsgIsSend int `description:"客户群消息是否已发送,0:否,1:是"`
  333. HasChapter int `description:"是否有章节 0-否 1-是"`
  334. ChapterType string `description:"章节类型 day-晨报 week-周报"`
  335. AdminId int `description:"创建者账号"`
  336. AdminRealName string `description:"创建者姓名"`
  337. ReportCode string `description:"报告唯一编码"`
  338. // eta1.8.3(研报改版)相关内容
  339. ContentStruct string `description:"内容组件"`
  340. LastModifyAdminId int `description:"最后更新人ID"`
  341. LastModifyAdminName string `description:"最后更新人姓名"`
  342. ContentModifyTime time.Time `description:"内容更新时间"`
  343. Pv int `description:"pv"`
  344. Uv int `description:"uv"`
  345. HeadImg string `description:"报告头图地址"`
  346. EndImg string `description:"报告尾图地址"`
  347. HeadStyle string `description:"版头样式"`
  348. EndStyle string `description:"版尾样式"`
  349. CanvasColor string `description:"画布颜色"`
  350. NeedSplice int `description:"是否拼接版头版位的标记,主要是为了兼容历史报告。0-不需要 1-需要"`
  351. HeadResourceId int `description:"版头资源ID"`
  352. EndResourceId int `description:"版尾资源ID"`
  353. ClassifyIdThird int `description:"三级分类id"`
  354. ClassifyNameThird string `description:"三级分类名称"`
  355. CollaborateType int8 `description:"协作方式,1:个人,2:多人协作。默认:1"`
  356. ReportLayout int8 `description:"报告布局,1:常规布局,2:智能布局。默认:1"`
  357. IsPublicPublish int8 `description:"是否公开发布,1:是,2:否"`
  358. ReportCreateTime time.Time `description:"报告时间创建时间"`
  359. }
  360. func GetReportById(reportId int) (item *ReportDetail, err error) {
  361. o := orm.NewOrmUsingDB("rddp")
  362. sql := `SELECT * FROM report WHERE id=?`
  363. err = o.Raw(sql, reportId).QueryRow(&item)
  364. return
  365. }
  366. func GetReportByIds(reportIds string) (list []*ReportDetail, err error) {
  367. o := orm.NewOrmUsingDB("rddp")
  368. sql := `SELECT * FROM report WHERE id in ` + reportIds
  369. _, err = o.Raw(sql).QueryRows(&list)
  370. return
  371. }
  372. // GetSimpleReportByIds 根据报告ID查询报告基本信息
  373. func GetSimpleReportByIds(reportIds []int) (list []*Report, err error) {
  374. if len(reportIds) == 0 {
  375. return
  376. }
  377. o := orm.NewOrmUsingDB("rddp")
  378. sql := `SELECT id, title, report_code FROM report WHERE id IN (` + utils.GetOrmInReplace(len(reportIds)) + `)`
  379. _, err = o.Raw(sql, reportIds).QueryRows(&list)
  380. return
  381. }
  382. // GetReportStage
  383. // @Description: 获取报告的最大期数(每一年的最大期数)
  384. // @author: Roc
  385. // @datetime 2024-06-03 17:44:14
  386. // @param classifyIdFirst int
  387. // @param classifyIdSecond int
  388. // @param classifyIdThird int
  389. // @return count int
  390. // @return err error
  391. func GetReportStage(classifyIdFirst, classifyIdSecond, classifyIdThird int) (count int, err error) {
  392. o := orm.NewOrmUsingDB("rddp")
  393. classifyId := classifyIdThird
  394. if classifyId <= 0 {
  395. classifyId = classifyIdSecond
  396. }
  397. if classifyId <= 0 {
  398. classifyId = classifyIdFirst
  399. }
  400. if classifyId <= 0 {
  401. err = errors.New("错误的分类id")
  402. return
  403. }
  404. yearStart := time.Date(time.Now().Local().Year(), 1, 1, 0, 0, 0, 0, time.Local)
  405. sql := `SELECT MAX(stage) AS max_stage FROM report WHERE create_time > ? `
  406. if classifyIdThird > 0 {
  407. sql += " AND classify_id_third = ? "
  408. } else if classifyIdSecond > 0 {
  409. sql += " AND classify_id_second = ? "
  410. } else {
  411. sql += " AND classify_id_first = ? "
  412. }
  413. o.Raw(sql, yearStart, classifyId).QueryRow(&count)
  414. return
  415. }
  416. // GetReportStageEdit
  417. // @Description: 获取报告的最大期数(每一年的最大期数)
  418. // @author: Roc
  419. // @datetime 2024-06-04 13:50:34
  420. // @param classifyIdFirst int
  421. // @param classifyIdSecond int
  422. // @param classifyIdThird int
  423. // @param reportId int
  424. // @return count int
  425. // @return err error
  426. func GetReportStageEdit(classifyIdFirst, classifyIdSecond, classifyIdThird, reportId int) (count int, err error) {
  427. classifyId := classifyIdThird
  428. if classifyId <= 0 {
  429. classifyId = classifyIdSecond
  430. }
  431. if classifyId <= 0 {
  432. classifyId = classifyIdFirst
  433. }
  434. if classifyId <= 0 {
  435. err = errors.New("错误的分类id")
  436. return
  437. }
  438. yearStart := time.Date(time.Now().Local().Year(), 1, 1, 0, 0, 0, 0, time.Local)
  439. sql := `SELECT MAX(stage) AS max_stage FROM report WHERE create_time > ? AND id<>? `
  440. if classifyIdThird > 0 {
  441. sql += " AND classify_id_third = ? "
  442. } else if classifyIdSecond > 0 {
  443. sql += " AND classify_id_second = ? "
  444. } else {
  445. sql = " AND classify_id_first = ? "
  446. }
  447. o := orm.NewOrmUsingDB("rddp")
  448. o.Raw(sql, yearStart, reportId, classifyId).QueryRow(&count)
  449. return
  450. }
  451. type PublishReq struct {
  452. ReportIds string `description:"报告id,多个用英文逗号隔开"`
  453. ReportUrl string `description:"报告Url"`
  454. }
  455. type PublishCancelReq struct {
  456. ReportIds int `description:"报告id"`
  457. }
  458. type DeleteReq struct {
  459. ReportIds int `description:"报告id"`
  460. }
  461. type AddReq struct {
  462. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  463. ClassifyIdFirst int `description:"一级分类id"`
  464. ClassifyNameFirst string `description:"一级分类名称"`
  465. ClassifyIdSecond int `description:"二级分类id"`
  466. ClassifyNameSecond string `description:"二级分类名称"`
  467. ClassifyIdThird int `description:"三级分类id"`
  468. ClassifyNameThird string `description:"三级分类名称"`
  469. Title string `description:"标题"`
  470. Abstract string `description:"摘要"`
  471. Author string `description:"作者"`
  472. Frequency string `description:"频度"`
  473. State int `description:"状态:1:未发布,2:已发布"`
  474. Content string `description:"内容"`
  475. CreateTime string `description:"创建时间"`
  476. ReportVersion int `description:"1:旧版,2:新版"`
  477. ContentStruct string `description:"内容组件"`
  478. HeadImg string `description:"报告头图地址"`
  479. EndImg string `description:"报告尾图地址"`
  480. CanvasColor string `description:"画布颜色"`
  481. NeedSplice int `description:"是否拼接版头版位的标记,主要是为了兼容历史报告。0-不需要 1-需要"`
  482. HeadResourceId int `description:"版头资源ID"`
  483. EndResourceId int `description:"版尾资源ID"`
  484. CollaborateType int8 `description:"协作方式,1:个人,2:多人协作。默认:1"`
  485. ReportLayout int8 `description:"报告布局,1:常规布局,2:智能布局。默认:1"`
  486. IsPublicPublish int8 `description:"是否公开发布,1:是,2:否"`
  487. InheritReportId int `description:"待继承的报告ID"`
  488. GrantAdminIdList []int `description:"授权用户id列表"`
  489. }
  490. type PrePublishReq struct {
  491. ReportId int `description:"报告id"`
  492. PrePublishTime string `description:"预发布时间"`
  493. PreMsgSend int `description:"定时发布成功后是否立即推送模版消息:0否,1是"`
  494. ReportUrl string `description:"报告Url"`
  495. }
  496. type AddResp struct {
  497. ReportId int64 `description:"报告id"`
  498. ReportCode string `description:"报告code"`
  499. }
  500. func AddReport(item *Report) (lastId int64, err error) {
  501. o := orm.NewOrmUsingDB("rddp")
  502. lastId, err = o.Insert(item)
  503. return
  504. }
  505. type EditReq struct {
  506. ReportId int64 `description:"报告id"`
  507. ClassifyIdFirst int `description:"一级分类id"`
  508. ClassifyNameFirst string `description:"一级分类名称"`
  509. ClassifyIdSecond int `description:"二级分类id"`
  510. ClassifyNameSecond string `description:"二级分类名称"`
  511. ClassifyIdThird int `description:"三级分类id"`
  512. ClassifyNameThird string `description:"三级分类名称"`
  513. Title string `description:"标题"`
  514. Abstract string `description:"摘要"`
  515. Author string `description:"作者"`
  516. Frequency string `description:"频度"`
  517. State int `description:"状态:1:未发布,2:已发布"`
  518. Content string `description:"内容"`
  519. CreateTime string `description:"创建时间"`
  520. ContentStruct string `description:"内容组件"`
  521. HeadImg string `description:"报告头图地址"`
  522. EndImg string `description:"报告尾图地址"`
  523. CanvasColor string `description:"画布颜色"`
  524. NeedSplice int `description:"是否拼接版头版位的标记,主要是为了兼容历史报告。0-不需要 1-需要"`
  525. HeadResourceId int `description:"版头资源ID"`
  526. EndResourceId int `description:"版尾资源ID"`
  527. //CollaborateType int8 `description:"协作方式,1:个人,2:多人协作。默认:1"`
  528. //ReportLayout int8 `description:"报告布局,1:常规布局,2:智能布局。默认:1"`
  529. IsPublicPublish int8 `description:"是否公开发布,1:是,2:否"`
  530. GrantAdminIdList []int `description:"授权用户id列表"`
  531. }
  532. type EditResp struct {
  533. ReportId int64 `description:"报告id"`
  534. ReportCode string `description:"报告code"`
  535. }
  536. func EditReport(item *Report, reportId int64) (err error) {
  537. o := orm.NewOrmUsingDB("rddp")
  538. sql := `UPDATE report
  539. SET
  540. classify_id_first =?,
  541. classify_name_first = ?,
  542. classify_id_second = ?,
  543. classify_name_second = ?,
  544. title = ?,
  545. abstract = ?,
  546. author = ?,
  547. frequency = ?,
  548. state = ?,
  549. content = ?,
  550. content_sub = ?,
  551. stage =?,
  552. create_time = ?,
  553. modify_time = ?
  554. WHERE id = ? `
  555. _, err = o.Raw(sql, item.ClassifyIdFirst, item.ClassifyNameFirst, item.ClassifyIdSecond, item.ClassifyNameSecond, item.Title,
  556. item.Abstract, item.Author, item.Frequency, item.State, item.Content, item.ContentSub, item.Stage, item.CreateTime, time.Now(), reportId).Exec()
  557. return
  558. }
  559. func (m *Report) Update(cols []string) (err error) {
  560. o := orm.NewOrmUsingDB("rddp")
  561. _, err = o.Update(m, cols...)
  562. return
  563. }
  564. type ReportDetailReq struct {
  565. ReportId int `description:"报告id"`
  566. }
  567. type ClassifyIdDetailReq struct {
  568. ClassifyIdFirst int `description:"报告一级分类id"`
  569. ClassifyIdSecond int `description:"报告二级分类id"`
  570. }
  571. func GetReportDetailByClassifyId(classifyIdFirst, classifyIdSecond int) (item *Report, err error) {
  572. o := orm.NewOrmUsingDB("rddp")
  573. sql := ` SELECT * FROM report WHERE 1=1 `
  574. if classifyIdSecond > 0 {
  575. sql = sql + ` AND classify_id_second=? ORDER BY stage DESC LIMIT 1`
  576. err = o.Raw(sql, classifyIdSecond).QueryRow(&item)
  577. } else {
  578. sql = sql + ` AND classify_id_first=? ORDER BY stage DESC LIMIT 1`
  579. err = o.Raw(sql, classifyIdFirst).QueryRow(&item)
  580. }
  581. return
  582. }
  583. type SendTemplateMsgReq struct {
  584. ReportId int `description:"报告id"`
  585. }
  586. // SendTemplateMsgResp
  587. // @Description: 报告推送返回结构体
  588. type SendTemplateMsgResp struct {
  589. ReportId int `description:"报告id"`
  590. MsgSendTime string `description:"报告推送时间"`
  591. }
  592. func ModifyReportMsgIsSend(reportId int) (err error) {
  593. o := orm.NewOrmUsingDB("rddp")
  594. report, err := GetReportById(reportId)
  595. if err != nil {
  596. return
  597. }
  598. if report.MsgIsSend == 0 {
  599. sql := `UPDATE report SET msg_is_send = 1, msg_send_time=NOW() WHERE id = ? `
  600. _, err = o.Raw(sql, reportId).Exec()
  601. }
  602. return
  603. }
  604. func ModifyReportVideo(reportId int, videoUrl, videoName, videoSize string, playSeconds float64) (err error) {
  605. o := orm.NewOrmUsingDB("rddp")
  606. sql := `UPDATE report SET video_url=?,video_name=?,video_play_seconds=?,video_size=? WHERE id=? `
  607. _, err = o.Raw(sql, videoUrl, videoName, playSeconds, videoSize, reportId).Exec()
  608. return
  609. }
  610. // ModifyReportVideoByNoVideo
  611. // @Description: 修改无音频的报告音频信息
  612. // @author: Roc
  613. // @datetime 2024-07-25 18:03:05
  614. // @param reportId int
  615. // @param videoUrl string
  616. // @param videoName string
  617. // @param videoSize string
  618. // @param playSeconds float64
  619. // @return err error
  620. func ModifyReportVideoByNoVideo(reportId int, videoUrl, videoName, videoSize string, playSeconds float64) (err error) {
  621. o := orm.NewOrmUsingDB("rddp")
  622. sql := `UPDATE report SET video_url=?,video_name=?,video_play_seconds=?,video_size=? WHERE id=? AND video_url=""`
  623. _, err = o.Raw(sql, videoUrl, videoName, playSeconds, videoSize, reportId).Exec()
  624. return
  625. }
  626. type ReportItem struct {
  627. Id int `orm:"column(id)" description:"报告Id"`
  628. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  629. ClassifyIdFirst int `description:"一级分类id"`
  630. ClassifyNameFirst string `description:"一级分类名称"`
  631. ClassifyIdSecond int `description:"二级分类id"`
  632. ClassifyNameSecond string `description:"二级分类名称"`
  633. Title string `description:"标题"`
  634. Abstract string `description:"摘要"`
  635. Author string `description:"作者"`
  636. Frequency string `description:"频度"`
  637. CreateTime time.Time `description:"创建时间"`
  638. ModifyTime time.Time `description:"修改时间"`
  639. State int `description:"1:未发布,2:已发布"`
  640. PublishTime time.Time `description:"发布时间"`
  641. Stage int `description:"期数"`
  642. MsgIsSend int `description:"消息是否已发送,0:否,1:是"`
  643. Content string `description:"内容"`
  644. VideoUrl string `description:"音频文件URL"`
  645. VideoName string `description:"音频文件名称"`
  646. VideoPlaySeconds string `description:"音频播放时长"`
  647. ContentSub string `description:"内容前两个章节"`
  648. }
  649. func GetReportItemById(reportId int) (item *ReportItem, err error) {
  650. o := orm.NewOrmUsingDB("rddp")
  651. sql := `SELECT * FROM report WHERE id=?`
  652. err = o.Raw(sql, reportId).QueryRow(&item)
  653. return
  654. }
  655. type SaveReportContent struct {
  656. Content string `description:"内容"`
  657. ReportId int `description:"报告id"`
  658. NoChange int `description:"内容是否未改变:1:内容未改变"`
  659. // 以下是智能研报相关
  660. ContentStruct string `description:"内容组件"`
  661. HeadImg string `description:"报告头图地址"`
  662. EndImg string `description:"报告尾图地址"`
  663. CanvasColor string `description:"画布颜色"`
  664. NeedSplice int `description:"是否拼接版头版位的标记,主要是为了兼容历史报告。0-不需要 1-需要"`
  665. HeadResourceId int `description:"版头资源ID"`
  666. EndResourceId int `description:"版尾资源ID"`
  667. }
  668. func EditReportContent(reportId int, content, contentSub string) (err error) {
  669. o := orm.NewOrmUsingDB("rddp")
  670. sql := ` UPDATE report SET content=?,content_sub=?,modify_time=NOW() WHERE id=? `
  671. _, err = o.Raw(sql, content, contentSub, reportId).Exec()
  672. return
  673. }
  674. func AddReportSaveLog(reportId, adminId int, content, contentSub, contentStruct, canvasColor, adminName string, headResourceId, endResourceId int) (err error) {
  675. o := orm.NewOrmUsingDB("rddp")
  676. sql := ` INSERT INTO report_save_log(report_id, content,content_sub,content_struct,canvas_color,head_resource_id,end_resource_id,admin_id,admin_name) VALUES (?,?,?,?,?,?,?,?,?) `
  677. _, err = o.Raw(sql, reportId, content, contentSub, contentStruct, canvasColor, headResourceId, endResourceId, adminId, adminName).Exec()
  678. return
  679. }
  680. func MultiAddReportChaptersSaveLog(items []*ReportChapter, adminId int, adminRealName string) (err error) {
  681. o := orm.NewOrmUsingDB("rddp")
  682. p, err := o.Raw(`INSERT INTO report_save_log(report_id, report_chapter_id, content, content_sub,content_struct,admin_id, admin_name) VALUES (?,?,?,?,?,?,?)`).Prepare()
  683. if err != nil {
  684. return
  685. }
  686. defer func() {
  687. _ = p.Close()
  688. }()
  689. for _, v := range items {
  690. _, err = p.Exec(v.ReportId, v.ReportChapterId, v.Content, v.ContentSub, v.ContentStruct, adminId, adminRealName)
  691. if err != nil {
  692. return
  693. }
  694. }
  695. return
  696. }
  697. type SaveReportContentResp struct {
  698. ReportId int `description:"报告id"`
  699. }
  700. func ModifyReportCode(reportId int64, reportCode string) (err error) {
  701. o := orm.NewOrmUsingDB("rddp")
  702. sql := `UPDATE report SET report_code=? WHERE id=? `
  703. _, err = o.Raw(sql, reportCode, reportId).Exec()
  704. return
  705. }
  706. func ModifyReportThsMsgIsSend(item *ReportDetail) (err error) {
  707. o := orm.NewOrmUsingDB("rddp")
  708. if item.ThsMsgIsSend == 0 {
  709. sql := `UPDATE report SET ths_msg_is_send = 1 WHERE id = ? `
  710. _, err = o.Raw(sql, item.Id).Exec()
  711. }
  712. return
  713. }
  714. type ThsSendTemplateMsgReq struct {
  715. ReportId []int `description:"报告id"`
  716. }
  717. type PublishDayWeekReportReq struct {
  718. ReportId int `description:"报告ID"`
  719. }
  720. // SaveDayWeekReportReq 新增晨报周报请求体
  721. type SaveDayWeekReportReq struct {
  722. ReportId int `description:"报告ID"`
  723. Title string `description:"标题"`
  724. ReportType string `description:"一级分类ID"`
  725. Author string `description:"作者"`
  726. CreateTime string `description:"创建时间"`
  727. }
  728. // GetDayWeekReportStage 获取晨报周报期数
  729. func GetDayWeekReportStage(classifyIdFirst int, yearStart time.Time) (count int, err error) {
  730. o := orm.NewOrmUsingDB("rddp")
  731. sql := " SELECT MAX(stage) AS max_stage FROM report WHERE classify_id_first = ? AND create_time > ? "
  732. o.Raw(sql, classifyIdFirst, yearStart).QueryRow(&count)
  733. return
  734. }
  735. // GetReportByReportId 主键获取报告
  736. func GetReportByReportId(reportId int) (item *Report, err error) {
  737. o := orm.NewOrmUsingDB("rddp")
  738. sql := `SELECT * FROM report WHERE id = ?`
  739. err = o.Raw(sql, reportId).QueryRow(&item)
  740. return
  741. }
  742. // GetReportByOldReportId 根据老报告id主键获取报告
  743. func GetReportByOldReportId(reportId int) (item *Report, err error) {
  744. o := orm.NewOrmUsingDB("rddp")
  745. sql := `SELECT * FROM report WHERE old_report_id = ?`
  746. err = o.Raw(sql, reportId).QueryRow(&item)
  747. return
  748. }
  749. // DeleteDayWeekReportAndChapter 删除晨周报及章节
  750. func DeleteDayWeekReportAndChapter(reportId int) (err error) {
  751. o := orm.NewOrmUsingDB("rddp")
  752. to, err := o.Begin()
  753. if err != nil {
  754. return
  755. }
  756. defer func() {
  757. if err != nil {
  758. _ = to.Rollback()
  759. } else {
  760. _ = to.Commit()
  761. }
  762. }()
  763. sql := ` DELETE FROM report WHERE id = ? LIMIT 1 `
  764. if _, err = to.Raw(sql, reportId).Exec(); err != nil {
  765. return
  766. }
  767. sql = ` DELETE FROM report_chapter WHERE report_id = ? `
  768. if _, err = to.Raw(sql, reportId).Exec(); err != nil {
  769. return
  770. }
  771. return
  772. }
  773. // UpdateReport 更新报告
  774. func (reportInfo *Report) UpdateReport(cols []string) (err error) {
  775. o := orm.NewOrmUsingDB("rddp")
  776. _, err = o.Update(reportInfo, cols...)
  777. return
  778. }
  779. // ReportDetailView
  780. // @Description: 晨周报详情
  781. type ReportDetailView struct {
  782. *ReportDetail
  783. ChapterList []*ReportChapter
  784. GrandAdminList []ReportDetailViewAdmin
  785. PermissionList []ReportDetailViewPermission
  786. }
  787. // ReportDetailViewAdmin
  788. // @Description: 报告里面的授权人
  789. type ReportDetailViewAdmin struct {
  790. AdminId int
  791. AdminName string
  792. }
  793. // ReportDetailViewPermission
  794. // @Description: 报告分类关联的品种权限
  795. type ReportDetailViewPermission struct {
  796. PermissionId int
  797. PermissionName string
  798. }
  799. func GetUnPublishDayReport(startTime time.Time, endTime time.Time) (item *Report, err error) {
  800. o := orm.NewOrmUsingDB("rddp")
  801. sql := ` SELECT
  802. *
  803. FROM
  804. report AS a
  805. WHERE
  806. a.has_chapter = 1
  807. AND a.chapter_type = "day"
  808. AND a.state = 1
  809. AND (
  810. a.create_time BETWEEN ? AND ?
  811. )
  812. ORDER BY
  813. a.create_time DESC
  814. LIMIT 1 `
  815. err = o.Raw(sql, startTime, endTime).QueryRow(&item)
  816. return
  817. }
  818. type ElasticReportDetail struct {
  819. ReportId int `description:"报告ID"`
  820. ReportChapterId int `description:"报告章节ID"`
  821. Title string `description:"标题"`
  822. Abstract string `description:"摘要"`
  823. BodyContent string `description:"内容"`
  824. PublishTime string `description:"发布时间"`
  825. PublishState int `description:"发布状态 1-未发布 2-已发布"`
  826. Author string `description:"作者"`
  827. ClassifyIdFirst int `description:"一级分类ID"`
  828. ClassifyNameFirst string `description:"一级分类名称"`
  829. ClassifyIdSecond int `description:"二级分类ID"`
  830. ClassifyNameSecond string `description:"二级分类名称"`
  831. ClassifyId int `description:"最小单元的分类ID"`
  832. ClassifyName string `description:"最小单元的分类名称"`
  833. Categories string `description:"关联的品种名称(包括品种别名)"`
  834. StageStr string `description:"报告期数"`
  835. }
  836. // GetLastPublishedDayWeekReport 获取上一篇已发布的晨周报
  837. func GetLastPublishDayWeekReport(chapterType string) (item *Report, err error) {
  838. o := orm.NewOrmUsingDB("rddp")
  839. sql := ` SELECT * FROM report WHERE has_chapter = 1 AND chapter_type = ? AND state = 2 ORDER BY publish_time DESC LIMIT 1 `
  840. err = o.Raw(sql, chapterType).QueryRow(&item)
  841. return
  842. }
  843. // GetNewReportExist
  844. func GetNewReportExist(oldReportId int) (item *Report, err error) {
  845. o := orm.NewOrmUsingDB("rddp")
  846. sql := ` SELECT id FROM report WHERE old_report_id = ? LIMIT 1 `
  847. err = o.Raw(sql, oldReportId).QueryRow(&item)
  848. return
  849. }
  850. // PublishReportAndChapter 发布报告及章节
  851. func PublishReportAndChapter(reportInfo *Report, isPublishReport bool, cols []string) (err error) {
  852. o := orm.NewOrmUsingDB("rddp")
  853. to, err := o.Begin()
  854. if err != nil {
  855. return
  856. }
  857. defer func() {
  858. if err != nil {
  859. _ = to.Rollback()
  860. } else {
  861. _ = to.Commit()
  862. }
  863. }()
  864. // 更新报告
  865. if isPublishReport {
  866. _, err = to.Update(reportInfo, cols...)
  867. if err != nil {
  868. return
  869. }
  870. }
  871. // 发布该报告的所有章节
  872. sql := ` UPDATE report_chapter SET publish_state = 2, publish_time = ? WHERE report_id = ? `
  873. _, err = to.Raw(sql, reportInfo.PublishTime, reportInfo.Id).Exec()
  874. // 发布章节
  875. //if len(publishIds) > 0 {
  876. // sql := ` UPDATE report_chapter SET publish_state = 2, publish_time = ? WHERE report_id = ? AND report_chapter_id IN (` + utils.GetOrmInReplace(len(publishIds)) + `) `
  877. // _, err = to.Raw(sql, reportInfo.PublishTime, reportInfo.Id, publishIds).Exec()
  878. //}
  879. //if len(unPublishIds) > 0 {
  880. // sql := ` UPDATE report_chapter SET publish_state = 1, publish_time = NULL, is_edit = 0 WHERE report_id = ? AND report_chapter_id IN (` + utils.GetOrmInReplace(len(unPublishIds)) + `) `
  881. // _, err = to.Raw(sql, reportInfo.Id, unPublishIds).Exec()
  882. //}
  883. return
  884. }
  885. func GetSyncEmptyVideoReport() (list []*Report, err error) {
  886. o := orm.NewOrmUsingDB("rddp")
  887. sql := ` SELECT id FROM report WHERE old_report_id > 0 AND state = 2 AND chapter_type = "" AND (video_size = "" OR video_play_seconds = "")
  888. UNION ALL
  889. SELECT DISTINCT report_id FROM report_chapter WHERE publish_state = 2 AND (video_size = "" OR video_play_seconds = "") `
  890. _, err = o.Raw(sql).QueryRows(&list)
  891. return
  892. }
  893. // PublishReportById 发布报告
  894. func PublishReportById(reportId int, publishTime time.Time, lastModifyAdminId int, lastModifyAdminName string) (err error) {
  895. o := orm.NewOrmUsingDB("rddp")
  896. sql := `UPDATE report SET state = 2, publish_time = ?, pre_publish_time=null, pre_msg_send=0, modify_time = NOW(),last_modify_admin_id=?,last_modify_admin_name=? WHERE id = ? `
  897. _, err = o.Raw(sql, publishTime, lastModifyAdminId, lastModifyAdminName, reportId).Exec()
  898. return
  899. }
  900. // ResetReportById 重置报告状态
  901. func ResetReportById(reportId, state int, lastModifyAdminId int, lastModifyAdminName string) (err error) {
  902. o := orm.NewOrmUsingDB("rddp")
  903. sql := `UPDATE report SET state = ?, pre_publish_time = null, pre_msg_send = 0, modify_time = NOW(),last_modify_admin_id=?,last_modify_admin_name=? WHERE id = ?`
  904. _, err = o.Raw(sql, state, lastModifyAdminId, lastModifyAdminName, reportId).Exec()
  905. return
  906. }
  907. // GetCommentReportByReportId 查询有留言的报告列表
  908. func GetCommentReportByReportId(condition string, pars []interface{}, startSize, pageSize int) (list []*Report, err error) {
  909. o := orm.NewOrmUsingDB("rddp")
  910. sql := `SELECT
  911. id,
  912. create_time,
  913. title,
  914. classify_name_first,
  915. classify_id_first,
  916. classify_name_second,
  917. classify_id_second,
  918. state,
  919. IF
  920. ( publish_time, publish_time, create_time ) AS publish_time
  921. FROM
  922. report
  923. WHERE
  924. 1=1
  925. `
  926. if condition != "" {
  927. sql += condition
  928. }
  929. sql += ` ORDER BY publish_time DESC , title ASC LIMIT ?,?`
  930. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
  931. return
  932. }
  933. // GetCommentReportByReportIdOrderBy 查询有留言的报告列表(指定排序)
  934. func GetCommentReportByReportIdOrderBy(condition string, pars []interface{}, startSize, pageSize int, orderBy string) (list []*Report, err error) {
  935. o := orm.NewOrmUsingDB("rddp")
  936. sql := `SELECT
  937. id,
  938. create_time,
  939. title,
  940. classify_name_first,
  941. classify_id_first,
  942. classify_name_second,
  943. classify_id_second,
  944. state,
  945. IF
  946. ( publish_time, publish_time, create_time ) AS publish_time
  947. FROM
  948. report
  949. WHERE
  950. 1=1
  951. `
  952. if condition != "" {
  953. sql += condition
  954. }
  955. if orderBy == `` {
  956. sql += ` ORDER BY publish_time DESC , title ASC `
  957. } else {
  958. sql += orderBy
  959. }
  960. sql += ` LIMIT ?,? `
  961. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
  962. return
  963. }
  964. // GetCommentReportTotalByReportId 查询有留言的报告列表总数
  965. func GetCommentReportTotalByReportId(condition string, pars []interface{}) (total int64, err error) {
  966. o := orm.NewOrmUsingDB("rddp")
  967. sql := `SELECT count(*)
  968. FROM report WHERE 1=1`
  969. if condition != "" {
  970. sql += condition
  971. }
  972. err = o.Raw(sql, pars).QueryRow(&total)
  973. return
  974. }
  975. // 点赞相关的报告列表
  976. type LikeReportItem struct {
  977. ReportId int `description:"报告Id"`
  978. ReportChapterId int `description:"报告章节Id"`
  979. ClassifyIdFirst int `description:"一级分类id"`
  980. ClassifyNameFirst string `description:"一级分类名称"`
  981. ClassifyIdSecond int `description:"二级分类id"`
  982. ClassifyNameSecond string `description:"二级分类名称"`
  983. ReportChapterTypeId int `description:"章节类型"`
  984. ReportChapterTypeName string `description:"品种名称"`
  985. PublishTime time.Time `description:"发布时间" `
  986. Title string `description:"标题"`
  987. }
  988. // GetLikeReportByReportIdReportChapterId 获取有被点赞的报告列表
  989. func GetLikeReportByReportIdReportChapterId(reportIds string, chapterIds string, orderStr string, startSize, pageSize int) (list []*LikeReportItem, err error) {
  990. o := orm.NewOrmUsingDB("rddp")
  991. sql := `( SELECT
  992. id AS report_id,
  993. 0 AS report_chapter_id,
  994. classify_id_first,
  995. classify_id_second,
  996. classify_name_first,
  997. classify_name_second,
  998. 0 as report_chapter_type_id,
  999. "" as report_chapter_type_name,
  1000. publish_time,
  1001. title
  1002. FROM
  1003. report
  1004. WHERE
  1005. classify_name_first != "晨报"
  1006. AND classify_name_first != "周报"
  1007. AND id in (` + reportIds + `)
  1008. )
  1009. UNION
  1010. ( SELECT
  1011. report_id,
  1012. report_chapter_id,
  1013. classify_id_first,
  1014. 0 as classify_id_second,
  1015. classify_name_first,
  1016. null as classify_name_second,
  1017. type_id as report_chapter_type_id,
  1018. type_name as report_chapter_type_name,
  1019. publish_time,
  1020. title
  1021. FROM
  1022. report_chapter
  1023. WHERE
  1024. report_chapter_id in (` + chapterIds + `)
  1025. )`
  1026. if orderStr != "" {
  1027. sql += ` ORDER BY FIELD(CONCAT(report_id, "-",report_chapter_id),` + orderStr + `)`
  1028. } else {
  1029. sql += ` ORDER BY publish_time DESC, report_id Desc`
  1030. }
  1031. sql += ` LIMIT ?,?`
  1032. _, err = o.Raw(sql, startSize, pageSize).QueryRows(&list)
  1033. return
  1034. }
  1035. // GetLikeReportTotalByReportIdReportChapterId 获取有被点赞的报告列表总数
  1036. func GetLikeReportTotalByReportIdReportChapterId(reportIds string, chapterIds string) (total int64, err error) {
  1037. o := orm.NewOrmUsingDB("rddp")
  1038. sql := `select count(*) from (( SELECT
  1039. id AS report_id,
  1040. 0 AS report_chapter_id,
  1041. classify_id_first,
  1042. classify_id_second,
  1043. classify_name_first,
  1044. classify_name_second,
  1045. 0 as report_chapter_type_id,
  1046. publish_time,
  1047. title
  1048. FROM
  1049. report
  1050. WHERE
  1051. classify_name_first != "晨报"
  1052. AND classify_name_first != "周报"
  1053. AND id in (` + reportIds + `)
  1054. )
  1055. UNION
  1056. ( SELECT
  1057. report_id,
  1058. report_chapter_id,
  1059. classify_id_first,
  1060. 0 as classify_id_second,
  1061. classify_name_first,
  1062. null as classify_name_second,
  1063. type_id as report_chapter_type_id,
  1064. publish_time,
  1065. title
  1066. FROM
  1067. report_chapter
  1068. WHERE
  1069. report_chapter_id in (` + chapterIds + `)
  1070. )) r`
  1071. err = o.Raw(sql).QueryRow(&total)
  1072. return
  1073. }
  1074. // GetPageReportList 分页获取报告列表
  1075. func GetPageReportList(condition string, pars []interface{}, startSize, pageSize int) (total int, items []*ReportList, err error) {
  1076. o := orm.NewOrmUsingDB("rddp")
  1077. sql := `SELECT * FROM report WHERE 1=1 `
  1078. sql += condition
  1079. sql += ` ORDER BY modify_time DESC`
  1080. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  1081. err = o.Raw(totalSql, pars).QueryRow(&total)
  1082. if err != nil {
  1083. return
  1084. }
  1085. sql += ` LIMIT ?,? `
  1086. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  1087. return
  1088. }
  1089. // SunCodeReq 获取太阳码请求体
  1090. type SunCodeReq struct {
  1091. CodePage string `json:"CodePage" description:"太阳码page"`
  1092. CodeScene string `json:"CodeScene" description:"太阳码scene"`
  1093. }
  1094. // YbPcSuncode 活动海报表
  1095. type YbPcSuncode struct {
  1096. SuncodeID uint32 `orm:"column(suncode_id);pk" `
  1097. Scene string `gorm:"column:scene;type:varchar(255);not null;default:0" json:"scene"` // 微信scene
  1098. SceneMd5 string `gorm:"column:scene_md5;type:varchar(255);not null" json:"sceneMd5"`
  1099. CodePage string `gorm:"column:code_page;type:varchar(255);not null;default:''" json:"codePage"` // 路径
  1100. SuncodeUrl string `gorm:"column:suncode_url;type:varchar(255);not null;default:''" json:"suncodeUrl"` // 太阳码储存地址
  1101. CreateTime time.Time `gorm:"column:create_time;type:timestamp;default:CURRENT_TIMESTAMP" json:"createTime"`
  1102. }
  1103. // GetYbPcSunCode 获取太阳码
  1104. func GetYbPcSunCode(scene, page string) (item *YbPcSuncode, err error) {
  1105. o := orm.NewOrmUsingDB("weekly")
  1106. sql := `SELECT * FROM yb_pc_suncode WHERE scene = ? AND code_page = ? `
  1107. err = o.Raw(sql, scene, page).QueryRow(&item)
  1108. return
  1109. }
  1110. func AddYbPcSunCode(item *YbPcSuncode) (err error) {
  1111. o := orm.NewOrmUsingDB("weekly")
  1112. _, err = o.Insert(item)
  1113. return
  1114. }
  1115. // YbSuncodePars 小程序太阳码scene参数
  1116. type YbSuncodePars struct {
  1117. ID uint32 `orm:"column(id);pk" `
  1118. Scene string `gorm:"column:scene;type:varchar(255);not null;default:''" json:"scene"` // scene参数
  1119. SceneKey string `gorm:"column:scene_key;type:varchar(32);not null;default:''" json:"scene_key"` // MD5值
  1120. CreateTime time.Time `gorm:"column:create_time;type:datetime;default:CURRENT_TIMESTAMP" json:"createTime"`
  1121. }
  1122. func AddYbSuncodePars(item *YbSuncodePars) (err error) {
  1123. o := orm.NewOrmUsingDB("weekly")
  1124. _, err = o.Insert(item)
  1125. return
  1126. }
  1127. // UpdateReportSecondClassifyNameByClassifyId 更新报告分类名称字段
  1128. func UpdateReportSecondClassifyNameByClassifyId(classifyId int, classifyName string) (err error) {
  1129. o := orm.NewOrmUsingDB("rddp")
  1130. sql := " UPDATE report SET classify_name_second = ? WHERE classify_id_second = ? "
  1131. _, err = o.Raw(sql, classifyName, classifyId).Exec()
  1132. return
  1133. }
  1134. // UpdateReportFirstClassifyNameByClassifyId 更新报告分类一级名称字段
  1135. func UpdateReportFirstClassifyNameByClassifyId(classifyId int, classifyName string) (err error) {
  1136. o := orm.NewOrmUsingDB("rddp")
  1137. sql := " UPDATE report SET classify_name_first = ? WHERE classify_id_first = ? "
  1138. _, err = o.Raw(sql, classifyName, classifyId).Exec()
  1139. return
  1140. }
  1141. // UpdateReportThirdClassifyNameByClassifyId 更新报告的三级分类名称字段
  1142. func UpdateReportThirdClassifyNameByClassifyId(classifyId int, classifyName string) (err error) {
  1143. o := orm.NewOrmUsingDB("rddp")
  1144. sql := " UPDATE report SET classify_name_third = ? WHERE classify_id_third = ? "
  1145. _, err = o.Raw(sql, classifyName, classifyId).Exec()
  1146. return
  1147. }
  1148. // UpdateReportSecondClassifyFirstNameByClassifyId 更新报告二级分类的一级分类名称和id
  1149. func UpdateReportSecondClassifyFirstNameByClassifyId(classifyId, newClassifyId int, classifyName string) (err error) {
  1150. o := orm.NewOrmUsingDB("rddp")
  1151. sql := " UPDATE report SET classify_name_first = ?, classify_id_first = ? WHERE classify_id_second = ? "
  1152. _, err = o.Raw(sql, classifyName, newClassifyId, classifyId).Exec()
  1153. return
  1154. }
  1155. // GetEmptyContentSubPPTReport 获取前两章为空的PPT报告
  1156. func GetEmptyContentSubPPTReport() (list []*Report, err error) {
  1157. sql := `SELECT
  1158. r.id,
  1159. r.content,
  1160. r.content_sub
  1161. FROM
  1162. report AS r
  1163. JOIN ppt_v2 AS p ON r.id = p.report_id
  1164. WHERE
  1165. p.report_id > 0 AND r.content_sub = ""`
  1166. _, err = orm.NewOrmUsingDB("rddp").Raw(sql).QueryRows(&list)
  1167. return
  1168. }
  1169. // ModifyReportAuthor 更改报告作者
  1170. func ModifyReportAuthor(condition string, pars []interface{}, authorName string) (count int, err error) {
  1171. //产品权限
  1172. oRddp := orm.NewOrmUsingDB("rddp")
  1173. sql := `UPDATE english_report set author = ? WHERE 1=1 `
  1174. if condition != "" {
  1175. sql += condition
  1176. }
  1177. err = oRddp.Raw(sql, authorName, pars).QueryRow(&count)
  1178. return
  1179. }
  1180. func UpdateReportPublishTime(reportId int, videoNameDate string) (err error) {
  1181. o := orm.NewOrmUsingDB("rddp")
  1182. sql1 := ` UPDATE report SET publish_time = NOW() WHERE id = ? `
  1183. _, err = o.Raw(sql1, reportId).Exec()
  1184. if err != nil {
  1185. return
  1186. }
  1187. //修改音频标题
  1188. sql2 := ` UPDATE report SET video_name=CONCAT(SUBSTRING_INDEX(video_name,"(",1),"` + videoNameDate + `") WHERE id = ? and (video_name !="" and video_name is not null)`
  1189. _, err = o.Raw(sql2, reportId).Exec()
  1190. return
  1191. }
  1192. func UpdateReportChapterPublishTime(reportId int, videoNameDate string) (err error) {
  1193. o := orm.NewOrmUsingDB("rddp")
  1194. sql1 := ` UPDATE report_chapter SET publish_time = NOW() WHERE report_id = ? `
  1195. _, err = o.Raw(sql1, reportId).Exec()
  1196. if err != nil {
  1197. return
  1198. }
  1199. //修改音频标题
  1200. sql2 := ` UPDATE report_chapter SET video_name=CONCAT(SUBSTRING_INDEX(video_name,"(",1),"` + videoNameDate + `") WHERE report_id = ? and (video_name !="" and video_name is not null)`
  1201. _, err = o.Raw(sql2, reportId).Exec()
  1202. return
  1203. }
  1204. // MarkEditReport 标记编辑英文研报的请求数据
  1205. type MarkEditReport struct {
  1206. ReportId int `description:"研报id"`
  1207. ReportChapterId int `description:"研报章节id"`
  1208. Status int `description:"标记状态,1:编辑中,2:查询状态,3:编辑完成"`
  1209. }
  1210. type MarkReportResp struct {
  1211. Status int `description:"状态:0:无人编辑, 1:当前有人在编辑"`
  1212. Msg string `description:"提示信息"`
  1213. Editor string `description:"编辑者姓名"`
  1214. }
  1215. type MarkReportItem struct {
  1216. AdminId int `description:"编辑者ID"`
  1217. Editor string `description:"编辑者姓名"`
  1218. ReportClassifyNameFirst string
  1219. }
  1220. // GetReportByCondition 获取报告
  1221. func GetReportByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string, isPage bool, startSize, pageSize int) (items []*Report, err error) {
  1222. o := orm.NewOrmUsingDB("rddp")
  1223. fields := `*`
  1224. if len(fieldArr) > 0 {
  1225. fields = strings.Join(fieldArr, ",")
  1226. }
  1227. sql := `SELECT ` + fields + ` FROM report WHERE 1=1 `
  1228. sql += condition
  1229. order := ` ORDER BY modify_time DESC`
  1230. if orderRule != `` {
  1231. order = orderRule
  1232. }
  1233. sql += order
  1234. if isPage {
  1235. sql += ` LIMIT ?,?`
  1236. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  1237. } else {
  1238. _, err = o.Raw(sql, pars).QueryRows(&items)
  1239. }
  1240. return
  1241. }
  1242. // ModifyReportMsgIsSendV2 更新报告消息状态
  1243. func ModifyReportMsgIsSendV2(reportId int) (err error) {
  1244. o := orm.NewOrmUsingDB("rddp")
  1245. sql := `UPDATE report SET msg_is_send = 1, ths_msg_is_send = 1, msg_send_time = NOW() WHERE id = ? LIMIT 1`
  1246. _, err = o.Raw(sql, reportId).Exec()
  1247. return
  1248. }
  1249. // SetPrePublishReportById 设置定时发布
  1250. func SetPrePublishReportById(reportId int, prePublishTime string, preMsgSend int) (err error) {
  1251. o := orm.NewOrmUsingDB("rddp")
  1252. sql := `UPDATE report SET pre_publish_time=?, pre_msg_send=? WHERE id = ? and state = 1 `
  1253. _, err = o.Raw(sql, prePublishTime, preMsgSend, reportId).Exec()
  1254. return
  1255. }
  1256. // ReportSubmitApproveReq 提交审批请求体
  1257. type ReportSubmitApproveReq struct {
  1258. ReportId int `description:"报告ID"`
  1259. }
  1260. // ReportCancelApproveReq 撤回审批请求体
  1261. type ReportCancelApproveReq struct {
  1262. ReportId int `description:"报告ID"`
  1263. }
  1264. func (m *Report) GetItemById(id int) (item *Report, err error) {
  1265. o := orm.NewOrmUsingDB("rddp")
  1266. sql := `SELECT * FROM report WHERE id = ? LIMIT 1`
  1267. err = o.Raw(sql, id).QueryRow(&item)
  1268. return
  1269. }
  1270. // GetReportStateCount 获取指定状态的报告数量
  1271. func GetReportStateCount(state int) (count int, err error) {
  1272. o := orm.NewOrmUsingDB("rddp")
  1273. sql := `SELECT COUNT(1) AS count FROM report WHERE state = ?`
  1274. err = o.Raw(sql, state).QueryRow(&count)
  1275. return
  1276. }
  1277. // UpdateReportsStateByCond 批量更新报告状态
  1278. func UpdateReportsStateByCond(classifyFirstId, classifySecondId, classifyThirdId, oldState, newState int) (err error) {
  1279. o := orm.NewOrmUsingDB("rddp")
  1280. cond := ``
  1281. if classifyFirstId > 0 {
  1282. cond += fmt.Sprintf(` AND classify_id_first = %d`, classifyFirstId)
  1283. }
  1284. if classifySecondId > 0 {
  1285. cond += fmt.Sprintf(` AND classify_id_second = %d`, classifySecondId)
  1286. }
  1287. if classifyThirdId > 0 {
  1288. cond += fmt.Sprintf(` AND classify_id_third = %d`, classifyThirdId)
  1289. }
  1290. sql := fmt.Sprintf(`UPDATE report SET state = ?, pre_publish_time = NULL WHERE state = ? %s`, cond)
  1291. _, err = o.Raw(sql, newState, oldState).Exec()
  1292. return
  1293. }
  1294. // UpdateReportsStateBySecondIds 批量更新二级分类报告状态
  1295. func UpdateReportsStateBySecondIds(oldState, newState int, secondIds []int) (err error) {
  1296. if len(secondIds) <= 0 {
  1297. return
  1298. }
  1299. o := orm.NewOrmUsingDB("rddp")
  1300. // (有审批流的)未发布->待提交
  1301. sql := fmt.Sprintf(`UPDATE report SET state = ?, pre_publish_time = NULL WHERE state = ? AND classify_id_second IN (%s)`, utils.GetOrmInReplace(len(secondIds)))
  1302. _, err = o.Raw(sql, newState, oldState, secondIds).Exec()
  1303. if err != nil {
  1304. return
  1305. }
  1306. // (无审批流的)待提交->未发布
  1307. sql = fmt.Sprintf(`UPDATE report SET state = ?, pre_publish_time = NULL WHERE state = ? AND classify_id_second NOT IN (%s)`, utils.GetOrmInReplace(len(secondIds)))
  1308. _, err = o.Raw(sql, oldState, newState, secondIds).Exec()
  1309. return
  1310. }
  1311. // GetReportPdfUrlReq 获取报告pdf地址请求体
  1312. type GetReportPdfUrlReq struct {
  1313. ReportUrl string `description:"报告Url"`
  1314. ReportCode string `description:"报告Code"`
  1315. Type int `description:"类型 1-pdf 2-图片"`
  1316. }
  1317. func ModifyReportPdfUrl(reportId int, detailPdfUrl string) (err error) {
  1318. o := orm.NewOrmUsingDB("rddp")
  1319. sql := `UPDATE report SET detail_pdf_url=? WHERE id=? `
  1320. _, err = o.Raw(sql, detailPdfUrl, reportId).Exec()
  1321. return
  1322. }
  1323. func ModifyReportImgUrl(reportId int, detailImgUrl string) (err error) {
  1324. o := orm.NewOrmUsingDB("rddp")
  1325. sql := `UPDATE report SET detail_img_url=? WHERE id=? `
  1326. _, err = o.Raw(sql, detailImgUrl, reportId).Exec()
  1327. return
  1328. }
  1329. // UpdatePdfUrlReportById 清空pdf相关字段
  1330. func UpdatePdfUrlReportById(reportId int) (err error) {
  1331. o := orm.NewOrmUsingDB("rddp")
  1332. sql := `UPDATE report SET detail_img_url = '',detail_pdf_url='',modify_time=NOW() WHERE id = ? `
  1333. _, err = o.Raw(sql, reportId).Exec()
  1334. return
  1335. }
  1336. // InsertMultiReport
  1337. // @Description: 批量新增报告
  1338. // @author: Roc
  1339. // @datetime 2024-06-27 15:55:25
  1340. // @param items []*Report
  1341. // @return err error
  1342. func InsertMultiReport(items []*Report) (err error) {
  1343. o := orm.NewOrmUsingDB("rddp")
  1344. _, err = o.InsertMulti(500, items)
  1345. return
  1346. }
  1347. // ReportLayout
  1348. // @Description: 报告布局
  1349. type ReportLayout struct {
  1350. Id int
  1351. ReportLayout int8 `description:"报告布局,1:常规布局,2:智能布局。默认:1"`
  1352. }
  1353. // GetReportLayoutByReportId
  1354. // @Description: 根据报告id获取报告的布局
  1355. // @author: Roc
  1356. // @datetime 2024-07-15 15:27:05
  1357. // @param reportId int
  1358. // @return item ReportLayout
  1359. // @return err error
  1360. func GetReportLayoutByReportId(reportId int) (item ReportLayout, err error) {
  1361. o := orm.NewOrmUsingDB("rddp")
  1362. sql := `SELECT id, report_layout FROM report WHERE id = ? `
  1363. err = o.Raw(sql, reportId).QueryRow(&item)
  1364. return
  1365. }
  1366. func GetReportFieldsByIds(ids []int, fields []string) (items []*Report, err error) {
  1367. if len(ids) == 0 {
  1368. return
  1369. }
  1370. o := orm.NewOrmUsingDB("rddp")
  1371. field := " * "
  1372. if len(fields) > 0 {
  1373. field = fmt.Sprintf(" %s ", strings.Join(fields, ","))
  1374. }
  1375. sql := fmt.Sprintf(`SELECT %s FROM report WHERE id IN (%s)`, field, utils.GetOrmInReplace(len(ids)))
  1376. _, err = o.Raw(sql, ids).QueryRows(&items)
  1377. return
  1378. }
  1379. // GetReportListByClassifyId 根据分类id 获取报告列表
  1380. func GetReportListByClassifyId(classifyId int) (items []*Report, err error) {
  1381. o := orm.NewOrmUsingDB("rddp")
  1382. sql := `SELECT * FROM report WHERE classify_id_first = ? or classify_id_second = ? or classify_id_third = ?`
  1383. _, err = o.Raw(sql, classifyId, classifyId, classifyId).QueryRows(&items)
  1384. return items, err
  1385. }
  1386. // UpdateReportInfo 修改报告
  1387. func UpdateReportInfo(reports *Report) (err error) {
  1388. o := orm.NewOrmUsingDB("rddp")
  1389. _, err = o.Update(reports)
  1390. if err != nil {
  1391. return err
  1392. }
  1393. return
  1394. }
  1395. func FindReportListByCondition(condition string, pars []interface{}) (items []*Report, err error) {
  1396. o := orm.NewOrmUsingDB("rddp")
  1397. sql := `SELECT * FROM report WHERE 1=1 `
  1398. if condition != "" {
  1399. sql += condition
  1400. }
  1401. _, err = o.Raw(sql, pars).QueryRows(&items)
  1402. if err != nil {
  1403. return nil, err
  1404. }
  1405. return
  1406. }