article.go 44 KB

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