article.go 43 KB

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