article.go 42 KB

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