article.go 43 KB

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