report.go 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100
  1. package models
  2. import (
  3. "eta/eta_api/utils"
  4. "github.com/beego/beego/v2/client/orm"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "strings"
  7. "time"
  8. )
  9. // 报告状态
  10. const (
  11. ReportStateUnpublished = 1 // 未发布
  12. ReportStatePublished = 2 // 已发布
  13. ReportStateWaitSubmit = 3 // 待提交
  14. ReportStateWaitApprove = 4 // 审批中
  15. ReportStateRefused = 5 // 已驳回
  16. ReportStatePass = 6 // 已通过
  17. )
  18. // 报告操作
  19. const (
  20. ReportOperateAdd = 1 // 新增报告
  21. ReportOperateEdit = 2 // 编辑报告
  22. ReportOperatePublish = 3 // 发布报告
  23. ReportOperateCancelPublish = 4 // 取消发布报告
  24. ReportOperateSubmitApprove = 5 // 提交审批
  25. ReportOperateCancelApprove = 6 // 撤回审批
  26. )
  27. type Report struct {
  28. Id int `orm:"column(id)" description:"报告Id"`
  29. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  30. ClassifyIdFirst int `description:"一级分类id"`
  31. ClassifyNameFirst string `description:"一级分类名称"`
  32. ClassifyIdSecond int `description:"二级分类id"`
  33. ClassifyNameSecond string `description:"二级分类名称"`
  34. Title string `description:"标题"`
  35. Abstract string `description:"摘要"`
  36. Author string `description:"作者"`
  37. Frequency string `description:"频度"`
  38. CreateTime string `description:"创建时间"`
  39. ModifyTime time.Time `description:"修改时间"`
  40. State int `description:"1:未发布;2:已发布;3-待提交;4-待审批;5-已驳回;6-已通过"`
  41. PublishTime time.Time `description:"发布时间"`
  42. Stage int `description:"期数"`
  43. MsgIsSend int `description:"消息是否已发送,0:否,1:是"`
  44. ThsMsgIsSend int `description:"客户群消息是否已发送,0:否,1:是"`
  45. Content string `description:"内容"`
  46. VideoUrl string `description:"音频文件URL"`
  47. VideoName string `description:"音频文件名称"`
  48. VideoPlaySeconds string `description:"音频播放时长"`
  49. VideoSize string `description:"音频文件大小,单位M"`
  50. ContentSub string `description:"内容前两个章节"`
  51. ReportCode string `description:"报告唯一编码"`
  52. ReportVersion int `description:"1:旧版,2:新版"`
  53. HasChapter int `description:"是否有章节 0-否 1-是"`
  54. ChapterType string `description:"章节类型 day-晨报 week-周报"`
  55. OldReportId int `description:"research_report表ID, 大于0则表示该报告为老后台同步过来的"`
  56. MsgSendTime time.Time `description:"模版消息发送时间"`
  57. AdminId int `description:"创建者账号"`
  58. AdminRealName string `description:"创建者姓名"`
  59. ApproveTime time.Time `description:"审批时间"`
  60. ApproveId int `description:"审批ID"`
  61. }
  62. type ReportList struct {
  63. Id int `description:"报告Id"`
  64. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  65. ClassifyIdFirst int `description:"一级分类id"`
  66. ClassifyNameFirst string `description:"一级分类名称"`
  67. ClassifyIdSecond int `description:"二级分类id"`
  68. ClassifyNameSecond string `description:"二级分类名称"`
  69. Title string `description:"标题"`
  70. Abstract string `description:"摘要"`
  71. Author string `description:"作者"`
  72. Frequency string `description:"频度"`
  73. CreateTime string `description:"创建时间"`
  74. ModifyTime time.Time `description:"修改时间"`
  75. State int `description:"1:未发布;2:已发布;3-待提交;4-待审批;5-已驳回;6-已通过"`
  76. PublishTime string `description:"发布时间"`
  77. PrePublishTime string `description:"预发布时间"`
  78. Stage int `description:"期数"`
  79. MsgIsSend int `description:"模板消息是否已发送,0:否,1:是"`
  80. Content string `description:"内容"`
  81. VideoUrl string `description:"音频文件URL"`
  82. VideoName string `description:"音频文件名称"`
  83. VideoPlaySeconds string `description:"音频播放时长"`
  84. ContentSub string `description:"内容前两个章节"`
  85. Pv int `description:"Pv"`
  86. Uv int `description:"Uv"`
  87. ReportCode string `description:"报告唯一编码"`
  88. ReportVersion int `description:"1:旧版,2:新版"`
  89. ThsMsgIsSend int `description:"客户群消息是否已发送,0:否,1:是"`
  90. NeedThsMsg int `description:"是否需要推送客群消息 0-否 1-是"`
  91. HasChapter int `description:"是否有章节 0-否 1-是"`
  92. ChapterType string `description:"章节类型 day-晨报 week-周报"`
  93. ChapterVideoList []*ReportChapterVideoList `description:"章节音频列表"`
  94. OldReportId int `description:"research_report表ID, 大于0则表示该报告为老后台同步过来的"`
  95. MsgSendTime string `description:"模版消息发送时间"`
  96. CanEdit bool `description:"是否可编辑"`
  97. Editor string `description:"编辑人"`
  98. AdminId int `description:"创建者账号"`
  99. AdminRealName string `description:"创建者姓名"`
  100. ApproveTime string `description:"审批时间"`
  101. }
  102. type ReportListResp struct {
  103. List []*ReportList
  104. Paging *paging.PagingItem `description:"分页数据"`
  105. }
  106. func GetReportListCount(condition string, pars []interface{}, companyType string) (count int, err error) {
  107. //产品权限
  108. companyTypeSqlStr := ``
  109. if companyType == "ficc" {
  110. companyTypeSqlStr = " AND classify_id_first != 40 "
  111. } else if companyType == "权益" {
  112. companyTypeSqlStr = " AND classify_id_first = 40 "
  113. }
  114. oRddp := orm.NewOrmUsingDB("rddp")
  115. sql := `SELECT COUNT(1) AS count FROM report WHERE 1=1 ` + companyTypeSqlStr
  116. if condition != "" {
  117. sql += condition
  118. }
  119. err = oRddp.Raw(sql, pars).QueryRow(&count)
  120. return
  121. }
  122. func GetReportList(condition string, pars []interface{}, companyType string, startSize, pageSize int) (items []*ReportList, err error) {
  123. o := orm.NewOrmUsingDB("rddp")
  124. //产品权限
  125. companyTypeSqlStr := ``
  126. if companyType == "ficc" {
  127. companyTypeSqlStr = " AND classify_id_first != 40 "
  128. } else if companyType == "权益" {
  129. companyTypeSqlStr = " AND classify_id_first = 40 "
  130. }
  131. sql := `SELECT *,
  132. (SELECT COUNT(1) FROM report_view_record AS rvr WHERE rvr.report_id=report.id) AS pv,
  133. (SELECT COUNT(DISTINCT user_id) FROM report_view_record AS rvr WHERE rvr.report_id=report.id) AS uv
  134. FROM report WHERE 1=1 ` + companyTypeSqlStr
  135. if condition != "" {
  136. sql += condition
  137. }
  138. sql += `ORDER BY FIELD(state,3,1,2,4), modify_time DESC LIMIT ?,?`
  139. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  140. return
  141. }
  142. // PublishReport 发布报告
  143. func PublishReport(reportIds []int) (err error) {
  144. if len(reportIds) == 0 {
  145. return
  146. }
  147. o := orm.NewOrmUsingDB("rddp")
  148. sql := `UPDATE report SET state=2,publish_time=now(),modify_time=NOW() WHERE id IN (` + utils.GetOrmInReplace(len(reportIds)) + `)`
  149. _, err = o.Raw(sql).Exec()
  150. return
  151. }
  152. // PublishCancelReport 取消发布报告
  153. func PublishCancelReport(reportId, state int, publishTimeNullFlag bool) (err error) {
  154. o := orm.NewOrmUsingDB("rddp")
  155. var sql string
  156. if publishTimeNullFlag {
  157. sql = ` UPDATE report SET state=?, publish_time=null, pre_publish_time=null, pre_msg_send=0 WHERE id =?`
  158. } else {
  159. sql = ` UPDATE report SET state=?, pre_publish_time=null, pre_msg_send=0 WHERE id =?`
  160. }
  161. _, err = o.Raw(sql, state, reportId).Exec()
  162. return
  163. }
  164. // 删除报告
  165. func DeleteReport(reportIds int) (err error) {
  166. o := orm.NewOrmUsingDB("rddp")
  167. sql := ` DELETE FROM report WHERE id =? `
  168. _, err = o.Raw(sql, reportIds).Exec()
  169. return
  170. }
  171. type ReportDetail struct {
  172. Id int `orm:"column(id)" description:"报告Id"`
  173. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  174. ClassifyIdFirst int `description:"一级分类id"`
  175. ClassifyNameFirst string `description:"一级分类名称"`
  176. ClassifyIdSecond int `description:"二级分类id"`
  177. ClassifyNameSecond string `description:"二级分类名称"`
  178. Title string `description:"标题"`
  179. Abstract string `description:"摘要"`
  180. Author string `description:"作者"`
  181. Frequency string `description:"频度"`
  182. CreateTime string `description:"创建时间"`
  183. ModifyTime string `description:"修改时间"`
  184. State int `description:"1:未发布,2:已发布"`
  185. PublishTime string `description:"发布时间"`
  186. PrePublishTime string `description:"预发布时间"`
  187. Stage int `description:"期数"`
  188. MsgIsSend int `description:"消息是否已发送,0:否,1:是"`
  189. PreMsgSend int `description:"定时发布成功后是否立即推送模版消息:0否,1是"`
  190. Content string `description:"内容"`
  191. VideoUrl string `description:"音频文件URL"`
  192. VideoName string `description:"音频文件名称"`
  193. VideoPlaySeconds string `description:"音频播放时长"`
  194. ContentSub string `description:"内容前两个章节"`
  195. ThsMsgIsSend int `description:"客户群消息是否已发送,0:否,1:是"`
  196. HasChapter int `description:"是否有章节 0-否 1-是"`
  197. ChapterType string `description:"章节类型 day-晨报 week-周报"`
  198. }
  199. func GetReportById(reportId int) (item *ReportDetail, err error) {
  200. o := orm.NewOrmUsingDB("rddp")
  201. sql := `SELECT * FROM report WHERE id=?`
  202. err = o.Raw(sql, reportId).QueryRow(&item)
  203. return
  204. }
  205. func GetReportByIds(reportIds string) (list []*ReportDetail, err error) {
  206. o := orm.NewOrmUsingDB("rddp")
  207. sql := `SELECT * FROM report WHERE id in ` + reportIds
  208. _, err = o.Raw(sql).QueryRows(&list)
  209. return
  210. }
  211. // GetSimpleReportByIds 根据报告ID查询报告基本信息
  212. func GetSimpleReportByIds(reportIds []int) (list []*ReportDetail, err error) {
  213. if len(reportIds) == 0 {
  214. return
  215. }
  216. o := orm.NewOrmUsingDB("rddp")
  217. sql := `SELECT id, title FROM report WHERE id IN (` + utils.GetOrmInReplace(len(reportIds)) + `)`
  218. _, err = o.Raw(sql, reportIds).QueryRows(&list)
  219. return
  220. }
  221. func GetReportStage(classifyIdFirst, classifyIdSecond int) (count int, err error) {
  222. o := orm.NewOrmUsingDB("rddp")
  223. sql := ``
  224. if classifyIdSecond > 0 {
  225. sql = "SELECT MAX(stage) AS max_stage FROM report WHERE classify_id_second=? "
  226. o.Raw(sql, classifyIdSecond).QueryRow(&count)
  227. } else {
  228. sql = "SELECT MAX(stage) AS max_stage FROM report WHERE classify_id_first=? "
  229. o.Raw(sql, classifyIdFirst).QueryRow(&count)
  230. }
  231. return
  232. }
  233. func GetReportStageEdit(classifyIdFirst, classifyIdSecond, reportId int) (count int, err error) {
  234. o := orm.NewOrmUsingDB("rddp")
  235. sql := ``
  236. if classifyIdSecond > 0 {
  237. sql = "SELECT MAX(stage) AS max_stage FROM report WHERE classify_id_second=? AND id<>? "
  238. o.Raw(sql, classifyIdSecond, reportId).QueryRow(&count)
  239. } else {
  240. sql = "SELECT MAX(stage) AS max_stage FROM report WHERE classify_id_first=? AND id<>? "
  241. o.Raw(sql, classifyIdFirst, reportId).QueryRow(&count)
  242. }
  243. return
  244. }
  245. type PublishReq struct {
  246. ReportIds string `description:"报告id,多个用英文逗号隔开"`
  247. }
  248. type PublishCancelReq struct {
  249. ReportIds int `description:"报告id"`
  250. }
  251. type DeleteReq struct {
  252. ReportIds int `description:"报告id"`
  253. }
  254. type AddReq struct {
  255. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  256. ClassifyIdFirst int `description:"一级分类id"`
  257. ClassifyNameFirst string `description:"一级分类名称"`
  258. ClassifyIdSecond int `description:"二级分类id"`
  259. ClassifyNameSecond string `description:"二级分类名称"`
  260. Title string `description:"标题"`
  261. Abstract string `description:"摘要"`
  262. Author string `description:"作者"`
  263. Frequency string `description:"频度"`
  264. State int `description:"状态:1:未发布,2:已发布"`
  265. Content string `description:"内容"`
  266. CreateTime string `description:"创建时间"`
  267. ReportVersion int `description:"1:旧版,2:新版"`
  268. }
  269. type PrePublishReq struct {
  270. ReportId int `description:"报告id"`
  271. PrePublishTime string `description:"预发布时间"`
  272. PreMsgSend int `description:"定时发布成功后是否立即推送模版消息:0否,1是"`
  273. }
  274. type AddResp struct {
  275. ReportId int64 `description:"报告id"`
  276. ReportCode string `description:"报告code"`
  277. }
  278. func AddReport(item *Report) (lastId int64, err error) {
  279. o := orm.NewOrmUsingDB("rddp")
  280. lastId, err = o.Insert(item)
  281. return
  282. }
  283. type EditReq struct {
  284. ReportId int64 `description:"报告id"`
  285. ClassifyIdFirst int `description:"一级分类id"`
  286. ClassifyNameFirst string `description:"一级分类名称"`
  287. ClassifyIdSecond int `description:"二级分类id"`
  288. ClassifyNameSecond string `description:"二级分类名称"`
  289. Title string `description:"标题"`
  290. Abstract string `description:"摘要"`
  291. Author string `description:"作者"`
  292. Frequency string `description:"频度"`
  293. State int `description:"状态:1:未发布,2:已发布"`
  294. Content string `description:"内容"`
  295. CreateTime string `description:"创建时间"`
  296. }
  297. type EditResp struct {
  298. ReportId int64 `description:"报告id"`
  299. ReportCode string `description:"报告code"`
  300. }
  301. func EditReport(item *Report, reportId int64) (err error) {
  302. o := orm.NewOrmUsingDB("rddp")
  303. sql := `UPDATE report
  304. SET
  305. classify_id_first =?,
  306. classify_name_first = ?,
  307. classify_id_second = ?,
  308. classify_name_second = ?,
  309. title = ?,
  310. abstract = ?,
  311. author = ?,
  312. frequency = ?,
  313. state = ?,
  314. content = ?,
  315. content_sub = ?,
  316. stage =?,
  317. create_time = ?,
  318. modify_time = ?
  319. WHERE id = ? `
  320. _, err = o.Raw(sql, item.ClassifyIdFirst, item.ClassifyNameFirst, item.ClassifyIdSecond, item.ClassifyNameSecond, item.Title,
  321. item.Abstract, item.Author, item.Frequency, item.State, item.Content, item.ContentSub, item.Stage, item.CreateTime, time.Now(), reportId).Exec()
  322. return
  323. }
  324. type ReportDetailReq struct {
  325. ReportId int `description:"报告id"`
  326. }
  327. type ClassifyIdDetailReq struct {
  328. ClassifyIdFirst int `description:"报告一级分类id"`
  329. ClassifyIdSecond int `description:"报告二级分类id"`
  330. }
  331. func GetReportDetailByClassifyId(classifyIdFirst, classifyIdSecond int) (item *Report, err error) {
  332. o := orm.NewOrmUsingDB("rddp")
  333. sql := ` SELECT * FROM report WHERE 1=1 `
  334. if classifyIdSecond > 0 {
  335. sql = sql + ` AND classify_id_second=? ORDER BY stage DESC LIMIT 1`
  336. err = o.Raw(sql, classifyIdSecond).QueryRow(&item)
  337. } else {
  338. sql = sql + ` AND classify_id_first=? ORDER BY stage DESC LIMIT 1`
  339. err = o.Raw(sql, classifyIdFirst).QueryRow(&item)
  340. }
  341. return
  342. }
  343. type SendTemplateMsgReq struct {
  344. ReportId int `description:"报告id"`
  345. }
  346. func ModifyReportMsgIsSend(reportId int) (err error) {
  347. o := orm.NewOrmUsingDB("rddp")
  348. report, err := GetReportById(reportId)
  349. if err != nil {
  350. return
  351. }
  352. if report.MsgIsSend == 0 {
  353. sql := `UPDATE report SET msg_is_send = 1, msg_send_time=NOW() WHERE id = ? `
  354. _, err = o.Raw(sql, reportId).Exec()
  355. }
  356. return
  357. }
  358. func ModifyReportVideo(reportId int, videoUrl, videoName, videoSize string, playSeconds float64) (err error) {
  359. o := orm.NewOrmUsingDB("rddp")
  360. sql := `UPDATE report SET video_url=?,video_name=?,video_play_seconds=?,video_size=? WHERE id=? `
  361. _, err = o.Raw(sql, videoUrl, videoName, playSeconds, videoSize, reportId).Exec()
  362. return
  363. }
  364. type ReportItem struct {
  365. Id int `orm:"column(id)" description:"报告Id"`
  366. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  367. ClassifyIdFirst int `description:"一级分类id"`
  368. ClassifyNameFirst string `description:"一级分类名称"`
  369. ClassifyIdSecond int `description:"二级分类id"`
  370. ClassifyNameSecond string `description:"二级分类名称"`
  371. Title string `description:"标题"`
  372. Abstract string `description:"摘要"`
  373. Author string `description:"作者"`
  374. Frequency string `description:"频度"`
  375. CreateTime time.Time `description:"创建时间"`
  376. ModifyTime time.Time `description:"修改时间"`
  377. State int `description:"1:未发布,2:已发布"`
  378. PublishTime time.Time `description:"发布时间"`
  379. Stage int `description:"期数"`
  380. MsgIsSend int `description:"消息是否已发送,0:否,1:是"`
  381. Content string `description:"内容"`
  382. VideoUrl string `description:"音频文件URL"`
  383. VideoName string `description:"音频文件名称"`
  384. VideoPlaySeconds string `description:"音频播放时长"`
  385. ContentSub string `description:"内容前两个章节"`
  386. }
  387. func GetReportItemById(reportId int) (item *ReportItem, err error) {
  388. o := orm.NewOrmUsingDB("rddp")
  389. sql := `SELECT * FROM report WHERE id=?`
  390. err = o.Raw(sql, reportId).QueryRow(&item)
  391. return
  392. }
  393. type SaveReportContent struct {
  394. Content string `description:"内容"`
  395. ReportId int `description:"报告id"`
  396. NoChange int `description:"内容是否未改变:1:内容未改变"`
  397. }
  398. func EditReportContent(reportId int, content, contentSub string) (err error) {
  399. o := orm.NewOrmUsingDB("rddp")
  400. sql := ` UPDATE report SET content=?,content_sub=?,modify_time=NOW() WHERE id=? `
  401. _, err = o.Raw(sql, content, contentSub, reportId).Exec()
  402. return
  403. }
  404. func AddReportSaveLog(reportId, adminId int, content, contentSub, adminName string) (err error) {
  405. o := orm.NewOrmUsingDB("rddp")
  406. sql := ` INSERT INTO report_save_log(report_id, content,content_sub,admin_id,admin_name) VALUES (?,?,?,?,?) `
  407. _, err = o.Raw(sql, reportId, content, contentSub, adminId, adminName).Exec()
  408. return
  409. }
  410. func MultiAddReportChaptersSaveLog(items []*ReportChapter, adminId int, adminRealName string) (err error) {
  411. o := orm.NewOrmUsingDB("rddp")
  412. p, err := o.Raw(`INSERT INTO report_save_log(report_id, report_chapter_id, content, content_sub, admin_id, admin_name) VALUES (?,?,?,?,?,?)`).Prepare()
  413. if err != nil {
  414. return
  415. }
  416. defer func() {
  417. _ = p.Close()
  418. }()
  419. for _, v := range items {
  420. _, err = p.Exec(v.ReportId, v.ReportChapterId, v.Content, v.ContentSub, adminId, adminRealName)
  421. if err != nil {
  422. return
  423. }
  424. }
  425. return
  426. }
  427. type SaveReportContentResp struct {
  428. ReportId int `description:"报告id"`
  429. }
  430. func ModifyReportCode(reportId int64, reportCode string) (err error) {
  431. o := orm.NewOrmUsingDB("rddp")
  432. sql := `UPDATE report SET report_code=? WHERE id=? `
  433. _, err = o.Raw(sql, reportCode, reportId).Exec()
  434. return
  435. }
  436. func ModifyReportThsMsgIsSend(item *ReportDetail) (err error) {
  437. o := orm.NewOrmUsingDB("rddp")
  438. if item.ThsMsgIsSend == 0 {
  439. sql := `UPDATE report SET ths_msg_is_send = 1 WHERE id = ? `
  440. _, err = o.Raw(sql, item.Id).Exec()
  441. }
  442. return
  443. }
  444. type ThsSendTemplateMsgReq struct {
  445. ReportId []int `description:"报告id"`
  446. }
  447. type PublishDayWeekReportReq struct {
  448. ReportId int `description:"报告ID"`
  449. }
  450. // SaveDayWeekReportReq 新增晨报周报请求体
  451. type SaveDayWeekReportReq struct {
  452. ReportId int `description:"报告ID"`
  453. Title string `description:"标题"`
  454. ReportType string `description:"一级分类ID"`
  455. Author string `description:"作者"`
  456. CreateTime string `description:"创建时间"`
  457. }
  458. // GetDayWeekReportStage 获取晨报周报期数
  459. func GetDayWeekReportStage(classifyIdFirst int, yearStart time.Time) (count int, err error) {
  460. o := orm.NewOrmUsingDB("rddp")
  461. sql := " SELECT MAX(stage) AS max_stage FROM report WHERE classify_id_first = ? AND create_time > ? "
  462. o.Raw(sql, classifyIdFirst, yearStart).QueryRow(&count)
  463. return
  464. }
  465. // AddReportAndChapter 新增报告及章节
  466. func AddReportAndChapter(reportItem *Report, chapterItemList []*ReportChapter) (reportId int64, err error) {
  467. o := orm.NewOrmUsingDB("rddp")
  468. to, err := o.Begin()
  469. if err != nil {
  470. return
  471. }
  472. defer func() {
  473. if err != nil {
  474. _ = to.Rollback()
  475. } else {
  476. _ = to.Commit()
  477. }
  478. }()
  479. if reportId, err = to.Insert(reportItem); err != nil {
  480. return
  481. }
  482. if len(chapterItemList) > 0 {
  483. for _, chapterItem := range chapterItemList {
  484. chapterItem.ReportId = int(reportId)
  485. cpId, tmpErr := to.Insert(chapterItem)
  486. if tmpErr != nil {
  487. return
  488. }
  489. chapterItem.ReportChapterId = int(cpId)
  490. }
  491. }
  492. return
  493. }
  494. // GetReportByReportId 主键获取报告
  495. func GetReportByReportId(reportId int) (item *Report, err error) {
  496. o := orm.NewOrmUsingDB("rddp")
  497. sql := `SELECT * FROM report WHERE id = ?`
  498. err = o.Raw(sql, reportId).QueryRow(&item)
  499. return
  500. }
  501. // GetReportByOldReportId 根据老报告id主键获取报告
  502. func GetReportByOldReportId(reportId int) (item *Report, err error) {
  503. o := orm.NewOrmUsingDB("rddp")
  504. sql := `SELECT * FROM report WHERE old_report_id = ?`
  505. err = o.Raw(sql, reportId).QueryRow(&item)
  506. return
  507. }
  508. // DeleteDayWeekReportAndChapter 删除晨周报及章节
  509. func DeleteDayWeekReportAndChapter(reportId int) (err error) {
  510. o := orm.NewOrmUsingDB("rddp")
  511. to, err := o.Begin()
  512. if err != nil {
  513. return
  514. }
  515. defer func() {
  516. if err != nil {
  517. _ = to.Rollback()
  518. } else {
  519. _ = to.Commit()
  520. }
  521. }()
  522. sql := ` DELETE FROM report WHERE id = ? LIMIT 1 `
  523. if _, err = to.Raw(sql, reportId).Exec(); err != nil {
  524. return
  525. }
  526. sql = ` DELETE FROM report_chapter WHERE report_id = ? `
  527. if _, err = to.Raw(sql, reportId).Exec(); err != nil {
  528. return
  529. }
  530. return
  531. }
  532. // UpdateReport 更新报告
  533. func (reportInfo *Report) UpdateReport(cols []string) (err error) {
  534. o := orm.NewOrmUsingDB("rddp")
  535. _, err = o.Update(reportInfo, cols...)
  536. return
  537. }
  538. // 晨周报详情
  539. type ReportDetailView struct {
  540. *ReportDetail
  541. ChapterList []*ReportChapter
  542. }
  543. func GetUnPublishDayReport(startTime time.Time, endTime time.Time) (item *Report, err error) {
  544. o := orm.NewOrmUsingDB("rddp")
  545. sql := ` SELECT
  546. *
  547. FROM
  548. report AS a
  549. WHERE
  550. a.has_chapter = 1
  551. AND a.chapter_type = "day"
  552. AND a.state = 1
  553. AND (
  554. a.create_time BETWEEN ? AND ?
  555. )
  556. ORDER BY
  557. a.create_time DESC
  558. LIMIT 1 `
  559. err = o.Raw(sql, startTime, endTime).QueryRow(&item)
  560. return
  561. }
  562. type ElasticReportDetail struct {
  563. ReportId int `description:"报告ID"`
  564. ReportChapterId int `description:"报告章节ID"`
  565. Title string `description:"标题"`
  566. Abstract string `description:"摘要"`
  567. BodyContent string `description:"内容"`
  568. PublishTime string `description:"发布时间"`
  569. PublishState int `description:"发布状态 1-未发布 2-已发布"`
  570. Author string `description:"作者"`
  571. ClassifyIdFirst int `description:"一级分类ID"`
  572. ClassifyNameFirst string `description:"一级分类名称"`
  573. ClassifyIdSecond int `description:"二级分类ID"`
  574. ClassifyNameSecond string `description:"二级分类名称"`
  575. Categories string `description:"关联的品种名称(包括品种别名)"`
  576. StageStr string `description:"报告期数"`
  577. }
  578. // GetLastPublishedDayWeekReport 获取上一篇已发布的晨周报
  579. func GetLastPublishDayWeekReport(chapterType string) (item *Report, err error) {
  580. o := orm.NewOrmUsingDB("rddp")
  581. sql := ` SELECT * FROM report WHERE has_chapter = 1 AND chapter_type = ? AND state = 2 ORDER BY publish_time DESC LIMIT 1 `
  582. err = o.Raw(sql, chapterType).QueryRow(&item)
  583. return
  584. }
  585. // GetNewReportExist
  586. func GetNewReportExist(oldReportId int) (item *Report, err error) {
  587. o := orm.NewOrmUsingDB("rddp")
  588. sql := ` SELECT id FROM report WHERE old_report_id = ? LIMIT 1 `
  589. err = o.Raw(sql, oldReportId).QueryRow(&item)
  590. return
  591. }
  592. // PublishReportAndChapter 发布报告及章节
  593. func PublishReportAndChapter(reportInfo *Report, publishIds, unPublishIds []int, isPublishReport bool, cols []string) (err error) {
  594. o := orm.NewOrmUsingDB("rddp")
  595. to, err := o.Begin()
  596. if err != nil {
  597. return
  598. }
  599. defer func() {
  600. if err != nil {
  601. _ = to.Rollback()
  602. } else {
  603. _ = to.Commit()
  604. }
  605. }()
  606. // 更新报告
  607. if isPublishReport {
  608. if _, err = to.Update(reportInfo, cols...); err != nil {
  609. return
  610. }
  611. }
  612. // 发布章节
  613. if len(publishIds) > 0 {
  614. sql := ` UPDATE report_chapter SET publish_state = 2, publish_time = ? WHERE report_id = ? AND report_chapter_id IN (` + utils.GetOrmInReplace(len(publishIds)) + `) `
  615. _, err = to.Raw(sql, reportInfo.PublishTime, reportInfo.Id, publishIds).Exec()
  616. }
  617. if len(unPublishIds) > 0 {
  618. 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)) + `) `
  619. _, err = to.Raw(sql, reportInfo.Id, unPublishIds).Exec()
  620. }
  621. return
  622. }
  623. func GetSyncEmptyVideoReport() (list []*Report, err error) {
  624. o := orm.NewOrmUsingDB("rddp")
  625. sql := ` SELECT id FROM report WHERE old_report_id > 0 AND state = 2 AND chapter_type = "" AND (video_size = "" OR video_play_seconds = "")
  626. UNION ALL
  627. SELECT DISTINCT report_id FROM report_chapter WHERE publish_state = 2 AND (video_size = "" OR video_play_seconds = "") `
  628. _, err = o.Raw(sql).QueryRows(&list)
  629. return
  630. }
  631. // PublishReportById 发布报告
  632. func PublishReportById(reportId int, publishTime time.Time) (err error) {
  633. o := orm.NewOrmUsingDB("rddp")
  634. sql := `UPDATE report SET state = 2, publish_time = ?, pre_publish_time=null, pre_msg_send=0, modify_time = NOW() WHERE id = ? `
  635. _, err = o.Raw(sql, publishTime, reportId).Exec()
  636. return
  637. }
  638. // ResetReportById 重置报告状态
  639. func ResetReportById(reportId, state int) (err error) {
  640. o := orm.NewOrmUsingDB("rddp")
  641. sql := `UPDATE report SET state = ?, pre_publish_time = null, pre_msg_send = 0, modify_time = NOW() WHERE id = ?`
  642. _, err = o.Raw(sql, state, reportId).Exec()
  643. return
  644. }
  645. // GetCommentReportByReportId 查询有留言的报告列表
  646. func GetCommentReportByReportId(condition string, pars []interface{}, startSize, pageSize int) (list []*Report, err error) {
  647. o := orm.NewOrmUsingDB("rddp")
  648. sql := `SELECT
  649. id,
  650. create_time,
  651. title,
  652. classify_name_first,
  653. classify_id_first,
  654. classify_name_second,
  655. classify_id_second,
  656. state,
  657. IF
  658. ( publish_time, publish_time, create_time ) AS publish_time
  659. FROM
  660. report
  661. WHERE
  662. 1=1
  663. `
  664. if condition != "" {
  665. sql += condition
  666. }
  667. sql += ` ORDER BY publish_time DESC , title ASC LIMIT ?,?`
  668. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
  669. return
  670. }
  671. // GetCommentReportByReportIdOrderBy 查询有留言的报告列表(指定排序)
  672. func GetCommentReportByReportIdOrderBy(condition string, pars []interface{}, startSize, pageSize int, orderBy string) (list []*Report, err error) {
  673. o := orm.NewOrmUsingDB("rddp")
  674. sql := `SELECT
  675. id,
  676. create_time,
  677. title,
  678. classify_name_first,
  679. classify_id_first,
  680. classify_name_second,
  681. classify_id_second,
  682. state,
  683. IF
  684. ( publish_time, publish_time, create_time ) AS publish_time
  685. FROM
  686. report
  687. WHERE
  688. 1=1
  689. `
  690. if condition != "" {
  691. sql += condition
  692. }
  693. if orderBy == `` {
  694. sql += ` ORDER BY publish_time DESC , title ASC `
  695. } else {
  696. sql += orderBy
  697. }
  698. sql += ` LIMIT ?,? `
  699. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
  700. return
  701. }
  702. // GetCommentReportTotalByReportId 查询有留言的报告列表总数
  703. func GetCommentReportTotalByReportId(condition string, pars []interface{}) (total int64, err error) {
  704. o := orm.NewOrmUsingDB("rddp")
  705. sql := `SELECT count(*)
  706. FROM report WHERE 1=1`
  707. if condition != "" {
  708. sql += condition
  709. }
  710. err = o.Raw(sql, pars).QueryRow(&total)
  711. return
  712. }
  713. // 点赞相关的报告列表
  714. type LikeReportItem struct {
  715. ReportId int `description:"报告Id"`
  716. ReportChapterId int `description:"报告章节Id"`
  717. ClassifyIdFirst int `description:"一级分类id"`
  718. ClassifyNameFirst string `description:"一级分类名称"`
  719. ClassifyIdSecond int `description:"二级分类id"`
  720. ClassifyNameSecond string `description:"二级分类名称"`
  721. ReportChapterTypeId int `description:"章节类型"`
  722. ReportChapterTypeName string `description:"品种名称"`
  723. PublishTime time.Time `description:"发布时间" `
  724. Title string `description:"标题"`
  725. }
  726. // GetLikeReportByReportIdReportChapterId 获取有被点赞的报告列表
  727. func GetLikeReportByReportIdReportChapterId(reportIds string, chapterIds string, orderStr string, startSize, pageSize int) (list []*LikeReportItem, err error) {
  728. o := orm.NewOrmUsingDB("rddp")
  729. sql := `( SELECT
  730. id AS report_id,
  731. 0 AS report_chapter_id,
  732. classify_id_first,
  733. classify_id_second,
  734. classify_name_first,
  735. classify_name_second,
  736. 0 as report_chapter_type_id,
  737. "" as report_chapter_type_name,
  738. publish_time,
  739. title
  740. FROM
  741. report
  742. WHERE
  743. classify_name_first != "晨报"
  744. AND classify_name_first != "周报"
  745. AND id in (` + reportIds + `)
  746. )
  747. UNION
  748. ( SELECT
  749. report_id,
  750. report_chapter_id,
  751. classify_id_first,
  752. 0 as classify_id_second,
  753. classify_name_first,
  754. null as classify_name_second,
  755. type_id as report_chapter_type_id,
  756. type_name as report_chapter_type_name,
  757. publish_time,
  758. title
  759. FROM
  760. report_chapter
  761. WHERE
  762. report_chapter_id in (` + chapterIds + `)
  763. )`
  764. if orderStr != "" {
  765. sql += ` ORDER BY FIELD(CONCAT(report_id, "-",report_chapter_id),` + orderStr + `)`
  766. } else {
  767. sql += ` ORDER BY publish_time DESC, report_id Desc`
  768. }
  769. sql += ` LIMIT ?,?`
  770. _, err = o.Raw(sql, startSize, pageSize).QueryRows(&list)
  771. return
  772. }
  773. // GetLikeReportTotalByReportIdReportChapterId 获取有被点赞的报告列表总数
  774. func GetLikeReportTotalByReportIdReportChapterId(reportIds string, chapterIds string) (total int64, err error) {
  775. o := orm.NewOrmUsingDB("rddp")
  776. sql := `select count(*) from (( SELECT
  777. id AS report_id,
  778. 0 AS report_chapter_id,
  779. classify_id_first,
  780. classify_id_second,
  781. classify_name_first,
  782. classify_name_second,
  783. 0 as report_chapter_type_id,
  784. publish_time,
  785. title
  786. FROM
  787. report
  788. WHERE
  789. classify_name_first != "晨报"
  790. AND classify_name_first != "周报"
  791. AND id in (` + reportIds + `)
  792. )
  793. UNION
  794. ( SELECT
  795. report_id,
  796. report_chapter_id,
  797. classify_id_first,
  798. 0 as classify_id_second,
  799. classify_name_first,
  800. null as classify_name_second,
  801. type_id as report_chapter_type_id,
  802. publish_time,
  803. title
  804. FROM
  805. report_chapter
  806. WHERE
  807. report_chapter_id in (` + chapterIds + `)
  808. )) r`
  809. err = o.Raw(sql).QueryRow(&total)
  810. return
  811. }
  812. // GetPageReportList 分页获取报告列表
  813. func GetPageReportList(condition string, pars []interface{}, startSize, pageSize int) (total int, items []*ReportList, err error) {
  814. o := orm.NewOrmUsingDB("rddp")
  815. sql := `SELECT * FROM report WHERE 1=1 `
  816. sql += condition
  817. sql += ` ORDER BY modify_time DESC`
  818. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  819. err = o.Raw(totalSql, pars).QueryRow(&total)
  820. if err != nil {
  821. return
  822. }
  823. sql += ` LIMIT ?,? `
  824. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  825. return
  826. }
  827. // SunCodeReq 获取太阳码请求体
  828. type SunCodeReq struct {
  829. CodePage string `json:"CodePage" description:"太阳码page"`
  830. CodeScene string `json:"CodeScene" description:"太阳码scene"`
  831. }
  832. // YbPcSuncode 活动海报表
  833. type YbPcSuncode struct {
  834. SuncodeID uint32 `orm:"column(suncode_id);pk" `
  835. Scene string `gorm:"column:scene;type:varchar(255);not null;default:0" json:"scene"` // 微信scene
  836. SceneMd5 string `gorm:"column:scene_md5;type:varchar(255);not null" json:"sceneMd5"`
  837. CodePage string `gorm:"column:code_page;type:varchar(255);not null;default:''" json:"codePage"` // 路径
  838. SuncodeUrl string `gorm:"column:suncode_url;type:varchar(255);not null;default:''" json:"suncodeUrl"` // 太阳码储存地址
  839. CreateTime time.Time `gorm:"column:create_time;type:timestamp;default:CURRENT_TIMESTAMP" json:"createTime"`
  840. }
  841. // GetYbPcSunCode 获取太阳码
  842. func GetYbPcSunCode(scene, page string) (item *YbPcSuncode, err error) {
  843. o := orm.NewOrmUsingDB("weekly")
  844. sql := `SELECT * FROM yb_pc_suncode WHERE scene = ? AND code_page = ? `
  845. err = o.Raw(sql, scene, page).QueryRow(&item)
  846. return
  847. }
  848. func AddYbPcSunCode(item *YbPcSuncode) (err error) {
  849. o := orm.NewOrmUsingDB("weekly")
  850. _, err = o.Insert(item)
  851. return
  852. }
  853. // YbSuncodePars 小程序太阳码scene参数
  854. type YbSuncodePars struct {
  855. ID uint32 `orm:"column(id);pk" `
  856. Scene string `gorm:"column:scene;type:varchar(255);not null;default:''" json:"scene"` // scene参数
  857. SceneKey string `gorm:"column:scene_key;type:varchar(32);not null;default:''" json:"scene_key"` // MD5值
  858. CreateTime time.Time `gorm:"column:create_time;type:datetime;default:CURRENT_TIMESTAMP" json:"createTime"`
  859. }
  860. func AddYbSuncodePars(item *YbSuncodePars) (err error) {
  861. o := orm.NewOrmUsingDB("weekly")
  862. _, err = o.Insert(item)
  863. return
  864. }
  865. // UpdateReportSecondClassifyNameByClassifyId 更新报告分类名称字段
  866. func UpdateReportSecondClassifyNameByClassifyId(classifyId int, classifyName string) (err error) {
  867. o := orm.NewOrmUsingDB("rddp")
  868. sql := " UPDATE report SET classify_name_second = ? WHERE classify_id_second = ? "
  869. _, err = o.Raw(sql, classifyName, classifyId).Exec()
  870. return
  871. }
  872. // UpdateReportFirstClassifyNameByClassifyId 更新报告分类一级名称字段
  873. func UpdateReportFirstClassifyNameByClassifyId(classifyId int, classifyName string) (err error) {
  874. o := orm.NewOrmUsingDB("rddp")
  875. sql := " UPDATE report SET classify_name_first = ? WHERE classify_id_first = ? "
  876. _, err = o.Raw(sql, classifyName, classifyId).Exec()
  877. return
  878. }
  879. // UpdateReportSecondClassifyFirstNameByClassifyId 更新报告二级分类的一级分类名称和id
  880. func UpdateReportSecondClassifyFirstNameByClassifyId(classifyId, newClassifyId int, classifyName string) (err error) {
  881. o := orm.NewOrmUsingDB("rddp")
  882. sql := " UPDATE report SET classify_name_first = ?, classify_id_first = ? WHERE classify_id_second = ? "
  883. _, err = o.Raw(sql, classifyName, newClassifyId, classifyId).Exec()
  884. return
  885. }
  886. // GetEmptyContentSubPPTReport 获取前两章为空的PPT报告
  887. func GetEmptyContentSubPPTReport() (list []*Report, err error) {
  888. sql := `SELECT
  889. r.id,
  890. r.content,
  891. r.content_sub
  892. FROM
  893. report AS r
  894. JOIN ppt_v2 AS p ON r.id = p.report_id
  895. WHERE
  896. p.report_id > 0 AND r.content_sub = ""`
  897. _, err = orm.NewOrmUsingDB("rddp").Raw(sql).QueryRows(&list)
  898. return
  899. }
  900. // ModifyReportAuthor 更改报告作者
  901. func ModifyReportAuthor(condition string, pars []interface{}, authorName string) (count int, err error) {
  902. //产品权限
  903. oRddp := orm.NewOrmUsingDB("rddp")
  904. sql := `UPDATE english_report set author = ? WHERE 1=1 `
  905. if condition != "" {
  906. sql += condition
  907. }
  908. err = oRddp.Raw(sql, authorName, pars).QueryRow(&count)
  909. return
  910. }
  911. func UpdateReportPublishTime(reportId int, videoNameDate string) (err error) {
  912. o := orm.NewOrmUsingDB("rddp")
  913. sql1 := ` UPDATE report SET publish_time = NOW() WHERE id = ? `
  914. _, err = o.Raw(sql1, reportId).Exec()
  915. if err != nil {
  916. return
  917. }
  918. //修改音频标题
  919. sql2 := ` UPDATE report SET video_name=CONCAT(SUBSTRING_INDEX(video_name,"(",1),"` + videoNameDate + `") WHERE id = ? and (video_name !="" and video_name is not null)`
  920. _, err = o.Raw(sql2, reportId).Exec()
  921. return
  922. }
  923. func UpdateReportChapterPublishTime(reportId int, videoNameDate string) (err error) {
  924. o := orm.NewOrmUsingDB("rddp")
  925. sql1 := ` UPDATE report_chapter SET publish_time = NOW() WHERE report_id = ? `
  926. _, err = o.Raw(sql1, reportId).Exec()
  927. if err != nil {
  928. return
  929. }
  930. //修改音频标题
  931. 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)`
  932. _, err = o.Raw(sql2, reportId).Exec()
  933. return
  934. }
  935. // MarkEditReport 标记编辑英文研报的请求数据
  936. type MarkEditReport struct {
  937. ReportId int `description:"研报id"`
  938. Status int `description:"标记状态,1:编辑中,2:编辑完成"`
  939. }
  940. type MarkReportResp struct {
  941. Status int `description:"状态:0:无人编辑, 1:当前有人在编辑"`
  942. Msg string `description:"提示信息"`
  943. Editor string `description:"编辑者姓名"`
  944. }
  945. type MarkReportItem struct {
  946. AdminId int `description:"编辑者ID"`
  947. Editor string `description:"编辑者姓名"`
  948. ReportClassifyNameFirst string
  949. }
  950. // GetReportByCondition 获取报告
  951. func GetReportByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string, isPage bool, startSize, pageSize int) (items []*Report, err error) {
  952. o := orm.NewOrmUsingDB("rddp")
  953. fields := `*`
  954. if len(fieldArr) > 0 {
  955. fields = strings.Join(fieldArr, ",")
  956. }
  957. sql := `SELECT ` + fields + ` FROM report WHERE 1=1 `
  958. sql += condition
  959. order := ` ORDER BY modify_time DESC`
  960. if orderRule != `` {
  961. order = orderRule
  962. }
  963. sql += order
  964. if isPage {
  965. sql += ` LIMIT ?,?`
  966. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  967. } else {
  968. _, err = o.Raw(sql, pars).QueryRows(&items)
  969. }
  970. return
  971. }
  972. // ModifyReportMsgIsSendV2 更新报告消息状态
  973. func ModifyReportMsgIsSendV2(reportId int) (err error) {
  974. o := orm.NewOrmUsingDB("rddp")
  975. sql := `UPDATE report SET msg_is_send = 1, ths_msg_is_send = 1, msg_send_time = NOW() WHERE id = ? LIMIT 1`
  976. _, err = o.Raw(sql, reportId).Exec()
  977. return
  978. }
  979. // SetPrePublishReportById 设置定时发布
  980. func SetPrePublishReportById(reportId int, prePublishTime string, preMsgSend int) (err error) {
  981. o := orm.NewOrmUsingDB("rddp")
  982. sql := `UPDATE report SET pre_publish_time=?, pre_msg_send=? WHERE id = ? and state = 1 `
  983. _, err = o.Raw(sql, prePublishTime, preMsgSend, reportId).Exec()
  984. return
  985. }
  986. // ReportSubmitApproveReq 提交审批请求体
  987. type ReportSubmitApproveReq struct {
  988. ReportId int `description:"报告ID"`
  989. }
  990. // ReportCancelApproveReq 撤回审批请求体
  991. type ReportCancelApproveReq struct {
  992. ReportId int `description:"报告ID"`
  993. }
  994. func (m *Report) GetItemById(id int) (item *Report, err error) {
  995. o := orm.NewOrmUsingDB("rddp")
  996. sql := `SELECT * FROM report WHERE id = ? LIMIT 1`
  997. err = o.Raw(sql, id).QueryRow(&item)
  998. return
  999. }