article.go 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "hongze/hongze_cygx/utils"
  5. "strings"
  6. "time"
  7. )
  8. type CygxArticle struct {
  9. Id int `orm:"column(id);pk"`
  10. ArticleId int `description:"文章id"`
  11. Title string `description:"标题"`
  12. TitleEn string `description:"英文标题 "`
  13. UpdateFrequency string `description:"更新周期"`
  14. CreateDate string `description:"创建时间"`
  15. PublishDate string `description:"发布时间"`
  16. Body string `description:"内容"`
  17. BodyText string `description:"内容"`
  18. Abstract string `description:"摘要"`
  19. CategoryName string `description:"一级分类"`
  20. SubCategoryName string `description:"二级分类"`
  21. PublishStatus int `description:"发布状态"`
  22. CategoryId int `description:"分类id"`
  23. CategoryIdTwo int `description:"分类id用作修改匹配类型使用"`
  24. ExpertBackground string `description:"专家背景"`
  25. ExpertNumber string `description:"专家编号"`
  26. InterviewDate string `description:"访谈日期"`
  27. Department string `description:"作者"`
  28. ArticleIdMd5 string `description:"ID,md5值"`
  29. IsClass int `description:"是否归类,1是,0否"`
  30. IsSummary int `description:"是否是纪要库,1是,0否"`
  31. IsReport int `description:"是否属于报告,1是,0否"`
  32. ReportType int `description:"报告类型,1行业报告,2产业报告,0无"`
  33. FileLink string `description:"下载预览链接"`
  34. MatchTypeName string `description:"匹配类型"`
  35. Periods string `description:"期数"`
  36. ReportLink string `description:"报告链接"`
  37. ArticleType string `description:"文章类型 文章类型,lyjh:路演精华 "`
  38. HavePublish int `description:"是否发布过,1是 ,0 否"`
  39. Source int `description:"来源 0策略平台同步,1小程序后台添加"`
  40. SellerAndMobile string `description:"销售和手机号"`
  41. VideoUrl string `description:"音频文件URL"`
  42. VideoName string `description:"音频文件名称"`
  43. VideoPlaySeconds string `description:"音频播放时长"`
  44. Stock string `description:"个股标签"`
  45. FieldName string `description:"产业标签"`
  46. SeriesName string `description:"系列名称"`
  47. Annotation string `description:"核心观点"`
  48. TypeName string `description:"策略平台报告类型"`
  49. ModifyTimeByCl string `description:"策略平台报告更新时间"`
  50. CeLueFieldId int `description:"策略平台领域ID"`
  51. Cover string `description:"封面图片"`
  52. ReportId int `description:"FICC研报ID"`
  53. CreateTime time.Time `description:"创建时间"`
  54. ChartPermissionId int `description:"行业id"`
  55. ChartPermissionName string `description:"行业名称"`
  56. ArticleSearchContent string `description:"搜索匹配用的内容"`
  57. }
  58. type CygxArticleEs struct {
  59. Id int `orm:"column(id);pk"`
  60. ArticleId int `description:"文章id"`
  61. Title string `description:"标题"`
  62. TitleEn string `description:"英文标题 "`
  63. UpdateFrequency string `description:"更新周期"`
  64. CreateDate string `description:"创建时间"`
  65. PublishDate string `description:"发布时间"`
  66. Body string `description:"内容"`
  67. BodyText string `description:"内容"`
  68. Abstract string `description:"摘要"`
  69. CategoryName string `description:"一级分类"`
  70. SubCategoryName string `description:"二级分类"`
  71. PublishStatus int `description:"发布状态"`
  72. CategoryId string `description:"分类id"`
  73. ExpertBackground string `description:"专家背景"`
  74. ExpertNumber string `description:"专家编号"`
  75. InterviewDate string `description:"访谈日期"`
  76. Department string `description:"作者"`
  77. ArticleIdMd5 string `description:"ID,md5值"`
  78. IsClass int `description:"是否归类,1是,0否"`
  79. IsSummary bool `description:"是否是纪要库,1是,0否"`
  80. IsReport bool `description:"是否属于报告,1是,0否"`
  81. ReportType int `description:"报告类型,1行业报告,2产业报告,0无"`
  82. FileLink string `description:"下载预览链接"`
  83. MatchTypeName string `description:"匹配类型"`
  84. }
  85. type CygxArticleIdReq struct {
  86. ArticleId int `description:"文章id"`
  87. }
  88. // 新增文章
  89. func AddCygxArticle(item *CygxArticle) (lastId int64, err error) {
  90. o := orm.NewOrm()
  91. lastId, err = o.Insert(item)
  92. return
  93. }
  94. type HomeArticle struct {
  95. ArticleId int `description:"文章id"`
  96. Title string `description:"标题"`
  97. TitleEn string `description:"英文标题 "`
  98. UpdateFrequency string `description:"更新周期"`
  99. CreateDate string `description:"创建时间"`
  100. PublishDate string `description:"发布时间"`
  101. Body string `description:"内容"`
  102. BodyHtml string `description:"内容带有HTML标签"`
  103. Abstract string `description:"摘要"`
  104. CategoryName string `description:"一级分类"`
  105. SubCategoryName string `description:"二级分类"`
  106. ExpertBackground string `description:"专家背景"`
  107. IsResearch bool `description:"是否属于研选"`
  108. Pv int `description:"PV"`
  109. ImgUrlPc string `description:"图片链接"`
  110. CategoryId string `description:"文章分类"`
  111. HttpUrl string `description:"文章链接跳转地址"`
  112. IsNeedJump bool `description:"是否需要跳转链接地址"`
  113. Source int `description:"来源 1:文章, 2:图表"`
  114. Annotation string `description:"核心观点"`
  115. HomeType int `description:"数据类型:0-纪要(默认); 1-微路演音频"`
  116. MicroAudio *MicroAudioUnionList `description:"微路演音频"`
  117. ChartPermissionName string `description:"权限名称"`
  118. ArticleTypeName string `description:"权限名称"`
  119. IsReport int `description:"是否属于报告,1是,0否"`
  120. ArticleResponse int `description:"报告类型 0:啥也不是,1研选报告,2:研选纪要,3:研选沙龙,4;研选观点"`
  121. Readnum int `description:"阅读数量"`
  122. Cover string `description:"封面图片"`
  123. BodyHighlight []string `description:"搜索高亮展示结果"`
  124. ArticleTypeId int `description:"文章类型ID"`
  125. ReportId int `description:"FICC研报ID"`
  126. Resource int `description:"来源类型,1:文章、2:产品内测"`
  127. IsCollect bool `description:"本人是否收藏"`
  128. CollectNum int `description:"收藏人数"`
  129. IsShowAbstract bool `description:"是否展示摘要"`
  130. List []*IndustrialManagementIdInt
  131. }
  132. type ArticleDetail struct {
  133. ArticleId int `description:"报告id"`
  134. Title string `description:"标题"`
  135. TitleEn string `description:"英文标题 "`
  136. UpdateFrequency string `description:"更新周期"`
  137. CreateDate string `description:"创建时间"`
  138. PublishDate string `description:"发布时间"`
  139. Body string `description:"内容"`
  140. Abstract string `description:"摘要"`
  141. CategoryName string `description:"一级分类"`
  142. SubCategoryName string `description:"二级分类"`
  143. IsCollect bool `description:"是否收藏:true,已收藏,false:未收藏"`
  144. IsInterviewApply bool `description:"是否申请访谈:true,已申请,false:未申请"`
  145. BodyText string `description:"内容"`
  146. InterviewApplyStatus string `description:"当前访谈申请状态:'待邀请','待访谈','已完成','已取消'"`
  147. InterviewDate string `description:"访谈时间"`
  148. ExpertBackground string `description:"专家背景"`
  149. ExpertNumber string `description:"专家编号"`
  150. Department string `description:"作者"`
  151. SellerMobile string `description:"销售手机号"`
  152. SellerName string `description:"销售名称"`
  153. ArticleIdMd5 string `description:"纪要id"`
  154. IsClass int `description:"是否归类,1是,0否"`
  155. CategoryId int `description:"分类ID"`
  156. IsSummary int `description:"是否是纪要库,1是,0否"`
  157. IsReport int `description:"是否属于报告,1是,0否"`
  158. IsResearch bool `description:"是否属于研选"`
  159. FileLink string `description:"下载预览链接"`
  160. SellerAndMobile string `description:"销售和手机号"`
  161. IsFollow bool `description:"是否关注,1是,0否"`
  162. IsBelongSummary bool `description:"是否属于纪要库"`
  163. IsBelongReport bool `description:"是否属于报告"`
  164. FollowNum int `description:"关注数量"`
  165. CollectionNum int `description:"收藏数量"`
  166. DepartmentId int `description:"作者ID"`
  167. DepartmentImgUrl string `description:"作者头像"`
  168. NickName string `description:"作者昵称"`
  169. SubjectIds string `description:"文章关联标的的ID字符串"`
  170. IndustrialAndSubjectIds string `description:"文章关联产业和标的的ID字符串"`
  171. IndustrialManagementId int `description:"文章关联产业ID"`
  172. SellerList []*SellerRep
  173. HttpUrl string `description:"文章链接跳转地址"`
  174. IsNeedJump bool `description:"是否需要跳转链接地址"`
  175. ReportLink string `description:"报告链接"`
  176. IsShowLinkButton int `description:"这种报告类型是否展示查看报告链接"`
  177. ArticleTypeId int `description:"文章类型ID"`
  178. IsSpecialArticle bool `description:"是否属于专项调研报告"`
  179. Annotation string `description:"核心观点"`
  180. IsShowFollowButton bool `description:"是否展示关注取关按钮"`
  181. IsFollowButton bool `description:"是否关注"`
  182. IsRoadShow bool `description:"是否是路演精华"`
  183. ReportType int `description:"报告类型,1行业报告,2产业报告,0无"`
  184. FieldName string `description:"策略平台的领域字段名称"`
  185. TypeName string `description:"策略平台类型字段名称"`
  186. IsApplyAppointmentExpert bool `description:"是否属于专家访谈"`
  187. ArticleTypeName string `description:"权限名称"`
  188. MatchTypeName string `description:"匹配类型"`
  189. Stock string `description:"个股标签"`
  190. Frequency string `description:"更新周期(策略平台字段)"`
  191. SeriesName string `description:"系列名称(策略平台字段)"`
  192. }
  193. type ArticleDetailFileLink struct {
  194. FileLink string `description:"下载预览链接"`
  195. Scene string `description:"资源参数"`
  196. }
  197. type SellerRep struct {
  198. SellerMobile string `description:"销售手机号"`
  199. SellerName string `description:"销售名称"`
  200. }
  201. func GetArticleDetailById(articleId int) (item *ArticleDetail, err error) {
  202. o := orm.NewOrm()
  203. sql := `SELECT * FROM cygx_article WHERE article_id = ? AND publish_status = 1 `
  204. err = o.Raw(sql, articleId).QueryRow(&item)
  205. return
  206. }
  207. func GetArticleDetailByReportId(reportId int) (item *ArticleDetail, err error) {
  208. o := orm.NewOrm()
  209. sql := `SELECT * FROM cygx_article WHERE report_id = ? AND publish_status = 1 `
  210. err = o.Raw(sql, reportId).QueryRow(&item)
  211. return
  212. }
  213. func GetSellerList(articleId int) (items []*SellerRep, err error) {
  214. o := orm.NewOrm()
  215. sql := `SELECT
  216. au.mobile as seller_mobile,
  217. au.name as seller_name
  218. FROM
  219. cygx_article_author AS au
  220. WHERE article_id = ?`
  221. _, err = o.Raw(sql, articleId).QueryRows(&items)
  222. return
  223. }
  224. func GetArticleDetailByIdMd5(articleIdMd5 string) (item *ArticleDetail, err error) {
  225. o := orm.NewOrm()
  226. sql := `SELECT * FROM cygx_article WHERE article_id_md5 = ? `
  227. err = o.Raw(sql, articleIdMd5).QueryRow(&item)
  228. return
  229. }
  230. func GetArticleDetailByIdStr(articleIdStr string) (items []*ArticleDetail, err error) {
  231. o := orm.NewOrm()
  232. sql := `SELECT art.*,d.nick_name FROM
  233. cygx_article AS art
  234. LEFT JOIN cygx_article_department AS d ON d.department_id = art.department_id WHERE article_id IN(` + articleIdStr + `) `
  235. _, err = o.Raw(sql).QueryRows(&items)
  236. return
  237. }
  238. func GetArticlePermission(companyId int) (item *ChartPermissionItemResp, err error) {
  239. o := orm.NewOrm()
  240. sql := `SELECT
  241. a.chart_permission_name as permission_name,a.match_type_name
  242. FROM
  243. cygx_report_mapping AS a
  244. WHERE
  245. a.category_id = ? LIMIT 1 `
  246. err = o.Raw(sql, companyId).QueryRow(&item)
  247. //_, err = o.Raw(sql, companyId).QueryRows(&item)
  248. return
  249. }
  250. type ArticleDetailResp struct {
  251. Detail *ArticleDetail
  252. HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
  253. HasFree int `description:"1:已付费(至少包含一个品类的权限),2:未付费(没有任何品类权限)"`
  254. HaveResearch bool `description:"是否有研选权限"`
  255. Mobile string `description:"用户手机号"`
  256. PopupMsg string `description:"权限弹窗信息"`
  257. SellerMobile string `description:"销售电话"`
  258. SellerName string `description:"销售姓名"`
  259. IsSpecialArticle bool `description:"是否属于专项调研报告"`
  260. IsResearch bool `description:"是否属于研选"`
  261. }
  262. type ArticleDetailHtgjResp struct {
  263. HasPermission int `description:"1:有该行业权限,正常展示,0:试用期已过期"`
  264. CompanyName string `description:"公司名称"`
  265. Detail *ArticleDetail
  266. }
  267. func ModifyArticleExpert(articleId int, expertNumStr, expertContentStr, interviewDateStr, bodyText string) (err error) {
  268. o := orm.NewOrm()
  269. sql := `UPDATE cygx_article SET expert_background=?,expert_number=?,interview_date=?,body_text=? WHERE article_id=? `
  270. _, err = o.Raw(sql, expertContentStr, expertNumStr, interviewDateStr, bodyText, articleId).Exec()
  271. return
  272. }
  273. // 更改文章发布状态
  274. func UpdateArticlePublish(articleId, publishStatus int) (err error) {
  275. o := orm.NewOrm()
  276. sql := `UPDATE cygx_article SET publish_status=? WHERE article_id=? `
  277. _, err = o.Raw(sql, publishStatus, articleId).Exec()
  278. return
  279. }
  280. type ArticleDetailTest struct {
  281. ArticleId int `description:"报告id"`
  282. Title string `description:"标题"`
  283. BodyText string `description:"内容"`
  284. Body string `json:"-" description:"内容"`
  285. }
  286. func GetArticleDetailTestById(articleId int) (item *ArticleDetail, err error) {
  287. o := orm.NewOrm()
  288. sql := `SELECT * FROM cygx_article WHERE article_id = ? `
  289. err = o.Raw(sql, articleId).QueryRow(&item)
  290. return
  291. }
  292. func GetArticleAll() (item []*ArticleDetail, err error) {
  293. o := orm.NewOrm()
  294. //sql := `SELECT * FROM cygx_article WHERE 1=1 is_summary=1`
  295. sql := `SELECT * FROM cygx_article WHERE 1=1 AND publish_status = 1 `
  296. _, err = o.Raw(sql).QueryRows(&item)
  297. return
  298. }
  299. func GetArticleAllDate(endDate string) (item []*ArticleDetail, err error) {
  300. o := orm.NewOrm()
  301. //sql := `SELECT * FROM cygx_article WHERE is_summary=1 AND publish_date >= ? `
  302. sql := `SELECT * FROM cygx_article WHERE 1=1 AND publish_date >= ? `
  303. _, err = o.Raw(sql, endDate).QueryRows(&item)
  304. return
  305. }
  306. func GetArticleAll2() (item []*ArticleDetail, err error) {
  307. o := orm.NewOrm()
  308. sql := `SELECT * FROM cygx_article `
  309. _, err = o.Raw(sql).QueryRows(&item)
  310. return
  311. }
  312. // 获取文章列表
  313. func GetArticleList(condition string, pars []interface{}) (items []*ArticleDetail, err error) {
  314. o := orm.NewOrm()
  315. sql := `SELECT * FROM cygx_article WHERE 1= 1 ` + condition
  316. _, err = o.Raw(sql, pars).QueryRows(&items)
  317. return
  318. }
  319. // 获取文章列表
  320. func GetArticleListHomeTag(condition string, pars []interface{}) (items []*ArticleDetail, err error) {
  321. o := orm.NewOrm()
  322. sql := `SELECT article_id,stock FROM cygx_article WHERE 1= 1 ` + condition
  323. _, err = o.Raw(sql, pars).QueryRows(&items)
  324. return
  325. }
  326. func ModifyArticleContent(articleId int, content, expertNumStr, expertContentStr, interviewDateStr string) (err error) {
  327. o := orm.NewOrm()
  328. sql := `UPDATE cygx_article SET body=?,expert_background=?,expert_number=?,interview_date=? WHERE article_id=? `
  329. _, err = o.Raw(sql, content, expertContentStr, expertNumStr, interviewDateStr, articleId).Exec()
  330. return
  331. }
  332. type ElasticArticleDetail struct {
  333. ArticleId int `description:"报告id"`
  334. Title string `description:"标题"`
  335. TitleEn string `description:"英文标题 "`
  336. UpdateFrequency string `description:"更新周期"`
  337. CreateDate string `description:"创建时间"`
  338. PublishDate string `description:"发布时间"`
  339. Abstract string `description:"摘要"`
  340. CategoryName string `description:"一级分类"`
  341. SubCategoryName string `description:"二级分类"`
  342. IsCollect bool `description:"是否收藏:true,已收藏,false:未收藏"`
  343. IsInterviewApply bool `description:"是否申请访谈:true,已申请,false:未申请"`
  344. BodyText string `description:"内容"`
  345. InterviewApplyStatus string `description:"当前访谈申请状态:'待邀请','待访谈','已完成','已取消'"`
  346. InterviewDate string `description:"访谈时间"`
  347. ExpertBackground string `description:"专家背景"`
  348. ExpertNumber string `description:"专家编号"`
  349. Department string `description:"作者"`
  350. SellerMobile string `description:"销售手机号"`
  351. SellerName string `description:"销售名称"`
  352. ArticleIdMd5 string `description:"纪要id"`
  353. }
  354. func GetArticleCountById(articleId int) (count int, err error) {
  355. o := orm.NewOrm()
  356. sql := `SELECT COUNT(1) AS count FROM cygx_article WHERE article_id = ? `
  357. err = o.Raw(sql, articleId).QueryRow(&count)
  358. return
  359. }
  360. type CygxArticles struct {
  361. Id int `orm:"column(id);pk"`
  362. ArticleId int `description:"文章id"`
  363. Title string `description:"标题"`
  364. TitleEn string `description:"英文标题 "`
  365. UpdateFrequency string `description:"更新周期"`
  366. CreateDate string `description:"创建时间"`
  367. PublishDate string `description:"发布时间"`
  368. Body string `description:"内容"`
  369. BodyText string `description:"内容"`
  370. Abstract string `description:"摘要"`
  371. CategoryName string `description:"一级分类"`
  372. SubCategoryName string `description:"二级分类"`
  373. PublishStatus int `description:"发布状态"`
  374. CategoryId int `description:"分类id"`
  375. ExpertBackground string `description:"专家背景"`
  376. ExpertNumber string `description:"专家编号"`
  377. InterviewDate string `description:"访谈日期"`
  378. Department string `description:"作者"`
  379. ArticleIdMd5 string `description:"ID,md5值"`
  380. IsClass int `description:"是否归类,1是,0否"`
  381. IsSummary int `description:"是否是纪要库,1是,0否"`
  382. IsReport int `description:"是否属于报告,1是,0否"`
  383. ReportType int `description:"报告类型,1行业报告,2产业报告,0无"`
  384. }
  385. // 新增文章
  386. func AddCygxArticles(item *CygxArticle) (lastId int64, err error) {
  387. o := orm.NewOrm()
  388. lastId, err = o.Insert(item)
  389. return
  390. }
  391. func GetPermissionMappingById(categoryId int) (count int, err error) {
  392. o := orm.NewOrm()
  393. sql := `SELECT COUNT(1) AS count FROM cygx_permission_mapping WHERE category_id = ? `
  394. err = o.Raw(sql, categoryId).QueryRow(&count)
  395. return
  396. }
  397. func GetReportMappingById(categoryId int) (count int, err error) {
  398. o := orm.NewOrm()
  399. sql := `SELECT COUNT(1) AS count FROM cygx_report_mapping WHERE category_id = ? `
  400. err = o.Raw(sql, categoryId).QueryRow(&count)
  401. return
  402. }
  403. type ReportArticle struct {
  404. ArticleId int `description:"文章id"`
  405. ReportId int `description:"文章id"`
  406. Title string `description:"标题"`
  407. TitleEn string `description:"英文标题 "`
  408. UpdateFrequency string `description:"更新周期"`
  409. CreateDate string `description:"创建时间"`
  410. PublishDate string `description:"发布时间"`
  411. Body string `description:"内容"`
  412. Abstract string `description:"摘要"`
  413. CategoryName string `description:"一级分类"`
  414. SubCategoryName string `description:"二级分类"`
  415. ExpertBackground string `description:"专家背景"`
  416. IsRed bool `description:"是否标记红点"`
  417. Readnum int `description:"阅读数量"`
  418. VideoUrl string `description:"链接"`
  419. IsHaveVideo bool `description:"是否含有音频文件"`
  420. ImgUrlPc string `description:"图片链接"`
  421. CategoryId string `description:"文章分类"`
  422. Annotation string `description:"核心观点"`
  423. Resource int `description:"来源类型,1:文章、2:产品内测"`
  424. MyCollectNum int `description:"本人是否收藏"`
  425. IsCollect bool `description:"本人是否收藏"`
  426. Pv int `description:"PV"`
  427. CollectNum int `description:"收藏人数"`
  428. IsShowAbstract bool `description:"是否展示摘要"`
  429. }
  430. type ReportMappingCategoryRep struct {
  431. CategoryId int `description:"文章分类id"`
  432. }
  433. func GetReportMappingCategoryID() (item []*ReportMappingCategoryRep, err error) {
  434. o := orm.NewOrm()
  435. sql := ` SELECT category_id FROM cygx_permission_mapping GROUP BY category_id `
  436. _, err = o.Raw(sql).QueryRows(&item)
  437. return
  438. }
  439. type PermissionMappingCategoryRep struct {
  440. CategoryId int `description:"文章分类id"`
  441. }
  442. func GetPermissionMappingCategoryID() (item []*PermissionMappingCategoryRep, err error) {
  443. o := orm.NewOrm()
  444. sql := ` SELECT category_id FROM cygx_report_mapping GROUP BY category_id `
  445. _, err = o.Raw(sql).QueryRows(&item)
  446. return
  447. }
  448. // 检查用户是否阅读某一分类最新文章
  449. func GetUserIsReadThisNewCategoryArticleCount(categoryId, uid int) (count int, err error) {
  450. sqlCount := `SELECT
  451. COUNT( 1 ) AS count
  452. FROM
  453. cygx_article_history_record
  454. WHERE
  455. article_id = ( SELECT article_id FROM cygx_article WHERE category_id IN ( SELECT category_id_celue FROM cygx_report_mapping_group WHERE id_cygx = ? ) ORDER BY publish_date DESC LIMIT 0, 1 )
  456. AND user_id = ?`
  457. o := orm.NewOrm()
  458. err = o.Raw(sqlCount, categoryId, uid).QueryRow(&count)
  459. return
  460. }
  461. type ArticleId struct {
  462. ArticleId int `description:"文章id"`
  463. }
  464. type ArticleIdAndTitle struct {
  465. Title string `description:"标题"`
  466. ArticleId int `description:"文章id"`
  467. }
  468. // 获取自定义分类的文章ID
  469. func GetCustomArticleId() (item []*ArticleId, err error) {
  470. o := orm.NewOrm()
  471. sql := ` SELECT article_id FROM cygx_article WHERE is_custom = 1 `
  472. _, err = o.Raw(sql).QueryRows(&item)
  473. return
  474. }
  475. type ArticleFollowDetail struct {
  476. DNum int `description:"作者被关注的数量"`
  477. MdNum int `description:"本人是否关注这个作者"`
  478. AcNum int `description:"文章被收藏的数量"`
  479. MacNum int `description:"本人是否收藏这个文章"`
  480. }
  481. // 获取文章被关注被收藏的详情
  482. func GetArticleFollowDetail(articleId, uid int) (item *ArticleFollowDetail, err error) {
  483. //d_num 作者被关注的数量 、 md_num 本人是否关注这个作者 、ac_num 文章被收藏的数量 、 mac_num 本人是否收藏这个文章
  484. o := orm.NewOrm()
  485. sql := ` SELECT
  486. ( SELECT count( 1 ) FROM cygx_article_department_follow AS af WHERE af.department_id = art.department_id AND af.type = 1 ) AS d_num,
  487. ( SELECT count( 1 ) FROM cygx_article_department_follow AS af WHERE af.department_id = art.department_id AND af.type = 1 AND af.user_id = ? ) AS md_num,
  488. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = art.article_id ) AS ac_num,
  489. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = art.article_id AND ac.user_id = ? ) AS mac_num
  490. FROM
  491. cygx_article AS art
  492. LEFT JOIN cygx_article_department_follow AS af ON af.department_id = art.department_id
  493. LEFT JOIN cygx_article_collect AS ac ON ac.article_id = art.article_id
  494. WHERE
  495. art.article_id = ?
  496. GROUP BY art.article_id `
  497. err = o.Raw(sql, uid, uid, articleId).QueryRow(&item)
  498. return
  499. }
  500. // 日度点评的数据同步
  501. type ReportDetail struct {
  502. Id int `orm:"column(id)" description:"报告Id"`
  503. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  504. ClassifyIdFirst int `description:"一级分类id"`
  505. ClassifyNameFirst string `description:"一级分类名称"`
  506. ClassifyIdSecond int `description:"二级分类id"`
  507. ClassifyNameSecond string `description:"二级分类名称"`
  508. Title string `description:"标题"`
  509. Abstract string `description:"摘要"`
  510. Author string `description:"作者"`
  511. Frequency string `description:"频度"`
  512. CreateTime string `description:"创建时间"`
  513. ModifyTime string `description:"修改时间"`
  514. State int `description:"1:未发布,2:已发布"`
  515. PublishTime string `description:"发布时间"`
  516. Stage int `description:"期数"`
  517. MsgIsSend int `description:"消息是否已发送,0:否,1:是"`
  518. Content string `description:"内容"`
  519. VideoUrl string `description:"音频文件URL"`
  520. VideoName string `description:"音频文件名称"`
  521. VideoPlaySeconds string `description:"音频播放时长"`
  522. ContentSub string `description:"内容前两个章节"`
  523. }
  524. func GetReportList() (items []*ReportDetail, err error) {
  525. o := orm.NewOrmUsingDB("rddp")
  526. sql := `SELECT * FROM report WHERE classify_id_second = '57'`
  527. _, err = o.Raw(sql).QueryRows(&items)
  528. return
  529. }
  530. func GetMaxArticleIdInfo() (item *ArticleDetail, err error) {
  531. o := orm.NewOrm()
  532. sql := `SELECT * FROM cygx_article ORDER BY article_id desc LIMIT 1`
  533. err = o.Raw(sql).QueryRow(&item)
  534. return
  535. }
  536. type ArticleResultApi struct {
  537. Data []ArticleResultApidate `json:"data"`
  538. Code int `json:"code"`
  539. Msg string `json:"msg"`
  540. }
  541. type ArticleDetailResultApi struct {
  542. Data ArticleResultApidate `json:"data"`
  543. Code int `json:"code"`
  544. Msg string `json:"msg"`
  545. }
  546. type ArticleResultApidate struct {
  547. ArticleId int `json:"id"`
  548. Title string `json:"title"`
  549. File string `json:"file"`
  550. TitleEn string `json:"title_en"`
  551. Frequency string `json:"frequency"`
  552. CreateDate string `json:"create_date"`
  553. UpdateDate string `json:"update_date"`
  554. PublishDate time.Time `json:"publish_date"`
  555. PublishStatus int `json:"publish_status"`
  556. IndustrId int `json:"industry_id"`
  557. SeriesId int `json:"series_id"`
  558. Series ArticleSeries `json:"series"`
  559. Content ArticleResultApiContent `json:"content"`
  560. Author ArticleResultApiAuthor `json:"author"`
  561. Industry ArticleResultApiIndustry `json:"industry"`
  562. Type ArticleResultApiType `json:"type"`
  563. Stock []string `json:"stock"`
  564. Field ArticleField `json:"field"`
  565. Corpus Corpus `json:"corpus"`
  566. Cover string `json:"cover"`
  567. TypeId int `json:"type_id"`
  568. IsActive bool `json:"is_active"`
  569. PublishArea string `json:"publish_area"`
  570. }
  571. type ArticleField struct {
  572. Id int `json:"id"`
  573. Name string `json:"name"`
  574. Description string `json:"description"`
  575. IndustryId int `json:"industry_id"`
  576. }
  577. type Corpus struct {
  578. Id int `json:"id"`
  579. ArticleId int `json:"article_id"`
  580. Corpus string `json:"corpus"`
  581. }
  582. type ArticleSeries struct {
  583. Name string `json:"name"`
  584. }
  585. type ArticleResultApiContent struct {
  586. ArticleId int `json:"id"`
  587. Body string `json:"body"`
  588. Abstract string `json:"abstract"`
  589. Annotation string `json:"annotation"`
  590. }
  591. type ArticleResultApiAuthor struct {
  592. PhoneNumber string `json:"phone_number"`
  593. Name string `json:"name"`
  594. }
  595. type ArticleResultApiIndustry struct {
  596. Name string `json:"name"`
  597. }
  598. type ArticleResultApiType struct {
  599. Name string `json:"name"`
  600. }
  601. type ArticleIndustryApi struct {
  602. Data []ArticleResultApiIndustrdate `json:"data"`
  603. Code int `json:"code"`
  604. Msg string `json:"msg"`
  605. }
  606. type ArticleResultApiIndustrdate struct {
  607. Id int `json:"id"`
  608. Name string `json:"name"`
  609. Series []ArticleResultApiSeriesdate `json:"series"`
  610. }
  611. type ArticleResultApiSeriesdate struct {
  612. Id int `json:"id"`
  613. Name string `json:"name"`
  614. }
  615. type ArticleApiMap struct {
  616. Id int `description:"新ID"`
  617. OldId int `description:"旧Id"`
  618. IsClass int `description:"是否自动归类,1是,0否"`
  619. IsReport int `description:"是否属于报告,1是,0否"`
  620. IsSummary int `description:"是否属于纪要,1是,0否"`
  621. SeriesId int `description:"策略平台那边的报告分类ID"`
  622. OldIdMap int `description:"策略平台老的分类ID样式map映射"`
  623. }
  624. func GetArticleApiMap() (item []*ArticleApiMap, err error) {
  625. o := orm.NewOrm()
  626. sql := ` SELECT * FROM cygx_article_api_map WHERE old_id > 0 AND is_update = 1 ORDER BY old_id ASC `
  627. _, err = o.Raw(sql).QueryRows(&item)
  628. return
  629. }
  630. func GetArticleIdSubjectGroup(keyWord string) (articleid string, err error) {
  631. o := orm.NewOrm()
  632. sql := ` SELECT
  633. GROUP_CONCAT(DISTINCT art.article_id SEPARATOR ',') AS articleid
  634. FROM
  635. cygx_article AS art
  636. INNER JOIN cygx_industrial_article_group_subject AS sg ON sg.article_id = art.article_id
  637. INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = sg.industrial_subject_id
  638. WHERE
  639. s.subject_name LIKE '%` + keyWord + `%' `
  640. err = o.Raw(sql).QueryRow(&articleid)
  641. return
  642. }
  643. func GetArticleIndustrialIdGroup(keyWord string) (articleid string, err error) {
  644. o := orm.NewOrm()
  645. sql := ` SELECT
  646. GROUP_CONCAT(DISTINCT art.article_id SEPARATOR ',') AS article_id
  647. FROM
  648. cygx_article AS art
  649. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = art.article_id
  650. INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  651. WHERE
  652. m.industry_name LIKE '%` + keyWord + `%' `
  653. err = o.Raw(sql).QueryRow(&articleid)
  654. return
  655. }
  656. // 通过文章ID获取文章所关联的标的ID
  657. func GetSubjectIds(articleId int) (subjects string, err error) {
  658. sql := ` SELECT
  659. GROUP_CONCAT( DISTINCT industrial_subject_id ORDER BY id ASC SEPARATOR ',' ) AS subjects
  660. FROM
  661. cygx_industrial_article_group_subject WHERE article_id = ?`
  662. o := orm.NewOrm()
  663. err = o.Raw(sql, articleId).QueryRow(&subjects)
  664. return
  665. }
  666. // 修改发布状态
  667. func UpdateIsClassFail(articleId int) (err error) {
  668. sql := `UPDATE cygx_article SET is_class_fail=1 WHERE article_id=? `
  669. o := orm.NewOrm()
  670. _, err = o.Raw(sql, articleId).Exec()
  671. return
  672. }
  673. type SummaryArticleStock struct {
  674. Id int `description:"新ID"`
  675. ArticleId int `description:"文章id"`
  676. Stock string `description:"个股标签"`
  677. }
  678. // 综述报告
  679. func GetSummaryArticle(chartPermissionId int) (items []*SummaryArticleStock, err error) {
  680. o := orm.NewOrm()
  681. sql := `SELECT
  682. *
  683. FROM
  684. cygx_article AS c
  685. INNER JOIN cygx_report_mapping AS m
  686. WHERE
  687. c.type_name = '综述报告'
  688. AND m.category_id = c.category_id_two
  689. AND m.chart_permission_id = ? ORDER BY modify_time_by_cl DESC `
  690. _, err = o.Raw(sql, chartPermissionId).QueryRows(&items)
  691. return
  692. }
  693. type SummaryArticleStockResp struct {
  694. List []*SummaryArticleStock
  695. }
  696. // 综述报告
  697. func GetArticleStock() (items []*SummaryArticleStock, err error) {
  698. o := orm.NewOrm()
  699. sql := `SELECT
  700. stock,article_id
  701. FROM
  702. cygx_article AS art
  703. WHERE
  704. 1 = 1
  705. AND type_name = '综述报告' `
  706. _, err = o.Raw(sql).QueryRows(&items)
  707. return
  708. }
  709. // 列表
  710. func GetCygxCygxArticleList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxArticle, err error) {
  711. o := orm.NewOrm()
  712. sql := `SELECT * FROM cygx_article as art WHERE 1= 1 `
  713. if condition != "" {
  714. sql += condition
  715. }
  716. sql += ` LIMIT ?,? `
  717. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  718. return
  719. }
  720. func ModifyArticleTitleByarticleId(articleId int, title string) (err error) {
  721. o := orm.NewOrm()
  722. sql := `UPDATE cygx_article SET title= ? WHERE article_id=? `
  723. _, err = o.Raw(sql, title, articleId).Exec()
  724. return
  725. }
  726. // 获取数量
  727. func GetCygxArticleCount(condition string, pars []interface{}) (count int, err error) {
  728. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_article as art WHERE 1= 1 `
  729. if condition != "" {
  730. sqlCount += condition
  731. }
  732. o := orm.NewOrm()
  733. err = o.Raw(sqlCount, pars).QueryRow(&count)
  734. return
  735. }
  736. // 列表
  737. func GetCygxCygxArticleListByCondition(articleTypesCond, activityTypesCond, industryStr, subjectNameStr, articleTypeStr string) (artIds, actIds, mmIds string, err error) {
  738. o := orm.NewOrm()
  739. artSql := `SELECT GROUP_CONCAT(DISTINCT art.article_id SEPARATOR ',') AS art_ids FROM cygx_article as art `
  740. actSql := ` SELECT GROUP_CONCAT(DISTINCT act.activity_id SEPARATOR ',') AS act_ids FROM cygx_activity as act `
  741. mmSql := ` SELECT GROUP_CONCAT(DISTINCT mmc.id SEPARATOR ',') AS mm_ids FROM cygx_morning_meeting_review_chapter as mmc `
  742. if industryStr != "" {
  743. artSql += ` INNER JOIN cygx_industrial_article_group_management AS iam ON iam.article_id = art.article_id
  744. INNER JOIN cygx_industrial_management AS im ON im.industrial_management_id=iam.industrial_management_id `
  745. actSql += ` INNER JOIN cygx_industrial_activity_group_management AS iam ON iam.activity_id = act.activity_id
  746. INNER JOIN cygx_industrial_management AS im ON im.industrial_management_id=iam.industrial_management_id `
  747. mmSql += ` INNER JOIN cygx_morning_meeting_reviews AS mm ON mmc.meeting_id = mm.id
  748. INNER JOIN cygx_industrial_management AS im ON im.industrial_management_id=mmc.industry_id `
  749. }
  750. if subjectNameStr != "" {
  751. artSql += ` INNER JOIN cygx_industrial_article_group_subject AS ias ON ias.article_id = art.article_id
  752. INNER JOIN cygx_industrial_subject AS cis ON cis.industrial_subject_id=ias.industrial_subject_id `
  753. actSql += ` INNER JOIN cygx_industrial_activity_group_subject AS ias ON ias.activity_id = act.activity_id
  754. INNER JOIN cygx_industrial_subject AS cis ON cis.industrial_subject_id=ias.industrial_subject_id `
  755. mmSql += ` IINNER JOIN cygx_morning_meeting_reviews AS mm ON mmc.meeting_id = mm.id
  756. INNER JOIN cygx_industrial_subject AS cis ON cis.industrial_subject_id=mmc.industrial_subject_ids `
  757. }
  758. artSql += ` WHERE 1=1 `
  759. if articleTypesCond != "" || (articleTypesCond == "" && activityTypesCond == "") {
  760. if industryStr != "" && subjectNameStr != "" {
  761. artSql += articleTypesCond + ` AND (im.industry_name In (` + industryStr + `) OR cis.subject_name In (` + subjectNameStr + `) )`
  762. } else if industryStr == "" && subjectNameStr != "" {
  763. artSql += articleTypesCond + ` AND cis.subject_name In (` + subjectNameStr + `) `
  764. } else if industryStr != "" && subjectNameStr == "" {
  765. artSql += articleTypesCond + ` AND im.industry_name In (` + industryStr + `) `
  766. } else {
  767. artSql += articleTypesCond
  768. }
  769. err = o.Raw(artSql).QueryRow(&artIds)
  770. }
  771. actSql += ` WHERE 1=1 `
  772. if activityTypesCond != "" || (articleTypesCond == "" && activityTypesCond == "") {
  773. if industryStr != "" && subjectNameStr != "" {
  774. actSql += activityTypesCond + ` AND (im.industry_name In (` + industryStr + `) OR cis.subject_name In (` + subjectNameStr + `) )`
  775. } else if industryStr == "" && subjectNameStr != "" {
  776. actSql += activityTypesCond + ` AND cis.subject_name In (` + subjectNameStr + `) `
  777. } else if industryStr != "" && subjectNameStr == "" {
  778. actSql += activityTypesCond + ` AND im.industry_name In (` + industryStr + `) `
  779. } else {
  780. actSql += activityTypesCond
  781. }
  782. err = o.Raw(actSql).QueryRow(&actIds)
  783. }
  784. if strings.Contains(articleTypeStr, "晨会精华") {
  785. mmSql += ` WHERE 1=1 `
  786. if industryStr != "" && subjectNameStr != "" {
  787. mmSql += ` AND (im.industry_name In (` + industryStr + `) OR cis.subject_name In (` + subjectNameStr + `) )`
  788. } else if industryStr == "" && subjectNameStr != "" {
  789. mmSql += ` AND cis.subject_name In (` + subjectNameStr + `) `
  790. } else if industryStr != "" && subjectNameStr == "" {
  791. mmSql += ` AND im.industry_name In (` + industryStr + `) `
  792. }
  793. err = o.Raw(mmSql).QueryRow(&mmIds)
  794. }
  795. return
  796. }
  797. // 单个tag时用,取合集
  798. func GetCygxCygxArticleListByConditionSoloTag(articleTypeCondSlice, activityTypesCondSlice, industriesCondSlice, subjectNamesSlice, articleTypeSlice []string) (artIds, actIds, mmIds string, err error) {
  799. o := orm.NewOrm()
  800. artSql := `SELECT GROUP_CONCAT(DISTINCT art.article_id SEPARATOR ',') AS art_ids FROM cygx_article as art `
  801. actSql := ` SELECT GROUP_CONCAT(DISTINCT act.activity_id SEPARATOR ',') AS act_ids FROM cygx_activity as act `
  802. mmSql := ` SELECT GROUP_CONCAT(DISTINCT mmc.id SEPARATOR ',') AS mm_ids FROM cygx_morning_meeting_review_chapter as mmc `
  803. for _, s := range industriesCondSlice {
  804. if s != "" {
  805. artSql += ` INNER JOIN cygx_industrial_article_group_management AS iam ON iam.article_id = art.article_id
  806. INNER JOIN cygx_industrial_management AS im ON im.industrial_management_id=iam.industrial_management_id `
  807. actSql += ` INNER JOIN cygx_industrial_activity_group_management AS iam ON iam.activity_id = act.activity_id
  808. INNER JOIN cygx_industrial_management AS im ON im.industrial_management_id=iam.industrial_management_id `
  809. mmSql += ` INNER JOIN cygx_morning_meeting_reviews AS mm ON mmc.meeting_id = mm.id
  810. INNER JOIN cygx_industrial_management AS im ON im.industrial_management_id=mmc.industry_id `
  811. break
  812. }
  813. }
  814. for _, s := range subjectNamesSlice {
  815. if s != "" {
  816. artSql += ` INNER JOIN cygx_industrial_article_group_subject AS ias ON ias.article_id = art.article_id
  817. INNER JOIN cygx_industrial_subject AS cis ON cis.industrial_subject_id=ias.industrial_subject_id `
  818. actSql += ` INNER JOIN cygx_industrial_activity_group_subject AS ias ON ias.activity_id = act.activity_id
  819. INNER JOIN cygx_industrial_subject AS cis ON cis.industrial_subject_id=ias.industrial_subject_id `
  820. mmSql += ` IINNER JOIN cygx_morning_meeting_reviews AS mm ON mmc.meeting_id = mm.id
  821. INNER JOIN cygx_industrial_subject AS cis ON cis.industrial_subject_id=mmc.industrial_subject_ids `
  822. break
  823. }
  824. }
  825. artSql += ` WHERE 1=1 AND ((1=1 `
  826. actSql += ` WHERE 1=1 AND ((1=1 `
  827. mmSql += ` WHERE 1=1 AND ((1=1 `
  828. var isNeedArt, isNeedAct, isNeedMm bool
  829. for i, _ := range articleTypeCondSlice {
  830. articleTypesCond := articleTypeCondSlice[i]
  831. activityTypesCond := activityTypesCondSlice[i]
  832. industryStr := industriesCondSlice[i]
  833. subjectNameStr := subjectNamesSlice[i]
  834. articleTypeStr := articleTypeSlice[i]
  835. if articleTypesCond != "" || (articleTypesCond == "" && activityTypesCond == "") {
  836. if industryStr != "" && subjectNameStr != "" {
  837. artSql += articleTypesCond + ` AND (im.industry_name In (` + industryStr + `) OR cis.subject_name In (` + subjectNameStr + `) )`
  838. } else if industryStr == "" && subjectNameStr != "" {
  839. artSql += articleTypesCond + ` AND cis.subject_name In (` + subjectNameStr + `) `
  840. } else if industryStr != "" && subjectNameStr == "" {
  841. artSql += articleTypesCond + ` AND im.industry_name In (` + industryStr + `) `
  842. } else {
  843. artSql += articleTypesCond
  844. }
  845. if i == len(articleTypeCondSlice)-1 {
  846. artSql += `)) `
  847. } else {
  848. artSql += `) OR (1=1 `
  849. }
  850. isNeedArt = true
  851. }
  852. if activityTypesCond != "" || (articleTypesCond == "" && activityTypesCond == "") {
  853. if industryStr != "" && subjectNameStr != "" {
  854. actSql += activityTypesCond + ` AND (im.industry_name In (` + industryStr + `) OR cis.subject_name In (` + subjectNameStr + `) )`
  855. } else if industryStr == "" && subjectNameStr != "" {
  856. actSql += activityTypesCond + ` AND cis.subject_name In (` + subjectNameStr + `) `
  857. } else if industryStr != "" && subjectNameStr == "" {
  858. actSql += activityTypesCond + ` AND im.industry_name In (` + industryStr + `) `
  859. } else {
  860. actSql += activityTypesCond
  861. }
  862. if i == len(articleTypeCondSlice)-1 {
  863. actSql += `)) `
  864. } else {
  865. actSql += `) OR (1=1 `
  866. }
  867. isNeedAct = true
  868. }
  869. if strings.Contains(articleTypeStr, "晨会精华") {
  870. if industryStr != "" && subjectNameStr != "" {
  871. mmSql += ` AND (im.industry_name In (` + industryStr + `) OR cis.subject_name In (` + subjectNameStr + `) )`
  872. } else if industryStr == "" && subjectNameStr != "" {
  873. mmSql += ` AND cis.subject_name In (` + subjectNameStr + `) `
  874. } else if industryStr != "" && subjectNameStr == "" {
  875. mmSql += ` AND im.industry_name In (` + industryStr + `) `
  876. }
  877. if i == len(articleTypeCondSlice)-1 {
  878. mmSql += `)) `
  879. } else {
  880. mmSql += `) OR (1=1 `
  881. }
  882. isNeedMm = true
  883. }
  884. }
  885. if isNeedArt {
  886. err = o.Raw(artSql).QueryRow(&artIds)
  887. if err != nil {
  888. return
  889. }
  890. }
  891. if isNeedAct {
  892. err = o.Raw(actSql).QueryRow(&actIds)
  893. if err != nil {
  894. return
  895. }
  896. }
  897. if isNeedMm {
  898. err = o.Raw(mmSql).QueryRow(&mmIds)
  899. if err != nil {
  900. return
  901. }
  902. }
  903. return
  904. }
  905. // 获取文章列表
  906. func GetArticleInit13_5() (items []*ArticleDetail, err error) {
  907. o := orm.NewOrm()
  908. sql := `SELECT
  909. art.title,
  910. art.article_id,
  911. art.category_id,
  912. art.publish_date,
  913. art.is_class,
  914. art.publish_status,
  915. art.is_filter,
  916. art.stock,
  917. art.field_name,
  918. art.id,
  919. art.article_id_md5,
  920. re.chart_permission_name,
  921. re.match_type_name,
  922. art.sub_category_name,
  923. re.chart_permission_id
  924. FROM
  925. cygx_article AS art
  926. LEFT JOIN cygx_report_mapping AS ret ON ret.category_id = art.category_id_two
  927. LEFT JOIN cygx_report_mapping AS re ON re.category_id = art.category_id
  928. LEFT JOIN cygx_industrial_article_group_management AS man ON man.article_id = art.article_id
  929. WHERE
  930. 1 = 1
  931. AND art.category_id IN ( SELECT category_id FROM cygx_report_mapping WHERE match_type_name = '热点问答' )
  932. AND re.chart_permission_id = 22 GROUP BY art.article_id `
  933. _, err = o.Raw(sql).QueryRows(&items)
  934. return
  935. }
  936. // 获取文章列表
  937. func GetArticleInit13_5GuSHou() (items []*ArticleDetail, err error) {
  938. o := orm.NewOrm()
  939. sql := `SELECT
  940. art.title,
  941. art.article_id
  942. FROM
  943. cygx_article AS art
  944. WHERE
  945. 1 = 1 AND category_id IN (10070,10082) `
  946. _, err = o.Raw(sql).QueryRows(&items)
  947. return
  948. }
  949. // 列表
  950. func GetCygxCygxArticleListByReportIds(reportIds []int) (items []*CygxArticle, err error) {
  951. lenArr := len(reportIds)
  952. if lenArr == 0 {
  953. return
  954. }
  955. var pars []interface{}
  956. o := orm.NewOrm()
  957. sql := `SELECT article_id ,report_id FROM cygx_article as art WHERE report_id IN (` + utils.GetOrmInReplace(lenArr) + `) `
  958. pars = append(pars, reportIds)
  959. sql += ` LIMIT ?,? `
  960. _, err = o.Raw(sql, pars, 0, lenArr).QueryRows(&items)
  961. return
  962. }
  963. // 已经同步到查研的FICC研报列表
  964. func GetCygxCygxArticleFiccReportList() (items []*CygxArticle, err error) {
  965. o := orm.NewOrm()
  966. sql := `SELECT article_id ,report_id,publish_status FROM cygx_article as art WHERE report_id > 0 `
  967. _, err = o.Raw(sql).QueryRows(&items)
  968. return
  969. }
  970. // UpdateCygxCygxArticleBillMulti 批量修改文章搜索内容字段
  971. func UpdateCygxCygxArticleBillMulti(items []*CygxArticle) (err error) {
  972. o := orm.NewOrm()
  973. p, err := o.Raw("UPDATE cygx_article SET article_search_content = ? WHERE article_id = ? ").Prepare()
  974. if err != nil {
  975. return
  976. }
  977. defer func() {
  978. _ = p.Close() // 别忘记关闭 statement
  979. }()
  980. for _, v := range items {
  981. _, err = p.Exec(v.ArticleSearchContent, v.ArticleId)
  982. if err != nil {
  983. return
  984. }
  985. }
  986. return
  987. }