english_report.go 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016
  1. package models
  2. import (
  3. "errors"
  4. "eta/eta_api/utils"
  5. "fmt"
  6. "strings"
  7. "time"
  8. "github.com/beego/beego/v2/client/orm"
  9. "github.com/rdlucklib/rdluck_tools/paging"
  10. )
  11. type EnglishReport struct {
  12. Id int `orm:"column(id)" description:"报告Id"`
  13. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  14. ClassifyIdFirst int `description:"一级分类id"`
  15. ClassifyNameFirst string `description:"一级分类名称"`
  16. ClassifyIdSecond int `description:"二级分类id"`
  17. ClassifyNameSecond string `description:"二级分类名称"`
  18. Title string `description:"标题"`
  19. Abstract string `description:"摘要"`
  20. Author string `description:"作者"`
  21. Frequency string `description:"频度"`
  22. CreateTime string `description:"创建时间"`
  23. ModifyTime time.Time `description:"修改时间"`
  24. State int `description:"1:未发布;2:已发布;3-待提交;4-待审批;5-已驳回;6-已通过"`
  25. PublishTime time.Time `description:"发布时间"`
  26. PrePublishTime time.Time `description:"预发布时间"`
  27. Stage int `description:"期数"`
  28. Content string `description:"内容"`
  29. VideoUrl string `description:"音频文件URL"`
  30. VideoName string `description:"音频文件名称"`
  31. VideoPlaySeconds string `description:"音频播放时长"`
  32. VideoSize string `description:"音频文件大小,单位M"`
  33. ContentSub string `description:"内容前两个章节"`
  34. ReportCode string `description:"报告唯一编码"`
  35. Pv int `description:"Pv"`
  36. PvEmail int `description:"邮箱PV"`
  37. UvEmail int `description:"邮箱UV"`
  38. EmailState int `description:"群发邮件状态: 0-未发送; 1-已发送"`
  39. Overview string `description:"英文概述部分"`
  40. KeyTakeaways string `description:"关键点"`
  41. FromReportId int `description:"继承的报告ID(英文策略报告ID)"`
  42. AdminId int `description:"创建者账号"`
  43. AdminRealName string `description:"创建者姓名"`
  44. ApproveTime time.Time `description:"审批时间"`
  45. ApproveId int `description:"审批ID"`
  46. DetailImgUrl string `description:"报告详情长图地址"`
  47. DetailPdfUrl string `description:"报告详情PDF地址"`
  48. EmailHasFail int `description:"是否存在邮件发送失败的记录: 0-否; 1-是"`
  49. }
  50. func GetEnglishReportStage(classifyIdFirst, classifyIdSecond int) (count int, err error) {
  51. o := orm.NewOrmUsingDB("rddp")
  52. sql := ``
  53. if classifyIdSecond > 0 {
  54. sql = "SELECT MAX(stage) AS max_stage FROM english_report WHERE classify_id_second=? "
  55. o.Raw(sql, classifyIdSecond).QueryRow(&count)
  56. } else {
  57. sql = "SELECT MAX(stage) AS max_stage FROM english_report WHERE classify_id_first=? "
  58. o.Raw(sql, classifyIdFirst).QueryRow(&count)
  59. }
  60. return
  61. }
  62. func GetEnglishReportStageEdit(classifyIdFirst, classifyIdSecond, reportId int) (count int, err error) {
  63. o := orm.NewOrmUsingDB("rddp")
  64. sql := ``
  65. if classifyIdSecond > 0 {
  66. sql = "SELECT MAX(stage) AS max_stage FROM english_report WHERE classify_id_second=? AND id<>? "
  67. o.Raw(sql, classifyIdSecond, reportId).QueryRow(&count)
  68. } else {
  69. sql = "SELECT MAX(stage) AS max_stage FROM english_report WHERE classify_id_first=? AND id<>? "
  70. o.Raw(sql, classifyIdFirst, reportId).QueryRow(&count)
  71. }
  72. return
  73. }
  74. func AddEnglishReport(item *EnglishReport) (lastId int64, err error) {
  75. o := orm.NewOrmUsingDB("rddp")
  76. lastId, err = o.Insert(item)
  77. return
  78. }
  79. func ModifyEnglishReportCode(reportId int64, reportCode string) (err error) {
  80. o := orm.NewOrmUsingDB("rddp")
  81. sql := `UPDATE english_report SET report_code=? WHERE id=? `
  82. _, err = o.Raw(sql, reportCode, reportId).Exec()
  83. return
  84. }
  85. type AddEnglishReportReq struct {
  86. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  87. ClassifyIdFirst int `description:"一级分类id"`
  88. ClassifyNameFirst string `description:"一级分类名称"`
  89. ClassifyIdSecond int `description:"二级分类id"`
  90. ClassifyNameSecond string `description:"二级分类名称"`
  91. ClassifyIdThird int `description:"三级分类id"`
  92. ClassifyNameThird string `description:"三级分类名称"`
  93. Title string `description:"标题"`
  94. Abstract string `description:"摘要"`
  95. Author string `description:"作者"`
  96. Frequency string `description:"频度"`
  97. State int `description:"状态:1:未发布,2:已发布"`
  98. Content string `description:"内容"`
  99. CreateTime string `description:"创建时间"`
  100. Overview string `description:"英文概述部分"`
  101. }
  102. type AddEnglishReportResp struct {
  103. ReportId int64 `description:"报告id"`
  104. ReportCode string `description:"报告code"`
  105. }
  106. type EditEnglishReportReq struct {
  107. ReportId int64 `description:"报告id"`
  108. ClassifyIdFirst int `description:"一级分类id"`
  109. ClassifyNameFirst string `description:"一级分类名称"`
  110. ClassifyIdSecond int `description:"二级分类id"`
  111. ClassifyNameSecond string `description:"二级分类名称"`
  112. Title string `description:"标题"`
  113. Abstract string `description:"摘要"`
  114. Author string `description:"作者"`
  115. Frequency string `description:"频度"`
  116. State int `description:"状态:1:未发布,2:已发布"`
  117. Content string `description:"内容"`
  118. CreateTime string `description:"创建时间"`
  119. Overview string `description:"英文概述部分"`
  120. }
  121. type EditEnglishReportFromPolicyReq struct {
  122. ReportId int64 `description:"报告id"`
  123. Title string `description:"标题"`
  124. Abstract string `description:"摘要"`
  125. Author string `description:"作者"`
  126. Frequency string `description:"频度"`
  127. CreateTime string `description:"创建时间"`
  128. //Overview string `description:"英文概述部分"`
  129. }
  130. type EditEnglishReportResp struct {
  131. ReportId int64 `description:"报告id"`
  132. ReportCode string `description:"报告code"`
  133. }
  134. type ElasticEnglishReportDetail struct {
  135. Id string `description:"报告id或者线上路演Id"`
  136. ReportId int `description:"报告id"`
  137. VideoId int `description:"线上路演Id"`
  138. ClassifyIdFirst int `description:"一级分类id"`
  139. ClassifyNameFirst string `description:"一级分类名称"`
  140. ClassifyIdSecond int `description:"二级分类id"`
  141. ClassifyNameSecond string `description:"二级分类名称"`
  142. StageStr string `description:"报告期数"`
  143. Title string `description:"标题"`
  144. Abstract string `description:"摘要"`
  145. Author string `description:"作者"`
  146. Frequency string `description:"频度"`
  147. PublishState int `description:"状态:1:未发布,2:已发布"`
  148. BodyContent string `description:"内容"`
  149. ContentSub string `description:"前两段内容"`
  150. CreateTime string `description:"创建时间"`
  151. PublishTime string `description:"发布时间"`
  152. ReportCode string `description:"报告唯一编码"`
  153. Overview string `description:"英文概述部分"`
  154. }
  155. func EditEnglishReport(item *EnglishReport, reportId int64) (err error) {
  156. o := orm.NewOrmUsingDB("rddp")
  157. sql := `UPDATE english_report
  158. SET
  159. classify_id_first =?,
  160. classify_name_first = ?,
  161. classify_id_second = ?,
  162. classify_name_second = ?,
  163. title = ?,
  164. abstract = ?,
  165. author = ?,
  166. frequency = ?,
  167. state = ?,
  168. content = ?,
  169. content_sub = ?,
  170. stage =?,
  171. create_time = ?,
  172. modify_time = ?,
  173. overview = ?
  174. WHERE id = ? `
  175. _, err = o.Raw(sql, item.ClassifyIdFirst, item.ClassifyNameFirst, item.ClassifyIdSecond, item.ClassifyNameSecond, item.Title,
  176. item.Abstract, item.Author, item.Frequency, item.State, item.Content, item.ContentSub, item.Stage, item.CreateTime, time.Now(), item.Overview, reportId).Exec()
  177. return
  178. }
  179. type EnglishReportDetail struct {
  180. Id int `orm:"column(id)" description:"报告Id"`
  181. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  182. ClassifyIdFirst int `description:"一级分类id"`
  183. ClassifyNameFirst string `description:"一级分类名称"`
  184. ClassifyIdSecond int `description:"二级分类id"`
  185. ClassifyNameSecond string `description:"二级分类名称"`
  186. Title string `description:"标题"`
  187. Abstract string `description:"摘要"`
  188. Author string `description:"作者"`
  189. Frequency string `description:"频度"`
  190. CreateTime string `description:"创建时间"`
  191. ModifyTime string `description:"修改时间"`
  192. State int `description:"1:未发布,2:已发布"`
  193. PublishTime string `description:"发布时间"`
  194. PrePublishTime string `description:"预发布时间"`
  195. Stage int `description:"期数"`
  196. MsgIsSend int `description:"消息是否已发送,0:否,1:是"`
  197. ReportCode string `description:"报告唯一编码"`
  198. Content string `description:"内容"`
  199. VideoUrl string `description:"音频文件URL"`
  200. VideoName string `description:"音频文件名称"`
  201. VideoPlaySeconds string `description:"音频播放时长"`
  202. ContentSub string `description:"内容前两个章节"`
  203. Pv int `description:"Pv"`
  204. Overview string `description:"英文概述部分"`
  205. FromReportId int `description:"继承的报告ID(英文策略报告ID)"`
  206. KeyTakeaways string `description:"关键点"`
  207. ClassifyIdRoot int `description:"顶级分类id"`
  208. ClassifyNameRoot string `description:"顶级分类名称"`
  209. }
  210. func GetEnglishReportById(reportId int) (item *EnglishReportDetail, err error) {
  211. o := orm.NewOrmUsingDB("rddp")
  212. sql := `SELECT * FROM english_report WHERE id=?`
  213. err = o.Raw(sql, reportId).QueryRow(&item)
  214. return
  215. }
  216. func GetEnglishReportItemById(reportId int) (item *EnglishReport, err error) {
  217. o := orm.NewOrmUsingDB("rddp")
  218. sql := `SELECT * FROM english_report WHERE id = ? LIMIT 1`
  219. err = o.Raw(sql, reportId).QueryRow(&item)
  220. return
  221. }
  222. type EnglishReportList struct {
  223. Id int `description:"报告Id"`
  224. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  225. ClassifyIdFirst int `description:"一级分类id"`
  226. ClassifyNameFirst string `description:"一级分类名称"`
  227. ClassifyIdSecond int `description:"二级分类id"`
  228. ClassifyNameSecond string `description:"二级分类名称"`
  229. Title string `description:"标题"`
  230. Abstract string `description:"摘要"`
  231. Author string `description:"作者"`
  232. Frequency string `description:"频度"`
  233. CreateTime string `description:"创建时间"`
  234. ModifyTime time.Time `description:"修改时间"`
  235. State int `description:"1:未发布;2:已发布;3-待提交;4-待审批;5-已驳回;6-已通过"`
  236. PublishTime string `description:"发布时间"`
  237. PrePublishTime string `description:"预发布时间"`
  238. Stage int `description:"期数"`
  239. Content string `description:"内容"`
  240. VideoUrl string `description:"音频文件URL"`
  241. VideoName string `description:"音频文件名称"`
  242. VideoPlaySeconds string `description:"音频播放时长"`
  243. ContentSub string `description:"内容前两个章节"`
  244. ReportCode string `description:"报告唯一编码"`
  245. Pv int `description:"Pv"`
  246. ShareUrl string `description:"分享url"`
  247. PvEmail int `description:"邮箱PV"`
  248. UvEmail int `description:"邮箱UV"`
  249. EmailState int `description:"群发邮件状态: 0-未发送; 1-已发送"`
  250. EmailAuth bool `description:"是否有权限群发邮件"`
  251. EmailHasFail bool `description:"是否存在邮件发送失败的记录"`
  252. CanEdit bool `description:"是否可编辑"`
  253. Editor string `description:"编辑人"`
  254. FromReportId int `description:"继承的报告ID(英文策略报告ID)"`
  255. AdminId int `description:"创建者账号"`
  256. AdminRealName string `description:"创建者姓名"`
  257. FullClassifyName string `description:"顶级分类名/父级分类名/当前分类名"`
  258. ClassifyIdRoot int `description:"顶级分类id"`
  259. ClassifyNameRoot string `description:"顶级分类名称"`
  260. ApproveTime string `description:"审批时间"`
  261. DetailImgUrl string `description:"报告详情长图地址"`
  262. DetailPdfUrl string `description:"报告详情PDF地址"`
  263. }
  264. type EnglishReportListResp struct {
  265. List []*EnglishReportList
  266. Paging *paging.PagingItem `description:"分页数据"`
  267. }
  268. func GetEnglishReportListCount(condition string, pars []interface{}, companyType string) (count int, err error) {
  269. //产品权限
  270. companyTypeSqlStr := ``
  271. if companyType == "ficc" {
  272. companyTypeSqlStr = " AND classify_id_first != 40 "
  273. } else if companyType == "权益" {
  274. companyTypeSqlStr = " AND classify_id_first = 40 "
  275. }
  276. oRddp := orm.NewOrmUsingDB("rddp")
  277. sql := `SELECT COUNT(1) AS count FROM english_report WHERE 1=1 ` + companyTypeSqlStr
  278. if condition != "" {
  279. sql += condition
  280. }
  281. err = oRddp.Raw(sql, pars).QueryRow(&count)
  282. return
  283. }
  284. func GetEnglishReportList(condition string, pars []interface{}, companyType string, startSize, pageSize int, fieldArr []string) (items []*EnglishReport, err error) {
  285. o := orm.NewOrmUsingDB("rddp")
  286. //产品权限
  287. companyTypeSqlStr := ``
  288. if companyType == "ficc" {
  289. companyTypeSqlStr = " AND classify_id_first != 40 "
  290. } else if companyType == "权益" {
  291. companyTypeSqlStr = " AND classify_id_first = 40 "
  292. }
  293. fields := "*"
  294. if len(fieldArr) > 0 {
  295. fields = strings.Join(fieldArr, ",")
  296. }
  297. sql := fmt.Sprintf(`SELECT %s FROM english_report WHERE 1=1 %s `, fields, companyTypeSqlStr)
  298. if condition != "" {
  299. sql += condition
  300. }
  301. // 排序:1:未发布;2:已发布;3-待提交;4-待审批;5-已驳回;6-已通过
  302. sql += ` ORDER BY FIELD(state,3,1,4,5,6,2), modify_time DESC LIMIT ?,?`
  303. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  304. return
  305. }
  306. func GetEnglishReportByCondition(condition string, pars []interface{}) (items []*EnglishReport, err error) {
  307. o := orm.NewOrmUsingDB("rddp")
  308. sql := `SELECT *
  309. FROM english_report WHERE 1=1 `
  310. if condition != "" {
  311. sql += condition
  312. }
  313. _, err = o.Raw(sql, pars).QueryRows(&items)
  314. return
  315. }
  316. func GetEnglishReportCountByCondition(condition string, pars []interface{}) (count int, err error) {
  317. o := orm.NewOrmUsingDB("rddp")
  318. sql := `SELECT count(*)
  319. FROM english_report WHERE 1=1 `
  320. if condition != "" {
  321. sql += condition
  322. }
  323. err = o.Raw(sql, pars).QueryRow(&count)
  324. return
  325. }
  326. // PublishEnglishReportById 发布报告
  327. func PublishEnglishReportById(reportId int, publishTime string) (err error) {
  328. o := orm.NewOrmUsingDB("rddp")
  329. sql := `UPDATE english_report SET state=2,publish_time=?,pre_publish_time=null,modify_time=NOW() WHERE id = ? `
  330. _, err = o.Raw(sql, publishTime, reportId).Exec()
  331. return
  332. }
  333. // ResetEnglishReportById 重置报告状态
  334. func ResetEnglishReportById(reportId, state int) (err error) {
  335. o := orm.NewOrmUsingDB("rddp")
  336. sql := `UPDATE english_report SET state = ?, pre_publish_time = null, modify_time = NOW() WHERE id = ?`
  337. _, err = o.Raw(sql, state, reportId).Exec()
  338. return
  339. }
  340. // PublishCancelEnglishReport 取消发布报告
  341. func PublishCancelEnglishReport(reportIds, state int) (err error) {
  342. o := orm.NewOrmUsingDB("rddp")
  343. sql := ` UPDATE english_report SET state=?, pre_publish_time=null WHERE id =? `
  344. _, err = o.Raw(sql, state, reportIds).Exec()
  345. return
  346. }
  347. // SetPrePublishEnglishReportById 设置定时发布
  348. func SetPrePublishEnglishReportById(reportId int, prePublishTime string) (err error) {
  349. o := orm.NewOrmUsingDB("rddp")
  350. sql := `UPDATE english_report SET pre_publish_time=? WHERE id = ? and state = 1 `
  351. _, err = o.Raw(sql, prePublishTime, reportId).Exec()
  352. return
  353. }
  354. // DeleteEnglishReportAndChapter 删除报告及章节
  355. func DeleteEnglishReportAndChapter(reportInfo *EnglishReportDetail) (err error) {
  356. reportId := reportInfo.Id
  357. if reportInfo.State == 2 {
  358. err = errors.New("报告已发布,不可删除")
  359. return
  360. }
  361. err = DeleteEnglishReport(reportId)
  362. if err != nil {
  363. err = errors.New("删除失败, Err: " + err.Error())
  364. return
  365. }
  366. return
  367. }
  368. // 删除报告
  369. func DeleteEnglishReport(reportIds int) (err error) {
  370. o := orm.NewOrmUsingDB("rddp")
  371. sql := ` DELETE FROM english_report WHERE id =? `
  372. _, err = o.Raw(sql, reportIds).Exec()
  373. return
  374. }
  375. func EditEnglishReportContent(reportId int, content, contentSub string) (err error) {
  376. o := orm.NewOrmUsingDB("rddp")
  377. sql := ` UPDATE english_report SET content=?,content_sub=?,modify_time=NOW() WHERE id=? `
  378. _, err = o.Raw(sql, content, contentSub, reportId).Exec()
  379. return
  380. }
  381. func AddEnglishReportSaveLog(reportId, adminId int, content, contentSub, adminName string) (err error) {
  382. o := orm.NewOrmUsingDB("rddp")
  383. sql := ` INSERT INTO english_report_save_log(report_id, content,content_sub,admin_id,admin_name) VALUES (?,?,?,?,?) `
  384. _, err = o.Raw(sql, reportId, content, contentSub, adminId, adminName).Exec()
  385. return
  386. }
  387. type EnglishClassifyList struct {
  388. Id int `orm:"column(id);pk"`
  389. ClassifyName string `description:"分类名称"`
  390. Sort int `description:"排序"`
  391. ParentId int `description:"父级分类id"`
  392. RootId int `description:"一级分类ID"`
  393. CreateTime time.Time `description:"创建时间"`
  394. ModifyTime time.Time `description:"修改时间"`
  395. ClassifyLabel string `description:"分类标签"`
  396. ShowType int `description:"展示类型:1-列表 2-专栏"`
  397. IsShow int `description:"是否在小程序显示:1-显示 0-隐藏"`
  398. //ClassifyType int `description:"分类类型:0英文报告,1英文线上路演"`
  399. EnPermissions []int `description:"英文权限IDs"`
  400. Enabled int `description:"是否可用,1可用,0禁用"`
  401. Child []*EnglishClassifyList
  402. }
  403. type EnglishClassifyListResp struct {
  404. List []*EnglishClassifyList
  405. }
  406. // GetEnglishClassifyRootId 获取一级分类列表
  407. func GetEnglishClassifyRootId(keyword string, enabled int) (items []*EnglishClassifyList, err error) {
  408. sql := ``
  409. o := orm.NewOrmUsingDB("rddp")
  410. cond := ""
  411. if enabled == 1 {
  412. cond = " AND enabled=1 "
  413. }
  414. if keyword != "" {
  415. sql = `SELECT * FROM (
  416. SELECT * FROM english_classify
  417. WHERE parent_id=0 ` + cond + ` AND classify_name LIKE ?
  418. UNION
  419. SELECT * FROM english_classify
  420. WHERE id IN(SELECT parent_id FROM english_classify
  421. WHERE parent_id>0 ` + cond + ` AND classify_name LIKE ? )
  422. )AS t
  423. ORDER BY sort ASC,create_time ASC`
  424. _, err = o.Raw(sql, utils.GetLikeKeyword(keyword), utils.GetLikeKeyword(keyword)).QueryRows(&items)
  425. } else {
  426. sql = `SELECT * FROM english_classify WHERE parent_id=0 ` + cond + ` ORDER BY sort ASC,create_time ASC `
  427. _, err = o.Raw(sql).QueryRows(&items)
  428. }
  429. return
  430. }
  431. func GetEnglishClassifyListByRootId(rootIds []int, keyword string, enabled int) (items []*EnglishClassifyList, err error) {
  432. sql := ``
  433. pars := make([]interface{}, 0)
  434. o := orm.NewOrmUsingDB("rddp")
  435. cond := ""
  436. if enabled == 1 {
  437. cond = " AND enabled=1 "
  438. }
  439. if keyword != "" {
  440. sql = `SELECT
  441. a.*
  442. FROM
  443. english_classify a
  444. LEFT JOIN english_classify b ON a.root_id = b.id
  445. LEFT JOIN english_classify c ON a.parent_id = c.id
  446. WHERE a.parent_id>0 ` + cond + ` and a.classify_name LIKE ? and a.root_id IN (` + utils.GetOrmInReplace(len(rootIds)) + `)`
  447. pars = append(pars, utils.GetLikeKeyword(keyword))
  448. pars = append(pars, rootIds)
  449. _, err = o.Raw(sql, pars).QueryRows(&items)
  450. } else {
  451. sql = `SELECT * FROM english_classify WHERE parent_id>0 ` + cond + ` and root_id IN (` + utils.GetOrmInReplace(len(rootIds)) + `) `
  452. _, err = o.Raw(sql, rootIds).QueryRows(&items)
  453. }
  454. return
  455. }
  456. func GetEnglishClassifyChildByIds(ids []int) (items []*EnglishClassifyList, err error) {
  457. o := orm.NewOrmUsingDB("rddp")
  458. sql := `SELECT * FROM english_classify WHERE id IN (` + utils.GetOrmInReplace(len(ids)) + `) ORDER BY create_time ASC `
  459. _, err = o.Raw(sql, ids).QueryRows(&items)
  460. return
  461. }
  462. func GetEnglishReportDetailByClassifyId(classifyIdFirst, classifyIdSecond int) (item *EnglishReportDetail, err error) {
  463. o := orm.NewOrmUsingDB("rddp")
  464. sql := ` SELECT * FROM english_report WHERE 1=1 `
  465. if classifyIdSecond > 0 {
  466. sql = sql + ` AND classify_id_second=? ORDER BY stage DESC LIMIT 1`
  467. err = o.Raw(sql, classifyIdSecond).QueryRow(&item)
  468. } else {
  469. sql = sql + ` AND classify_id_first=? ORDER BY stage DESC LIMIT 1`
  470. err = o.Raw(sql, classifyIdFirst).QueryRow(&item)
  471. }
  472. return
  473. }
  474. // Update 更新
  475. func (item *EnglishReport) Update(cols []string) (err error) {
  476. o := orm.NewOrmUsingDB("rddp")
  477. _, err = o.Update(item, cols...)
  478. return
  479. }
  480. // ModifyEnglishReportAuthor 更改英文报告作者
  481. func ModifyEnglishReportAuthor(condition string, pars []interface{}, authorName string) (count int, err error) {
  482. //产品权限
  483. oRddp := orm.NewOrmUsingDB("rddp")
  484. sql := `UPDATE english_report set author = ? WHERE 1=1 `
  485. if condition != "" {
  486. sql += condition
  487. }
  488. err = oRddp.Raw(sql, authorName, pars).QueryRow(&count)
  489. return
  490. }
  491. type EnglishClassify struct {
  492. Id int `orm:"column(id);pk"`
  493. ClassifyName string `description:"分类名称"`
  494. Sort int `description:"排序"`
  495. ParentId int `description:"父级分类id"`
  496. RootId int `description:"一级分类ID"`
  497. CreateTime time.Time `description:"创建时间"`
  498. ModifyTime time.Time `description:"修改时间"`
  499. ClassifyLabel string `description:"分类标签"`
  500. ShowType int `description:"展示类型:1-列表 2-专栏"`
  501. IsShow int `description:"是否在小程序显示:1-显示 0-隐藏"`
  502. //ClassifyType int `description:"分类类型:0英文报告,1英文线上路演"`
  503. Enabled int `description:"是否可用,1可用,0禁用"`
  504. }
  505. func AddEnglishClassify(item *EnglishClassify) (lastId int64, err error) {
  506. o := orm.NewOrmUsingDB("rddp")
  507. lastId, err = o.Insert(item)
  508. return
  509. }
  510. func ModifyEnglishClassify(item *EnglishClassify) (err error) {
  511. o := orm.NewOrmUsingDB("rddp")
  512. sql := `UPDATE english_classify
  513. SET
  514. classify_name = ?,
  515. sort = ?,
  516. parent_id = ?,
  517. root_id = ?,
  518. modify_time = ?
  519. WHERE id = ? `
  520. _, err = o.Raw(sql, item.ClassifyName, item.Sort, item.ParentId, item.RootId, item.ModifyTime, item.Id).Exec()
  521. return
  522. }
  523. // UpdateEnglishClassifyRootIdByParentId 更新报告分类的顶级ID
  524. func UpdateEnglishClassifyRootIdByParentId(parentId, rootId int) (err error) {
  525. o := orm.NewOrmUsingDB("rddp")
  526. sql := " UPDATE english_classify SET root_id = ? WHERE parent_id=? "
  527. _, err = o.Raw(sql, rootId, parentId).Exec()
  528. return
  529. }
  530. // UpdateClassify 更新分类
  531. func (classifyInfo *EnglishClassify) UpdateEnglishClassify(cols []string) (err error) {
  532. o := orm.NewOrmUsingDB("rddp")
  533. _, err = o.Update(classifyInfo, cols...)
  534. return
  535. }
  536. // DeleteEnglishClassify 删除英文分类
  537. func DeleteEnglishClassify(classifyId int) (err error) {
  538. o := orm.NewOrmUsingDB("rddp")
  539. sql := ` DELETE FROM english_classify WHERE id =? `
  540. _, err = o.Raw(sql, classifyId).Exec()
  541. return
  542. }
  543. func GetEnglishClassifyChildCounts(parentId int) (count int, err error) {
  544. o := orm.NewOrmUsingDB("rddp")
  545. sql := `SELECT COUNT(1) AS count FROM english_classify WHERE parent_id=? `
  546. err = o.Raw(sql, parentId).QueryRow(&count)
  547. return
  548. }
  549. func GetEnglishReportCounts(classifyId, parentId int) (count int, err error) {
  550. o := orm.NewOrmUsingDB("rddp")
  551. sql := ``
  552. if parentId == 0 {
  553. sql = `SELECT COUNT(1) AS count FROM english_report WHERE classify_id_first=? `
  554. } else {
  555. sql = `SELECT COUNT(1) AS count FROM english_report WHERE classify_id_second=? `
  556. }
  557. err = o.Raw(sql, classifyId).QueryRow(&count)
  558. return
  559. }
  560. func GetEnglishClassifyCountsByName(name string, parentId int) (count int, err error) {
  561. o := orm.NewOrmUsingDB("rddp")
  562. sql := `SELECT COUNT(1) AS count FROM english_classify WHERE classify_name=? AND parent_id = ? `
  563. err = o.Raw(sql, name, parentId).QueryRow(&count)
  564. return
  565. }
  566. // GetEnglishFirstClassifyList 获取一级、二级分类列表
  567. func GetEnglishFirstClassifyList() (items []*EnglishClassifyList, err error) {
  568. o := orm.NewOrmUsingDB("rddp")
  569. sql := `SELECT * FROM english_classify WHERE parent_id=0 ORDER BY sort ASC,create_time`
  570. _, err = o.Raw(sql).QueryRows(&items)
  571. return
  572. }
  573. // GetEnglishSecondClassifyList 获取一级、二级分类列表
  574. func GetEnglishSecondClassifyList(rootIds []int) (items []*EnglishClassifyList, err error) {
  575. o := orm.NewOrmUsingDB("rddp")
  576. sql := `SELECT * FROM english_classify WHERE root_id IN (` + utils.GetOrmInReplace(len(rootIds)) + `) and parent_id>0 and root_id=parent_id ORDER BY sort ASC,create_time ASC`
  577. _, err = o.Raw(sql, rootIds).QueryRows(&items)
  578. return
  579. }
  580. func GetEnglishFirstClassifyListCount() (count int, err error) {
  581. o := orm.NewOrmUsingDB("rddp")
  582. sqlCount := `SELECT COUNT(1) AS count FROM english_classify WHERE parent_id=0`
  583. err = o.Raw(sqlCount).QueryRow(&count)
  584. return
  585. }
  586. func GetEnglishReportClassifyById(classifyId int) (item *EnglishClassify, err error) {
  587. sql := `SELECT * FROM english_classify WHERE id=?`
  588. o := orm.NewOrmUsingDB("rddp")
  589. err = o.Raw(sql, classifyId).QueryRow(&item)
  590. return
  591. }
  592. func GetEnglishReportClassifyByIds(classifyIds []int) (list []*EnglishClassify, err error) {
  593. o := orm.NewOrmUsingDB("rddp")
  594. sql := `SELECT * FROM english_classify WHERE id IN (` + utils.GetOrmInReplace(len(classifyIds)) + `)`
  595. _, err = o.Raw(sql, classifyIds).QueryRows(&list)
  596. return
  597. }
  598. // UpdateEnglishReportSecondClassifyNameByClassifyId 更新报告分类名称字段
  599. func UpdateEnglishReportSecondClassifyNameByClassifyId(classifyId int, classifyName string) (err error) {
  600. o := orm.NewOrmUsingDB("rddp")
  601. sql := " UPDATE english_report SET classify_name_second = ? WHERE classify_id_second = ? "
  602. _, err = o.Raw(sql, classifyName, classifyId).Exec()
  603. return
  604. }
  605. // UpdateEnglishReportFirstClassifyNameByClassifyId 更新报告分类名称字段
  606. func UpdateEnglishReportFirstClassifyNameByClassifyId(classifyId int, classifyName string) (err error) {
  607. o := orm.NewOrmUsingDB("rddp")
  608. sql := " UPDATE english_report SET classify_name_first = ? WHERE classify_id_first = ? "
  609. _, err = o.Raw(sql, classifyName, classifyId).Exec()
  610. return
  611. }
  612. // UpdateEnglishReportFirstClassifyNameByClassifyId 更新报告分类名称字段
  613. func UpdateEnglishReportByClassifyId(classifyFirstName, classifySecondName string, firstClassifyId, secondClassifyId int, ids string) (err error) {
  614. o := orm.NewOrmUsingDB("rddp")
  615. sql := " UPDATE english_report SET classify_name_first = ?,classify_name_second = ?,classify_id_first=?, classify_id_second =? WHERE id IN (" + ids + ") "
  616. _, err = o.Raw(sql, classifyFirstName, classifySecondName, firstClassifyId, secondClassifyId).Exec()
  617. return
  618. }
  619. func UpdateEnglishReportClassifyByFirstSecondClassifyId(classifyId, parentId int) (err error) {
  620. o := orm.NewOrmUsingDB("rddp")
  621. // 更新相关联的二级分类的parentId,和classify_name_second
  622. sql := `update english_report r
  623. LEFT JOIN english_classify c ON r.classify_id_second = c.id
  624. SET r.classify_id_first=c.parent_id, r.classify_name_second=c.classify_name
  625. where (r.classify_id_first != c.parent_id or r.classify_name_second != c.classify_name) and r.classify_id_second =?`
  626. _, err = o.Raw(sql, classifyId).Exec()
  627. if err != nil {
  628. return
  629. }
  630. //更新一级分类名
  631. sql = `update english_report r
  632. LEFT JOIN english_classify c ON r.classify_id_first = c.id
  633. SET r.classify_name_first=c.classify_name
  634. where r.classify_name_first != c.classify_name and r.classify_id_first=?`
  635. _, err = o.Raw(sql, parentId).Exec()
  636. if err != nil {
  637. return
  638. }
  639. //更新一级分类名
  640. sql = `update english_report r
  641. LEFT JOIN english_classify c ON r.classify_id_first = c.id
  642. SET r.classify_name_first=c.classify_name
  643. where r.classify_name_first != c.classify_name and r.classify_id_first=?`
  644. _, err = o.Raw(sql, classifyId).Exec()
  645. return
  646. }
  647. // FetchEnglishReportById 主键获取英文报告
  648. func FetchEnglishReportById(reportId int) (item *EnglishReport, err error) {
  649. o := orm.NewOrmUsingDB("rddp")
  650. sql := `SELECT * FROM english_report WHERE id=?`
  651. err = o.Raw(sql, reportId).QueryRow(&item)
  652. return
  653. }
  654. // UpdateReport 更新英文报告
  655. func (reportInfo *EnglishReport) UpdateReport(cols []string) (err error) {
  656. o := orm.NewOrmUsingDB("rddp")
  657. _, err = o.Update(reportInfo, cols...)
  658. return
  659. }
  660. // GetAllEnglishClassify 获取所有英文分类
  661. func GetAllEnglishClassify() (list []*Classify, err error) {
  662. o := orm.NewOrmUsingDB("rddp")
  663. sql := ` SELECT * FROM english_classify `
  664. _, err = o.Raw(sql).QueryRows(&list)
  665. return
  666. }
  667. // GetEnglishReportByIds 根据IDs获取英文报告列表
  668. func GetEnglishReportByIds(reportIds []int, fieldArr []string) (list []*EnglishReport, err error) {
  669. listLen := len(reportIds)
  670. if listLen == 0 {
  671. return
  672. }
  673. fields := ` * `
  674. if len(fieldArr) > 0 {
  675. fields = strings.Join(fieldArr, ",")
  676. }
  677. o := orm.NewOrmUsingDB("rddp")
  678. sql := `SELECT ` + fields + ` FROM english_report WHERE id IN (` + utils.GetOrmInReplace(listLen) + `)`
  679. _, err = o.Raw(sql, reportIds).QueryRows(&list)
  680. return
  681. }
  682. // MarkEditEnReport 标记编辑英文研报的请求数据
  683. type MarkEditEnReport struct {
  684. ReportId int `description:"研报id"`
  685. Status int `description:"标记状态,1:编辑中,2:编辑完成"`
  686. }
  687. type EnglishClassifyNameParentName struct {
  688. Id int `description:"分类ID"`
  689. ClassifyName string `description:"分类名称"`
  690. Sort int `description:"排序"`
  691. ParentId int `description:"父级分类id"`
  692. CreateTime time.Time `description:"创建时间"`
  693. ModifyTime time.Time `description:"修改时间"`
  694. ClassifyLabel string `description:"分类标签"`
  695. ShowType int `description:"展示类型:1-列表 2-专栏"`
  696. IsShow int `description:"是否在小程序显示:1-显示 0-隐藏"`
  697. ParentClassifyName string `description:"父级分类名称"`
  698. }
  699. func GetEnglishClassifyByClassifyNameAndParentName(parentClassiyName, classifyName string) (item EnglishClassifyNameParentName, err error) {
  700. o := orm.NewOrmUsingDB("rddp")
  701. sql := "SELECT c1.*, c2.classify_name as parent_classify_name FROM english_classify c1 LEFT JOIN english_classify c2 on c1.parent_id = c2.id where c1.parent_id > 0 and c2.classify_name = ? and c1.classify_name= ?"
  702. err = o.Raw(sql, parentClassiyName, classifyName).QueryRow(&item)
  703. return
  704. }
  705. type RSClassifyList []*EnglishClassifyList
  706. func (m RSClassifyList) Len() int {
  707. return len(m)
  708. }
  709. func (m RSClassifyList) Less(i, j int) bool {
  710. return m[i].Sort < m[j].Sort
  711. }
  712. func (m RSClassifyList) Swap(i, j int) {
  713. m[i], m[j] = m[j], m[i]
  714. }
  715. type RSChildClassifyList []*EnglishClassifyList
  716. func (m RSChildClassifyList) Len() int {
  717. return len(m)
  718. }
  719. func (m RSChildClassifyList) Less(i, j int) bool {
  720. return m[i].Sort < m[j].Sort
  721. }
  722. func (m RSChildClassifyList) Swap(i, j int) {
  723. m[i], m[j] = m[j], m[i]
  724. }
  725. // GetEnglishClassifyByClassifyNameParentId 获取英文分类
  726. func GetEnglishClassifyByClassifyNameParentId(classifyName string, parentId int) (item *Classify, err error) {
  727. o := orm.NewOrmUsingDB("rddp")
  728. sql := ` SELECT * FROM english_classify where classify_name = ? and parent_id = ? `
  729. err = o.Raw(sql, classifyName, parentId).QueryRow(&item)
  730. return
  731. }
  732. type EnglishClassifyFullName struct {
  733. Id int `description:"分类ID"`
  734. ParentId int `description:"父级分类id"`
  735. RootId int `description:"一级分类ID"`
  736. RootName string `description:"一级分类名"`
  737. ParentName string `description:"二级分类名"`
  738. ClassifyName string `description:"分类名称"`
  739. }
  740. // GetEnglishClassifyFullNameByIds 获取英文分类名一级/二级/三级
  741. func GetEnglishClassifyFullNameByIds(classifyIds []int) (list []*EnglishClassifyFullName, err error) {
  742. o := orm.NewOrmUsingDB("rddp")
  743. sql := ` SELECT
  744. a.id,
  745. a.parent_id,
  746. a.root_id,
  747. a.classify_name,
  748. b.classify_name AS root_name,
  749. c.classify_name AS parent_name
  750. FROM
  751. english_classify a
  752. LEFT JOIN english_classify b ON a.root_id = b.id
  753. LEFT JOIN english_classify c ON a.parent_id = c.id
  754. where a.id IN (` + utils.GetOrmInReplace(len(classifyIds)) + `)`
  755. _, err = o.Raw(sql, classifyIds).QueryRows(&list)
  756. return
  757. }
  758. func (m *EnglishReport) GetItemById(id int) (item *EnglishReport, err error) {
  759. o := orm.NewOrmUsingDB("rddp")
  760. sql := `SELECT * FROM english_report WHERE id = ? LIMIT 1`
  761. err = o.Raw(sql, id).QueryRow(&item)
  762. return
  763. }
  764. // GetEnglishClassifies 获取所有英文分类
  765. func GetEnglishClassifies() (list []*EnglishClassify, err error) {
  766. o := orm.NewOrmUsingDB("rddp")
  767. sql := ` SELECT * FROM english_classify `
  768. _, err = o.Raw(sql).QueryRows(&list)
  769. return
  770. }
  771. // GetEnglishReportStateCount 获取指定状态的报告数量
  772. func GetEnglishReportStateCount(state int) (count int, err error) {
  773. o := orm.NewOrmUsingDB("rddp")
  774. sql := `SELECT COUNT(1) AS count FROM english_report WHERE state = ?`
  775. err = o.Raw(sql, state).QueryRow(&count)
  776. return
  777. }
  778. // UpdateEnglishReportsStateByCond 批量更新报告状态
  779. func UpdateEnglishReportsStateByCond(classifyFirstId, classifySecondId, oldState, newState int) (err error) {
  780. o := orm.NewOrmUsingDB("rddp")
  781. cond := ``
  782. if classifyFirstId > 0 {
  783. cond += fmt.Sprintf(` AND classify_id_first = %d`, classifyFirstId)
  784. }
  785. if classifySecondId > 0 {
  786. cond += fmt.Sprintf(` AND classify_id_second = %d`, classifySecondId)
  787. }
  788. sql := fmt.Sprintf(`UPDATE english_report SET state = ?, pre_publish_time = NULL WHERE state = ? %s`, cond)
  789. _, err = o.Raw(sql, newState, oldState).Exec()
  790. return
  791. }
  792. // UpdateEnglishReportsStateBySecondIds 批量更新二级分类报告状态
  793. func UpdateEnglishReportsStateBySecondIds(oldState, newState int, secondIds []int) (err error) {
  794. if len(secondIds) <= 0 {
  795. return
  796. }
  797. o := orm.NewOrmUsingDB("rddp")
  798. // (有审批流的)未发布->待提交
  799. sql := fmt.Sprintf(`UPDATE english_report SET state = ?, pre_publish_time = NULL WHERE state = ? AND classify_id_second IN (%s)`, utils.GetOrmInReplace(len(secondIds)))
  800. _, err = o.Raw(sql, newState, oldState, secondIds).Exec()
  801. if err != nil {
  802. return
  803. }
  804. // (无审批流的)待提交->未发布
  805. sql = fmt.Sprintf(`UPDATE english_report SET state = ?, pre_publish_time = NULL WHERE state = ? AND classify_id_second NOT IN (%s)`, utils.GetOrmInReplace(len(secondIds)))
  806. _, err = o.Raw(sql, oldState, newState, secondIds).Exec()
  807. return
  808. }
  809. type EnglishClassifySetEnabledReq struct {
  810. ClassifyId int `description:"分类ID"`
  811. Enabled int `description:"是否可用,1可用,0禁用"`
  812. }
  813. func (classifyInfo *EnglishClassify) SetEnabled(id, enabled int) (err error) {
  814. o := orm.NewOrmUsingDB("rddp")
  815. to, err := o.Begin()
  816. if err != nil {
  817. return
  818. }
  819. defer func() {
  820. if err != nil {
  821. _ = to.Rollback()
  822. } else {
  823. _ = to.Commit()
  824. }
  825. }()
  826. sql := ` UPDATE english_classify SET enabled =? WHERE id = ?`
  827. _, err = to.Raw(sql, enabled, id).Exec()
  828. if err != nil {
  829. return
  830. }
  831. sql = ` UPDATE english_classify SET enabled =? WHERE parent_id = ? or root_id = ?`
  832. _, err = to.Raw(sql, enabled, id, id).Exec()
  833. if err != nil {
  834. return
  835. }
  836. return
  837. }
  838. func ModifyEnglishReportPdfUrl(reportId int, detailPdfUrl string) (err error) {
  839. o := orm.NewOrmUsingDB("rddp")
  840. sql := `UPDATE english_report SET detail_pdf_url=? WHERE id=? `
  841. _, err = o.Raw(sql, detailPdfUrl, reportId).Exec()
  842. return
  843. }
  844. func ModifyEnglishReportImgUrl(reportId int, detailImgUrl string) (err error) {
  845. o := orm.NewOrmUsingDB("rddp")
  846. sql := `UPDATE english_report SET detail_img_url=? WHERE id=? `
  847. _, err = o.Raw(sql, detailImgUrl, reportId).Exec()
  848. return
  849. }
  850. func FormatEnglishReport2ListItem(origin *EnglishReport) (item *EnglishReportList) {
  851. if origin == nil {
  852. return
  853. }
  854. item = new(EnglishReportList)
  855. item.Id = origin.Id
  856. item.AddType = origin.AddType
  857. item.ClassifyIdFirst = origin.ClassifyIdFirst
  858. item.ClassifyNameFirst = origin.ClassifyNameFirst
  859. item.ClassifyIdSecond = origin.ClassifyIdSecond
  860. item.ClassifyNameSecond = origin.ClassifyNameSecond
  861. item.Title = origin.Title
  862. item.Abstract = origin.Abstract
  863. item.Author = origin.Author
  864. item.Frequency = origin.Frequency
  865. item.CreateTime = origin.CreateTime
  866. item.ModifyTime = origin.ModifyTime
  867. item.State = origin.State
  868. item.PublishTime = utils.TimeTransferString(utils.FormatDateTime, origin.PublishTime)
  869. item.PrePublishTime = utils.TimeTransferString(utils.FormatDateTime, origin.PrePublishTime)
  870. item.Stage = origin.Stage
  871. //item.Content = origin.Content
  872. item.VideoUrl = origin.VideoUrl
  873. item.VideoName = origin.VideoName
  874. item.VideoPlaySeconds = origin.VideoPlaySeconds
  875. item.ContentSub = origin.ContentSub
  876. item.ReportCode = origin.ReportCode
  877. item.Pv = origin.Pv
  878. item.PvEmail = origin.PvEmail
  879. item.UvEmail = origin.UvEmail
  880. // 邮箱PV大于0的时候, 不展示最初版本的PV
  881. if item.PvEmail > 0 {
  882. item.Pv = 0
  883. }
  884. item.EmailState = origin.EmailState
  885. if origin.EmailHasFail == 1 {
  886. item.EmailHasFail = true
  887. }
  888. item.FromReportId = origin.FromReportId
  889. item.AdminId = origin.AdminId
  890. item.AdminRealName = origin.AdminRealName
  891. item.ApproveTime = utils.TimeTransferString(utils.FormatDateTime, origin.ApproveTime)
  892. item.DetailImgUrl = origin.DetailImgUrl
  893. item.DetailPdfUrl = origin.DetailPdfUrl
  894. return
  895. }
  896. // UpdateEnglishReportEmailHasFail 标记报告邮件发送失败
  897. func UpdateEnglishReportEmailHasFail(reportId int) (err error) {
  898. o := orm.NewOrmUsingDB("rddp")
  899. sql := `UPDATE english_report SET email_has_fail = 1 WHERE id = ?`
  900. _, err = o.Raw(sql, reportId).Exec()
  901. return
  902. }
  903. // UpdatePdfUrlEnglishReportById 清空pdf相关字段
  904. func UpdatePdfUrlEnglishReportById(reportId int) (err error) {
  905. o := orm.NewOrmUsingDB("rddp")
  906. sql := `UPDATE english_report SET detail_img_url = '',detail_pdf_url='',modify_time=NOW() WHERE id = ? `
  907. _, err = o.Raw(sql, reportId).Exec()
  908. return
  909. }
  910. func GetEnglishReportFieldsByIds(ids []int, fields []string) (items []*EnglishReport, err error) {
  911. if len(ids) == 0 {
  912. return
  913. }
  914. o := orm.NewOrmUsingDB("rddp")
  915. field := " * "
  916. if len(fields) > 0 {
  917. field = fmt.Sprintf(" %s ", strings.Join(fields, ","))
  918. }
  919. sql := fmt.Sprintf(`SELECT %s FROM english_report WHERE id IN (%s)`, field, utils.GetOrmInReplace(len(ids)))
  920. _, err = o.Raw(sql, ids).QueryRows(&items)
  921. return
  922. }