english_report.go 38 KB

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