article.go 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059
  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. // 获取文章列表
  310. func GetArticleListHomeTag(condition string, pars []interface{}) (items []*ArticleDetail, err error) {
  311. o := orm.NewOrm()
  312. sql := `SELECT article_id,stock FROM cygx_article WHERE 1= 1 ` + condition
  313. _, err = o.Raw(sql, pars).QueryRows(&items)
  314. return
  315. }
  316. func ModifyArticleContent(articleId int, content, expertNumStr, expertContentStr, interviewDateStr string) (err error) {
  317. o := orm.NewOrm()
  318. sql := `UPDATE cygx_article SET body=?,expert_background=?,expert_number=?,interview_date=? WHERE article_id=? `
  319. _, err = o.Raw(sql, content, expertContentStr, expertNumStr, interviewDateStr, articleId).Exec()
  320. return
  321. }
  322. type ElasticArticleDetail struct {
  323. ArticleId int `description:"报告id"`
  324. Title string `description:"标题"`
  325. TitleEn string `description:"英文标题 "`
  326. UpdateFrequency string `description:"更新周期"`
  327. CreateDate string `description:"创建时间"`
  328. PublishDate string `description:"发布时间"`
  329. Abstract string `description:"摘要"`
  330. CategoryName string `description:"一级分类"`
  331. SubCategoryName string `description:"二级分类"`
  332. IsCollect bool `description:"是否收藏:true,已收藏,false:未收藏"`
  333. IsInterviewApply bool `description:"是否申请访谈:true,已申请,false:未申请"`
  334. BodyText string `description:"内容"`
  335. InterviewApplyStatus string `description:"当前访谈申请状态:'待邀请','待访谈','已完成','已取消'"`
  336. InterviewDate string `description:"访谈时间"`
  337. ExpertBackground string `description:"专家背景"`
  338. ExpertNumber string `description:"专家编号"`
  339. Department string `description:"作者"`
  340. SellerMobile string `description:"销售手机号"`
  341. SellerName string `description:"销售名称"`
  342. ArticleIdMd5 string `description:"纪要id"`
  343. }
  344. func GetArticleCountById(articleId int) (count int, err error) {
  345. o := orm.NewOrm()
  346. sql := `SELECT COUNT(1) AS count FROM cygx_article WHERE article_id = ? `
  347. err = o.Raw(sql, articleId).QueryRow(&count)
  348. return
  349. }
  350. type CygxArticles struct {
  351. Id int `orm:"column(id);pk"`
  352. ArticleId int `description:"文章id"`
  353. Title string `description:"标题"`
  354. TitleEn string `description:"英文标题 "`
  355. UpdateFrequency string `description:"更新周期"`
  356. CreateDate string `description:"创建时间"`
  357. PublishDate string `description:"发布时间"`
  358. Body string `description:"内容"`
  359. BodyText string `description:"内容"`
  360. Abstract string `description:"摘要"`
  361. CategoryName string `description:"一级分类"`
  362. SubCategoryName string `description:"二级分类"`
  363. PublishStatus int `description:"发布状态"`
  364. CategoryId int `description:"分类id"`
  365. ExpertBackground string `description:"专家背景"`
  366. ExpertNumber string `description:"专家编号"`
  367. InterviewDate string `description:"访谈日期"`
  368. Department string `description:"作者"`
  369. ArticleIdMd5 string `description:"ID,md5值"`
  370. IsClass int `description:"是否归类,1是,0否"`
  371. IsSummary int `description:"是否是纪要库,1是,0否"`
  372. IsReport int `description:"是否属于报告,1是,0否"`
  373. ReportType int `description:"报告类型,1行业报告,2产业报告,0无"`
  374. }
  375. // 新增文章
  376. func AddCygxArticles(item *CygxArticle) (lastId int64, err error) {
  377. o := orm.NewOrm()
  378. lastId, err = o.Insert(item)
  379. return
  380. }
  381. func GetPermissionMappingById(categoryId int) (count int, err error) {
  382. o := orm.NewOrm()
  383. sql := `SELECT COUNT(1) AS count FROM cygx_permission_mapping WHERE category_id = ? `
  384. err = o.Raw(sql, categoryId).QueryRow(&count)
  385. return
  386. }
  387. func GetReportMappingById(categoryId int) (count int, err error) {
  388. o := orm.NewOrm()
  389. sql := `SELECT COUNT(1) AS count FROM cygx_report_mapping WHERE category_id = ? `
  390. err = o.Raw(sql, categoryId).QueryRow(&count)
  391. return
  392. }
  393. type ReportArticle struct {
  394. ArticleId int `description:"文章id"`
  395. ReportId int `description:"文章id"`
  396. Title string `description:"标题"`
  397. TitleEn string `description:"英文标题 "`
  398. UpdateFrequency string `description:"更新周期"`
  399. CreateDate string `description:"创建时间"`
  400. PublishDate string `description:"发布时间"`
  401. Body string `description:"内容"`
  402. Abstract string `description:"摘要"`
  403. CategoryName string `description:"一级分类"`
  404. SubCategoryName string `description:"二级分类"`
  405. ExpertBackground string `description:"专家背景"`
  406. IsRed bool `description:"是否标记红点"`
  407. Readnum int `description:"阅读数量"`
  408. VideoUrl string `description:"链接"`
  409. IsHaveVideo bool `description:"是否含有音频文件"`
  410. ImgUrlPc string `description:"图片链接"`
  411. CategoryId string `description:"文章分类"`
  412. Annotation string `description:"核心观点"`
  413. Resource int `description:"来源类型,1:文章、2:产品内测"`
  414. MyCollectNum int `description:"本人是否收藏"`
  415. IsCollect bool `description:"本人是否收藏"`
  416. Pv int `description:"PV"`
  417. CollectNum int `description:"收藏人数"`
  418. }
  419. type ReportMappingCategoryRep struct {
  420. CategoryId int `description:"文章分类id"`
  421. }
  422. func GetReportMappingCategoryID() (item []*ReportMappingCategoryRep, err error) {
  423. o := orm.NewOrm()
  424. sql := ` SELECT category_id FROM cygx_permission_mapping GROUP BY category_id `
  425. _, err = o.Raw(sql).QueryRows(&item)
  426. return
  427. }
  428. type PermissionMappingCategoryRep struct {
  429. CategoryId int `description:"文章分类id"`
  430. }
  431. func GetPermissionMappingCategoryID() (item []*PermissionMappingCategoryRep, err error) {
  432. o := orm.NewOrm()
  433. sql := ` SELECT category_id FROM cygx_report_mapping GROUP BY category_id `
  434. _, err = o.Raw(sql).QueryRows(&item)
  435. return
  436. }
  437. // 检查用户是否阅读某一分类最新文章
  438. func GetUserIsReadThisNewCategoryArticleCount(categoryId, uid int) (count int, err error) {
  439. sqlCount := `SELECT
  440. COUNT( 1 ) AS count
  441. FROM
  442. cygx_article_history_record
  443. WHERE
  444. 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 )
  445. AND user_id = ?`
  446. o := orm.NewOrm()
  447. err = o.Raw(sqlCount, categoryId, uid).QueryRow(&count)
  448. return
  449. }
  450. type ArticleId struct {
  451. ArticleId int `description:"文章id"`
  452. }
  453. type ArticleIdAndTitle struct {
  454. Title string `description:"标题"`
  455. ArticleId int `description:"文章id"`
  456. }
  457. // 获取自定义分类的文章ID
  458. func GetCustomArticleId() (item []*ArticleId, err error) {
  459. o := orm.NewOrm()
  460. sql := ` SELECT article_id FROM cygx_article WHERE is_custom = 1 `
  461. _, err = o.Raw(sql).QueryRows(&item)
  462. return
  463. }
  464. type ArticleFollowDetail struct {
  465. DNum int `description:"作者被关注的数量"`
  466. MdNum int `description:"本人是否关注这个作者"`
  467. AcNum int `description:"文章被收藏的数量"`
  468. MacNum int `description:"本人是否收藏这个文章"`
  469. }
  470. // 获取文章被关注被收藏的详情
  471. func GetArticleFollowDetail(articleId, uid int) (item *ArticleFollowDetail, err error) {
  472. //d_num 作者被关注的数量 、 md_num 本人是否关注这个作者 、ac_num 文章被收藏的数量 、 mac_num 本人是否收藏这个文章
  473. o := orm.NewOrm()
  474. sql := ` SELECT
  475. ( SELECT count( 1 ) FROM cygx_article_department_follow AS af WHERE af.department_id = art.department_id AND af.type = 1 ) AS d_num,
  476. ( 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,
  477. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = art.article_id ) AS ac_num,
  478. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = art.article_id AND ac.user_id = ? ) AS mac_num
  479. FROM
  480. cygx_article AS art
  481. LEFT JOIN cygx_article_department_follow AS af ON af.department_id = art.department_id
  482. LEFT JOIN cygx_article_collect AS ac ON ac.article_id = art.article_id
  483. WHERE
  484. art.article_id = ?
  485. GROUP BY art.article_id `
  486. err = o.Raw(sql, uid, uid, articleId).QueryRow(&item)
  487. return
  488. }
  489. // 日度点评的数据同步
  490. type ReportDetail struct {
  491. Id int `orm:"column(id)" description:"报告Id"`
  492. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  493. ClassifyIdFirst int `description:"一级分类id"`
  494. ClassifyNameFirst string `description:"一级分类名称"`
  495. ClassifyIdSecond int `description:"二级分类id"`
  496. ClassifyNameSecond string `description:"二级分类名称"`
  497. Title string `description:"标题"`
  498. Abstract string `description:"摘要"`
  499. Author string `description:"作者"`
  500. Frequency string `description:"频度"`
  501. CreateTime string `description:"创建时间"`
  502. ModifyTime string `description:"修改时间"`
  503. State int `description:"1:未发布,2:已发布"`
  504. PublishTime string `description:"发布时间"`
  505. Stage int `description:"期数"`
  506. MsgIsSend int `description:"消息是否已发送,0:否,1:是"`
  507. Content string `description:"内容"`
  508. VideoUrl string `description:"音频文件URL"`
  509. VideoName string `description:"音频文件名称"`
  510. VideoPlaySeconds string `description:"音频播放时长"`
  511. ContentSub string `description:"内容前两个章节"`
  512. }
  513. func GetReportList() (items []*ReportDetail, err error) {
  514. o := orm.NewOrmUsingDB("rddp")
  515. sql := `SELECT * FROM report WHERE classify_id_second = '57'`
  516. _, err = o.Raw(sql).QueryRows(&items)
  517. return
  518. }
  519. func GetMaxArticleIdInfo() (item *ArticleDetail, err error) {
  520. o := orm.NewOrm()
  521. sql := `SELECT * FROM cygx_article ORDER BY article_id desc LIMIT 1`
  522. err = o.Raw(sql).QueryRow(&item)
  523. return
  524. }
  525. type ArticleResultApi struct {
  526. Data []ArticleResultApidate `json:"data"`
  527. Code int `json:"code"`
  528. Msg string `json:"msg"`
  529. }
  530. type ArticleDetailResultApi struct {
  531. Data ArticleResultApidate `json:"data"`
  532. Code int `json:"code"`
  533. Msg string `json:"msg"`
  534. }
  535. type ArticleResultApidate struct {
  536. ArticleId int `json:"id"`
  537. Title string `json:"title"`
  538. File string `json:"file"`
  539. TitleEn string `json:"title_en"`
  540. Frequency string `json:"frequency"`
  541. CreateDate string `json:"create_date"`
  542. UpdateDate string `json:"update_date"`
  543. PublishDate time.Time `json:"publish_date"`
  544. PublishStatus int `json:"publish_status"`
  545. IndustrId int `json:"industry_id"`
  546. SeriesId int `json:"series_id"`
  547. Series ArticleSeries `json:"series"`
  548. Content ArticleResultApiContent `json:"content"`
  549. Author ArticleResultApiAuthor `json:"author"`
  550. Industry ArticleResultApiIndustry `json:"industry"`
  551. Type ArticleResultApiType `json:"type"`
  552. Stock []string `json:"stock"`
  553. Field ArticleField `json:"field"`
  554. Corpus Corpus `json:"corpus"`
  555. Cover string `json:"cover"`
  556. TypeId int `json:"type_id"`
  557. IsActive bool `json:"is_active"`
  558. PublishArea string `json:"publish_area"`
  559. }
  560. type ArticleField struct {
  561. Id int `json:"id"`
  562. Name string `json:"name"`
  563. Description string `json:"description"`
  564. IndustryId int `json:"industry_id"`
  565. }
  566. type Corpus struct {
  567. Id int `json:"id"`
  568. ArticleId int `json:"article_id"`
  569. Corpus string `json:"corpus"`
  570. }
  571. type ArticleSeries struct {
  572. Name string `json:"name"`
  573. }
  574. type ArticleResultApiContent struct {
  575. ArticleId int `json:"id"`
  576. Body string `json:"body"`
  577. Abstract string `json:"abstract"`
  578. Annotation string `json:"annotation"`
  579. }
  580. type ArticleResultApiAuthor struct {
  581. PhoneNumber string `json:"phone_number"`
  582. Name string `json:"name"`
  583. }
  584. type ArticleResultApiIndustry struct {
  585. Name string `json:"name"`
  586. }
  587. type ArticleResultApiType struct {
  588. Name string `json:"name"`
  589. }
  590. type ArticleIndustryApi struct {
  591. Data []ArticleResultApiIndustrdate `json:"data"`
  592. Code int `json:"code"`
  593. Msg string `json:"msg"`
  594. }
  595. type ArticleResultApiIndustrdate struct {
  596. Id int `json:"id"`
  597. Name string `json:"name"`
  598. Series []ArticleResultApiSeriesdate `json:"series"`
  599. }
  600. type ArticleResultApiSeriesdate struct {
  601. Id int `json:"id"`
  602. Name string `json:"name"`
  603. }
  604. type ArticleApiMap struct {
  605. Id int `description:"新ID"`
  606. OldId int `description:"旧Id"`
  607. IsClass int `description:"是否自动归类,1是,0否"`
  608. IsReport int `description:"是否属于报告,1是,0否"`
  609. IsSummary int `description:"是否属于纪要,1是,0否"`
  610. SeriesId int `description:"策略平台那边的报告分类ID"`
  611. OldIdMap int `description:"策略平台老的分类ID样式map映射"`
  612. }
  613. func GetArticleApiMap() (item []*ArticleApiMap, err error) {
  614. o := orm.NewOrm()
  615. sql := ` SELECT * FROM cygx_article_api_map WHERE old_id > 0 AND is_update = 1 ORDER BY old_id ASC `
  616. _, err = o.Raw(sql).QueryRows(&item)
  617. return
  618. }
  619. func GetArticleIdSubjectGroup(keyWord string) (articleid string, err error) {
  620. o := orm.NewOrm()
  621. sql := ` SELECT
  622. GROUP_CONCAT(DISTINCT art.article_id SEPARATOR ',') AS articleid
  623. FROM
  624. cygx_article AS art
  625. INNER JOIN cygx_industrial_article_group_subject AS sg ON sg.article_id = art.article_id
  626. INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = sg.industrial_subject_id
  627. WHERE
  628. s.subject_name LIKE '%` + keyWord + `%' `
  629. err = o.Raw(sql).QueryRow(&articleid)
  630. return
  631. }
  632. func GetArticleIndustrialIdGroup(keyWord string) (articleid string, err error) {
  633. o := orm.NewOrm()
  634. sql := ` SELECT
  635. GROUP_CONCAT(DISTINCT art.article_id SEPARATOR ',') AS article_id
  636. FROM
  637. cygx_article AS art
  638. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = art.article_id
  639. INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  640. WHERE
  641. m.industry_name LIKE '%` + keyWord + `%' `
  642. err = o.Raw(sql).QueryRow(&articleid)
  643. return
  644. }
  645. // 通过文章ID获取文章所关联的标的ID
  646. func GetSubjectIds(articleId int) (subjects string, err error) {
  647. sql := ` SELECT
  648. GROUP_CONCAT( DISTINCT industrial_subject_id ORDER BY id ASC SEPARATOR ',' ) AS subjects
  649. FROM
  650. cygx_industrial_article_group_subject WHERE article_id = ?`
  651. o := orm.NewOrm()
  652. err = o.Raw(sql, articleId).QueryRow(&subjects)
  653. return
  654. }
  655. // 修改发布状态
  656. func UpdateIsClassFail(articleId int) (err error) {
  657. sql := `UPDATE cygx_article SET is_class_fail=1 WHERE article_id=? `
  658. o := orm.NewOrm()
  659. _, err = o.Raw(sql, articleId).Exec()
  660. return
  661. }
  662. type SummaryArticleStock struct {
  663. Id int `description:"新ID"`
  664. ArticleId int `description:"文章id"`
  665. Stock string `description:"个股标签"`
  666. }
  667. // 综述报告
  668. func GetSummaryArticle(chartPermissionId int) (items []*SummaryArticleStock, err error) {
  669. o := orm.NewOrm()
  670. sql := `SELECT
  671. *
  672. FROM
  673. cygx_article AS c
  674. INNER JOIN cygx_report_mapping AS m
  675. WHERE
  676. c.type_name = '综述报告'
  677. AND m.category_id = c.category_id_two
  678. AND m.chart_permission_id = ? ORDER BY modify_time_by_cl DESC `
  679. _, err = o.Raw(sql, chartPermissionId).QueryRows(&items)
  680. return
  681. }
  682. type SummaryArticleStockResp struct {
  683. List []*SummaryArticleStock
  684. }
  685. // 综述报告
  686. func GetArticleStock() (items []*SummaryArticleStock, err error) {
  687. o := orm.NewOrm()
  688. sql := `SELECT
  689. stock,article_id
  690. FROM
  691. cygx_article AS art
  692. WHERE
  693. 1 = 1
  694. AND type_name = '综述报告' `
  695. _, err = o.Raw(sql).QueryRows(&items)
  696. return
  697. }
  698. // 列表
  699. func GetCygxCygxArticleList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxArticle, err error) {
  700. o := orm.NewOrm()
  701. sql := `SELECT * FROM cygx_article as art WHERE 1= 1 `
  702. if condition != "" {
  703. sql += condition
  704. }
  705. sql += ` LIMIT ?,? `
  706. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  707. return
  708. }
  709. func ModifyArticleTitleByarticleId(articleId int, title string) (err error) {
  710. o := orm.NewOrm()
  711. sql := `UPDATE cygx_article SET title= ? WHERE article_id=? `
  712. _, err = o.Raw(sql, title, articleId).Exec()
  713. return
  714. }
  715. // 获取数量
  716. func GetCygxArticleCount(condition string, pars []interface{}) (count int, err error) {
  717. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_article as art WHERE 1= 1 `
  718. if condition != "" {
  719. sqlCount += condition
  720. }
  721. o := orm.NewOrm()
  722. err = o.Raw(sqlCount, pars).QueryRow(&count)
  723. return
  724. }
  725. // 列表
  726. func GetCygxCygxArticleListByCondition(articleTypesCond, activityTypesCond, industryStr, subjectNameStr, articleTypeStr string) (artIds, actIds, mmIds string, err error) {
  727. o := orm.NewOrm()
  728. artSql := `SELECT GROUP_CONCAT(DISTINCT art.article_id SEPARATOR ',') AS art_ids FROM cygx_article as art `
  729. actSql := ` SELECT GROUP_CONCAT(DISTINCT act.activity_id SEPARATOR ',') AS act_ids FROM cygx_activity as act `
  730. mmSql := ` SELECT GROUP_CONCAT(DISTINCT mmc.id SEPARATOR ',') AS mm_ids FROM cygx_morning_meeting_review_chapter as mmc `
  731. if industryStr != "" {
  732. artSql += ` INNER JOIN cygx_industrial_article_group_management AS iam ON iam.article_id = art.article_id
  733. INNER JOIN cygx_industrial_management AS im ON im.industrial_management_id=iam.industrial_management_id `
  734. actSql += ` INNER JOIN cygx_industrial_activity_group_management AS iam ON iam.activity_id = act.activity_id
  735. INNER JOIN cygx_industrial_management AS im ON im.industrial_management_id=iam.industrial_management_id `
  736. mmSql += ` INNER JOIN cygx_morning_meeting_reviews AS mm ON mmc.meeting_id = mm.id
  737. INNER JOIN cygx_industrial_management AS im ON im.industrial_management_id=mmc.industry_id `
  738. }
  739. if subjectNameStr != "" {
  740. artSql += ` INNER JOIN cygx_industrial_article_group_subject AS ias ON ias.article_id = art.article_id
  741. INNER JOIN cygx_industrial_subject AS cis ON cis.industrial_subject_id=ias.industrial_subject_id `
  742. actSql += ` INNER JOIN cygx_industrial_activity_group_subject AS ias ON ias.activity_id = act.activity_id
  743. INNER JOIN cygx_industrial_subject AS cis ON cis.industrial_subject_id=ias.industrial_subject_id `
  744. mmSql += ` IINNER JOIN cygx_morning_meeting_reviews AS mm ON mmc.meeting_id = mm.id
  745. INNER JOIN cygx_industrial_subject AS cis ON cis.industrial_subject_id=mmc.industrial_subject_ids `
  746. }
  747. artSql += ` WHERE 1=1 `
  748. if articleTypesCond != "" || (articleTypesCond == "" && activityTypesCond == "") {
  749. if industryStr != "" && subjectNameStr != "" {
  750. artSql += articleTypesCond + ` AND (im.industry_name In (` + industryStr + `) OR cis.subject_name In (` + subjectNameStr + `) )`
  751. } else if industryStr == "" && subjectNameStr != "" {
  752. artSql += articleTypesCond + ` AND cis.subject_name In (` + subjectNameStr + `) `
  753. } else if industryStr != "" && subjectNameStr == "" {
  754. artSql += articleTypesCond + ` AND im.industry_name In (` + industryStr + `) `
  755. } else {
  756. artSql += articleTypesCond
  757. }
  758. err = o.Raw(artSql).QueryRow(&artIds)
  759. }
  760. actSql += ` WHERE 1=1 `
  761. if activityTypesCond != "" || (articleTypesCond == "" && activityTypesCond == "") {
  762. if industryStr != "" && subjectNameStr != "" {
  763. actSql += activityTypesCond + ` AND (im.industry_name In (` + industryStr + `) OR cis.subject_name In (` + subjectNameStr + `) )`
  764. } else if industryStr == "" && subjectNameStr != "" {
  765. actSql += activityTypesCond + ` AND cis.subject_name In (` + subjectNameStr + `) `
  766. } else if industryStr != "" && subjectNameStr == "" {
  767. actSql += activityTypesCond + ` AND im.industry_name In (` + industryStr + `) `
  768. } else {
  769. actSql += activityTypesCond
  770. }
  771. err = o.Raw(actSql).QueryRow(&actIds)
  772. }
  773. if strings.Contains(articleTypeStr, "晨会精华") {
  774. mmSql += ` WHERE 1=1 `
  775. if industryStr != "" && subjectNameStr != "" {
  776. mmSql += ` AND (im.industry_name In (` + industryStr + `) OR cis.subject_name In (` + subjectNameStr + `) )`
  777. } else if industryStr == "" && subjectNameStr != "" {
  778. mmSql += ` AND cis.subject_name In (` + subjectNameStr + `) `
  779. } else if industryStr != "" && subjectNameStr == "" {
  780. mmSql += ` AND im.industry_name In (` + industryStr + `) `
  781. }
  782. err = o.Raw(mmSql).QueryRow(&mmIds)
  783. }
  784. return
  785. }
  786. // 单个tag时用,取合集
  787. func GetCygxCygxArticleListByConditionSoloTag(articleTypeCondSlice, activityTypesCondSlice, industriesCondSlice, subjectNamesSlice, articleTypeSlice []string) (artIds, actIds, mmIds string, err error) {
  788. o := orm.NewOrm()
  789. artSql := `SELECT GROUP_CONCAT(DISTINCT art.article_id SEPARATOR ',') AS art_ids FROM cygx_article as art `
  790. actSql := ` SELECT GROUP_CONCAT(DISTINCT act.activity_id SEPARATOR ',') AS act_ids FROM cygx_activity as act `
  791. mmSql := ` SELECT GROUP_CONCAT(DISTINCT mmc.id SEPARATOR ',') AS mm_ids FROM cygx_morning_meeting_review_chapter as mmc `
  792. for _, s := range industriesCondSlice {
  793. if s != "" {
  794. artSql += ` INNER JOIN cygx_industrial_article_group_management AS iam ON iam.article_id = art.article_id
  795. INNER JOIN cygx_industrial_management AS im ON im.industrial_management_id=iam.industrial_management_id `
  796. actSql += ` INNER JOIN cygx_industrial_activity_group_management AS iam ON iam.activity_id = act.activity_id
  797. INNER JOIN cygx_industrial_management AS im ON im.industrial_management_id=iam.industrial_management_id `
  798. mmSql += ` INNER JOIN cygx_morning_meeting_reviews AS mm ON mmc.meeting_id = mm.id
  799. INNER JOIN cygx_industrial_management AS im ON im.industrial_management_id=mmc.industry_id `
  800. break
  801. }
  802. }
  803. for _, s := range subjectNamesSlice {
  804. if s != "" {
  805. artSql += ` INNER JOIN cygx_industrial_article_group_subject AS ias ON ias.article_id = art.article_id
  806. INNER JOIN cygx_industrial_subject AS cis ON cis.industrial_subject_id=ias.industrial_subject_id `
  807. actSql += ` INNER JOIN cygx_industrial_activity_group_subject AS ias ON ias.activity_id = act.activity_id
  808. INNER JOIN cygx_industrial_subject AS cis ON cis.industrial_subject_id=ias.industrial_subject_id `
  809. mmSql += ` IINNER JOIN cygx_morning_meeting_reviews AS mm ON mmc.meeting_id = mm.id
  810. INNER JOIN cygx_industrial_subject AS cis ON cis.industrial_subject_id=mmc.industrial_subject_ids `
  811. break
  812. }
  813. }
  814. artSql += ` WHERE 1=1 AND ((1=1 `
  815. actSql += ` WHERE 1=1 AND ((1=1 `
  816. mmSql += ` WHERE 1=1 AND ((1=1 `
  817. var isNeedArt, isNeedAct, isNeedMm bool
  818. for i, _ := range articleTypeCondSlice {
  819. articleTypesCond := articleTypeCondSlice[i]
  820. activityTypesCond := activityTypesCondSlice[i]
  821. industryStr := industriesCondSlice[i]
  822. subjectNameStr := subjectNamesSlice[i]
  823. articleTypeStr := articleTypeSlice[i]
  824. if articleTypesCond != "" || (articleTypesCond == "" && activityTypesCond == "") {
  825. if industryStr != "" && subjectNameStr != "" {
  826. artSql += articleTypesCond + ` AND (im.industry_name In (` + industryStr + `) OR cis.subject_name In (` + subjectNameStr + `) )`
  827. } else if industryStr == "" && subjectNameStr != "" {
  828. artSql += articleTypesCond + ` AND cis.subject_name In (` + subjectNameStr + `) `
  829. } else if industryStr != "" && subjectNameStr == "" {
  830. artSql += articleTypesCond + ` AND im.industry_name In (` + industryStr + `) `
  831. } else {
  832. artSql += articleTypesCond
  833. }
  834. if i == len(articleTypeCondSlice)-1 {
  835. artSql += `)) `
  836. } else {
  837. artSql += `) OR (1=1 `
  838. }
  839. isNeedArt = true
  840. }
  841. if activityTypesCond != "" || (articleTypesCond == "" && activityTypesCond == "") {
  842. if industryStr != "" && subjectNameStr != "" {
  843. actSql += activityTypesCond + ` AND (im.industry_name In (` + industryStr + `) OR cis.subject_name In (` + subjectNameStr + `) )`
  844. } else if industryStr == "" && subjectNameStr != "" {
  845. actSql += activityTypesCond + ` AND cis.subject_name In (` + subjectNameStr + `) `
  846. } else if industryStr != "" && subjectNameStr == "" {
  847. actSql += activityTypesCond + ` AND im.industry_name In (` + industryStr + `) `
  848. } else {
  849. actSql += activityTypesCond
  850. }
  851. if i == len(articleTypeCondSlice)-1 {
  852. actSql += `)) `
  853. } else {
  854. actSql += `) OR (1=1 `
  855. }
  856. isNeedAct = true
  857. }
  858. if strings.Contains(articleTypeStr, "晨会精华") {
  859. if industryStr != "" && subjectNameStr != "" {
  860. mmSql += ` AND (im.industry_name In (` + industryStr + `) OR cis.subject_name In (` + subjectNameStr + `) )`
  861. } else if industryStr == "" && subjectNameStr != "" {
  862. mmSql += ` AND cis.subject_name In (` + subjectNameStr + `) `
  863. } else if industryStr != "" && subjectNameStr == "" {
  864. mmSql += ` AND im.industry_name In (` + industryStr + `) `
  865. }
  866. if i == len(articleTypeCondSlice)-1 {
  867. mmSql += `)) `
  868. } else {
  869. mmSql += `) OR (1=1 `
  870. }
  871. isNeedMm = true
  872. }
  873. }
  874. if isNeedArt {
  875. err = o.Raw(artSql).QueryRow(&artIds)
  876. if err != nil {
  877. return
  878. }
  879. }
  880. if isNeedAct {
  881. err = o.Raw(actSql).QueryRow(&actIds)
  882. if err != nil {
  883. return
  884. }
  885. }
  886. if isNeedMm {
  887. err = o.Raw(mmSql).QueryRow(&mmIds)
  888. if err != nil {
  889. return
  890. }
  891. }
  892. return
  893. }
  894. // 获取文章列表
  895. func GetArticleInit13_5() (items []*ArticleDetail, err error) {
  896. o := orm.NewOrm()
  897. sql := `SELECT
  898. art.title,
  899. art.article_id,
  900. art.category_id,
  901. art.publish_date,
  902. art.is_class,
  903. art.publish_status,
  904. art.is_filter,
  905. art.stock,
  906. art.field_name,
  907. art.id,
  908. art.article_id_md5,
  909. re.chart_permission_name,
  910. re.match_type_name,
  911. art.sub_category_name,
  912. re.chart_permission_id
  913. FROM
  914. cygx_article AS art
  915. LEFT JOIN cygx_report_mapping AS ret ON ret.category_id = art.category_id_two
  916. LEFT JOIN cygx_report_mapping AS re ON re.category_id = art.category_id
  917. LEFT JOIN cygx_industrial_article_group_management AS man ON man.article_id = art.article_id
  918. WHERE
  919. 1 = 1
  920. AND art.category_id IN ( SELECT category_id FROM cygx_report_mapping WHERE match_type_name = '热点问答' )
  921. AND re.chart_permission_id = 22 GROUP BY art.article_id `
  922. _, err = o.Raw(sql).QueryRows(&items)
  923. return
  924. }
  925. // 获取文章列表
  926. func GetArticleInit13_5GuSHou() (items []*ArticleDetail, err error) {
  927. o := orm.NewOrm()
  928. sql := `SELECT
  929. art.title,
  930. art.article_id
  931. FROM
  932. cygx_article AS art
  933. WHERE
  934. 1 = 1 AND category_id IN (10070,10082) `
  935. _, err = o.Raw(sql).QueryRows(&items)
  936. return
  937. }
  938. // 列表
  939. func GetCygxCygxArticleListByReportIds(reportIds []int) (items []*CygxArticle, err error) {
  940. lenArr := len(reportIds)
  941. if lenArr == 0 {
  942. return
  943. }
  944. var pars []interface{}
  945. o := orm.NewOrm()
  946. sql := `SELECT article_id ,report_id FROM cygx_article as art WHERE report_id IN (` + utils.GetOrmInReplace(lenArr) + `) `
  947. pars = append(pars, reportIds)
  948. sql += ` LIMIT ?,? `
  949. _, err = o.Raw(sql, pars, 0, lenArr).QueryRows(&items)
  950. return
  951. }
  952. // 已经同步到查研的FICC研报列表
  953. func GetCygxCygxArticleFiccReportList() (items []*CygxArticle, err error) {
  954. o := orm.NewOrm()
  955. sql := `SELECT article_id ,report_id FROM cygx_article as art WHERE report_id > 0 `
  956. _, err = o.Raw(sql).QueryRows(&items)
  957. return
  958. }