article.go 43 KB

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