article.go 43 KB

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