article.go 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxArticle struct {
  7. Id int `orm:"column(id);pk"`
  8. ArticleId int `description:"文章id"`
  9. Title string `description:"标题"`
  10. TitleEn string `description:"英文标题 "`
  11. UpdateFrequency string `description:"更新周期"`
  12. CreateDate string `description:"创建时间"`
  13. PublishDate string `description:"发布时间"`
  14. Body string `description:"内容"`
  15. BodyText string `description:"内容"`
  16. Abstract string `description:"摘要"`
  17. CategoryName string `description:"一级分类"`
  18. SubCategoryName string `description:"二级分类"`
  19. PublishStatus int `description:"发布状态"`
  20. CategoryId int `description:"分类id"`
  21. CategoryIdTwo int `description:"分类id用作修改匹配类型使用"`
  22. ExpertBackground string `description:"专家背景"`
  23. ExpertNumber string `description:"专家编号"`
  24. InterviewDate string `description:"访谈日期"`
  25. Department string `description:"作者"`
  26. ArticleIdMd5 string `description:"ID,md5值"`
  27. IsClass int `description:"是否归类,1是,0否"`
  28. IsSummary int `description:"是否是纪要库,1是,0否"`
  29. IsReport int `description:"是否属于报告,1是,0否"`
  30. ReportType int `description:"报告类型,1行业报告,2产业报告,0无"`
  31. FileLink string `description:"下载预览链接"`
  32. MatchTypeName string `description:"匹配类型"`
  33. Periods string `description:"期数"`
  34. ReportLink string `description:"报告链接"`
  35. ArticleType string `description:"文章类型 文章类型,lyjh:路演精华 "`
  36. HavePublish int `description:"是否发布过,1是 ,0 否"`
  37. Source int `description:"来源 0策略平台同步,1小程序后台添加"`
  38. SellerAndMobile string `description:"销售和手机号"`
  39. VideoUrl string `description:"音频文件URL"`
  40. VideoName string `description:"音频文件名称"`
  41. VideoPlaySeconds string `description:"音频播放时长"`
  42. Stock string `description:"个股标签"`
  43. FieldName string `description:"产业标签"`
  44. Annotation string `description:"核心观点"`
  45. TypeName string `description:"策略平台报告类型"`
  46. ModifyTimeByCl string `description:"策略平台报告更新时间"`
  47. CeLueFieldId int `description:"策略平台领域ID"`
  48. }
  49. type CygxArticleEs struct {
  50. Id int `orm:"column(id);pk"`
  51. ArticleId int `description:"文章id"`
  52. Title string `description:"标题"`
  53. TitleEn string `description:"英文标题 "`
  54. UpdateFrequency string `description:"更新周期"`
  55. CreateDate string `description:"创建时间"`
  56. PublishDate string `description:"发布时间"`
  57. Body string `description:"内容"`
  58. BodyText string `description:"内容"`
  59. Abstract string `description:"摘要"`
  60. CategoryName string `description:"一级分类"`
  61. SubCategoryName string `description:"二级分类"`
  62. PublishStatus int `description:"发布状态"`
  63. CategoryId string `description:"分类id"`
  64. ExpertBackground string `description:"专家背景"`
  65. ExpertNumber string `description:"专家编号"`
  66. InterviewDate string `description:"访谈日期"`
  67. Department string `description:"作者"`
  68. ArticleIdMd5 string `description:"ID,md5值"`
  69. IsClass int `description:"是否归类,1是,0否"`
  70. IsSummary bool `description:"是否是纪要库,1是,0否"`
  71. IsReport bool `description:"是否属于报告,1是,0否"`
  72. ReportType int `description:"报告类型,1行业报告,2产业报告,0无"`
  73. FileLink string `description:"下载预览链接"`
  74. MatchTypeName string `description:"匹配类型"`
  75. }
  76. // 新增文章
  77. func AddCygxArticle(item *CygxArticle) (lastId int64, err error) {
  78. o := orm.NewOrm()
  79. lastId, err = o.Insert(item)
  80. return
  81. }
  82. type HomeArticle struct {
  83. ArticleId int `description:"文章id"`
  84. Title string `description:"标题"`
  85. TitleEn string `description:"英文标题 "`
  86. UpdateFrequency string `description:"更新周期"`
  87. CreateDate string `description:"创建时间"`
  88. PublishDate string `description:"发布时间"`
  89. Body string `description:"内容"`
  90. BodyHtml string `description:"内容带有HTML标签"`
  91. Abstract string `description:"摘要"`
  92. CategoryName string `description:"一级分类"`
  93. SubCategoryName string `description:"二级分类"`
  94. ExpertBackground string `description:"专家背景"`
  95. IsResearch bool `description:"是否属于研选"`
  96. Pv int `description:"PV"`
  97. ImgUrlPc string `description:"图片链接"`
  98. CategoryId string `description:"文章分类"`
  99. HttpUrl string `description:"文章链接跳转地址"`
  100. IsNeedJump bool `description:"是否需要跳转链接地址"`
  101. Source int `description:"来源 1:文章, 2:图表"`
  102. Annotation string `description:"核心观点"`
  103. HomeType int `description:"数据类型:0-纪要(默认); 1-微路演音频"`
  104. MicroAudio *MicroAudioUnionList `description:"微路演音频"`
  105. ChartPermissionName string `description:"权限名称"`
  106. ArticleTypeName string `description:"权限名称"`
  107. IsReport int `description:"是否属于报告,1是,0否"`
  108. ArticleResponse int `description:"报告类型 0:啥也不是,1研选报告,2:研选纪要,3:研选沙龙,4;研选观点"`
  109. Readnum int `description:"阅读数量"`
  110. List []*IndustrialManagementIdInt
  111. }
  112. type ArticleDetail struct {
  113. ArticleId int `description:"报告id"`
  114. Title string `description:"标题"`
  115. TitleEn string `description:"英文标题 "`
  116. UpdateFrequency string `description:"更新周期"`
  117. CreateDate string `description:"创建时间"`
  118. PublishDate string `description:"发布时间"`
  119. Body string `description:"内容"`
  120. Abstract string `description:"摘要"`
  121. CategoryName string `description:"一级分类"`
  122. SubCategoryName string `description:"二级分类"`
  123. IsCollect bool `description:"是否收藏:true,已收藏,false:未收藏"`
  124. IsInterviewApply bool `description:"是否申请访谈:true,已申请,false:未申请"`
  125. BodyText string `description:"内容"`
  126. InterviewApplyStatus string `description:"当前访谈申请状态:'待邀请','待访谈','已完成','已取消'"`
  127. InterviewDate string `description:"访谈时间"`
  128. ExpertBackground string `description:"专家背景"`
  129. ExpertNumber string `description:"专家编号"`
  130. Department string `description:"作者"`
  131. SellerMobile string `description:"销售手机号"`
  132. SellerName string `description:"销售名称"`
  133. ArticleIdMd5 string `description:"纪要id"`
  134. IsClass int `description:"是否归类,1是,0否"`
  135. CategoryId int `description:"分类ID"`
  136. IsSummary int `description:"是否是纪要库,1是,0否"`
  137. IsReport int `description:"是否属于报告,1是,0否"`
  138. IsResearch bool `description:"是否属于研选"`
  139. FileLink string `description:"下载预览链接"`
  140. SellerAndMobile string `description:"销售和手机号"`
  141. IsFollow bool `description:"是否关注,1是,0否"`
  142. IsBelongSummary bool `description:"是否属于纪要库"`
  143. IsBelongReport bool `description:"是否属于报告"`
  144. FollowNum int `description:"关注数量"`
  145. CollectionNum int `description:"收藏数量"`
  146. DepartmentId int `description:"作者ID"`
  147. DepartmentImgUrl string `description:"作者头像"`
  148. NickName string `description:"作者昵称"`
  149. SubjectIds string `description:"文章关联标的的ID字符串"`
  150. IndustrialAndSubjectIds string `description:"文章关联产业和标的的ID字符串"`
  151. IndustrialManagementId int `description:"文章关联产业ID"`
  152. SellerList []*SellerRep
  153. HttpUrl string `description:"文章链接跳转地址"`
  154. IsNeedJump bool `description:"是否需要跳转链接地址"`
  155. ReportLink string `description:"报告链接"`
  156. IsShowLinkButton int `description:"这种报告类型是否展示查看报告链接"`
  157. ArticleTypeId int `description:"文章类型ID"`
  158. IsSpecialArticle bool `description:"是否属于专项调研报告"`
  159. Annotation string `description:"核心观点"`
  160. IsShowFollowButton bool `description:"是否展示关注取关按钮"`
  161. IsFollowButton bool `description:"是否关注"`
  162. IsRoadShow bool `description:"是否是路演精华"`
  163. ReportType int `description:"报告类型,1行业报告,2产业报告,0无"`
  164. }
  165. type ArticleDetailFileLink struct {
  166. FileLink string `description:"下载预览链接"`
  167. Scene string `description:"资源参数"`
  168. }
  169. type SellerRep struct {
  170. SellerMobile string `description:"销售手机号"`
  171. SellerName string `description:"销售名称"`
  172. }
  173. func GetArticleDetailById(articleId int) (item *ArticleDetail, err error) {
  174. o := orm.NewOrm()
  175. sql := `SELECT * FROM cygx_article WHERE article_id = ? AND publish_status = 1 `
  176. err = o.Raw(sql, articleId).QueryRow(&item)
  177. return
  178. }
  179. func GetSellerList(articleId int) (items []*SellerRep, err error) {
  180. o := orm.NewOrm()
  181. sql := `SELECT
  182. au.mobile as seller_mobile,
  183. au.name as seller_name
  184. FROM
  185. cygx_article_author AS au
  186. WHERE article_id = ?`
  187. _, err = o.Raw(sql, articleId).QueryRows(&items)
  188. return
  189. }
  190. func GetArticleDetailByIdMd5(articleIdMd5 string) (item *ArticleDetail, err error) {
  191. o := orm.NewOrm()
  192. sql := `SELECT * FROM cygx_article WHERE article_id_md5 = ? `
  193. err = o.Raw(sql, articleIdMd5).QueryRow(&item)
  194. return
  195. }
  196. func GetArticleDetailByIdStr(articleIdStr string) (items []*ArticleDetail, err error) {
  197. o := orm.NewOrm()
  198. sql := `SELECT art.*,d.nick_name FROM
  199. cygx_article AS art
  200. LEFT JOIN cygx_article_department AS d ON d.department_id = art.department_id WHERE article_id IN(` + articleIdStr + `) `
  201. _, err = o.Raw(sql).QueryRows(&items)
  202. return
  203. }
  204. func GetArticlePermission(companyId int) (item *ChartPermission, err error) {
  205. o := orm.NewOrm()
  206. sql := `SELECT
  207. a.chart_permission_name as permission_name
  208. FROM
  209. cygx_report_mapping AS a
  210. WHERE
  211. a.category_id = ? LIMIT 1 `
  212. err = o.Raw(sql, companyId).QueryRow(&item)
  213. //_, err = o.Raw(sql, companyId).QueryRows(&item)
  214. return
  215. }
  216. type ArticleDetailResp struct {
  217. Detail *ArticleDetail
  218. HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
  219. HasFree int `description:"1:已付费(至少包含一个品类的权限),2:未付费(没有任何品类权限)"`
  220. HaveResearch bool `description:"是否有研选权限"`
  221. Mobile string `description:"用户手机号"`
  222. PopupMsg string `description:"权限弹窗信息"`
  223. SellerMobile string `description:"销售电话"`
  224. SellerName string `description:"销售姓名"`
  225. IsSpecialArticle bool `description:"是否属于专项调研报告"`
  226. }
  227. type ArticleDetailHtgjResp struct {
  228. HasPermission int `description:"1:有该行业权限,正常展示,0:试用期已过期"`
  229. CompanyName string `description:"公司名称"`
  230. Detail *ArticleDetail
  231. }
  232. func ModifyArticleExpert(articleId int, expertNumStr, expertContentStr, interviewDateStr, bodyText string) (err error) {
  233. o := orm.NewOrm()
  234. sql := `UPDATE cygx_article SET expert_background=?,expert_number=?,interview_date=?,body_text=? WHERE article_id=? `
  235. _, err = o.Raw(sql, expertContentStr, expertNumStr, interviewDateStr, bodyText, articleId).Exec()
  236. return
  237. }
  238. // 更改文章发布状态
  239. func UpdateArticlePublish(articleId, publishStatus int) (err error) {
  240. o := orm.NewOrm()
  241. sql := `UPDATE cygx_article SET publish_status=? WHERE article_id=? `
  242. _, err = o.Raw(sql, publishStatus, articleId).Exec()
  243. return
  244. }
  245. type ArticleDetailTest struct {
  246. ArticleId int `description:"报告id"`
  247. Title string `description:"标题"`
  248. BodyText string `description:"内容"`
  249. Body string `json:"-" description:"内容"`
  250. }
  251. func GetArticleDetailTestById(articleId int) (item *ArticleDetail, err error) {
  252. o := orm.NewOrm()
  253. sql := `SELECT * FROM cygx_article WHERE article_id = ? `
  254. err = o.Raw(sql, articleId).QueryRow(&item)
  255. return
  256. }
  257. func GetArticleAll() (item []*ArticleDetail, err error) {
  258. o := orm.NewOrm()
  259. sql := `SELECT * FROM cygx_article WHERE is_summary=1`
  260. _, err = o.Raw(sql).QueryRows(&item)
  261. return
  262. }
  263. func GetArticleAllDate(endDate string) (item []*ArticleDetail, err error) {
  264. o := orm.NewOrm()
  265. sql := `SELECT * FROM cygx_article WHERE is_summary=1 AND publish_date >= ? `
  266. _, err = o.Raw(sql, endDate).QueryRows(&item)
  267. return
  268. }
  269. func GetArticleAll2() (item []*ArticleDetail, err error) {
  270. o := orm.NewOrm()
  271. sql := `SELECT * FROM cygx_article `
  272. _, err = o.Raw(sql).QueryRows(&item)
  273. return
  274. }
  275. // 获取文章列表
  276. func GetArticleList(condition string, pars []interface{}) (items []*ArticleDetail, err error) {
  277. o := orm.NewOrm()
  278. sql := `SELECT article_id FROM cygx_article WHERE 1= 1 ` + condition
  279. _, err = o.Raw(sql, pars).QueryRows(&items)
  280. return
  281. }
  282. func ModifyArticleContent(articleId int, content, expertNumStr, expertContentStr, interviewDateStr string) (err error) {
  283. o := orm.NewOrm()
  284. sql := `UPDATE cygx_article SET body=?,expert_background=?,expert_number=?,interview_date=? WHERE article_id=? `
  285. _, err = o.Raw(sql, content, expertContentStr, expertNumStr, interviewDateStr, articleId).Exec()
  286. return
  287. }
  288. type ElasticArticleDetail struct {
  289. ArticleId int `description:"报告id"`
  290. Title string `description:"标题"`
  291. TitleEn string `description:"英文标题 "`
  292. UpdateFrequency string `description:"更新周期"`
  293. CreateDate string `description:"创建时间"`
  294. PublishDate string `description:"发布时间"`
  295. Abstract string `description:"摘要"`
  296. CategoryName string `description:"一级分类"`
  297. SubCategoryName string `description:"二级分类"`
  298. IsCollect bool `description:"是否收藏:true,已收藏,false:未收藏"`
  299. IsInterviewApply bool `description:"是否申请访谈:true,已申请,false:未申请"`
  300. BodyText string `description:"内容"`
  301. InterviewApplyStatus string `description:"当前访谈申请状态:'待邀请','待访谈','已完成','已取消'"`
  302. InterviewDate string `description:"访谈时间"`
  303. ExpertBackground string `description:"专家背景"`
  304. ExpertNumber string `description:"专家编号"`
  305. Department string `description:"作者"`
  306. SellerMobile string `description:"销售手机号"`
  307. SellerName string `description:"销售名称"`
  308. ArticleIdMd5 string `description:"纪要id"`
  309. }
  310. func GetArticleCountById(articleId int) (count int, err error) {
  311. o := orm.NewOrm()
  312. sql := `SELECT COUNT(1) AS count FROM cygx_article WHERE article_id = ? `
  313. err = o.Raw(sql, articleId).QueryRow(&count)
  314. return
  315. }
  316. type CygxArticles struct {
  317. Id int `orm:"column(id);pk"`
  318. ArticleId int `description:"文章id"`
  319. Title string `description:"标题"`
  320. TitleEn string `description:"英文标题 "`
  321. UpdateFrequency string `description:"更新周期"`
  322. CreateDate string `description:"创建时间"`
  323. PublishDate string `description:"发布时间"`
  324. Body string `description:"内容"`
  325. BodyText string `description:"内容"`
  326. Abstract string `description:"摘要"`
  327. CategoryName string `description:"一级分类"`
  328. SubCategoryName string `description:"二级分类"`
  329. PublishStatus int `description:"发布状态"`
  330. CategoryId int `description:"分类id"`
  331. ExpertBackground string `description:"专家背景"`
  332. ExpertNumber string `description:"专家编号"`
  333. InterviewDate string `description:"访谈日期"`
  334. Department string `description:"作者"`
  335. ArticleIdMd5 string `description:"ID,md5值"`
  336. IsClass int `description:"是否归类,1是,0否"`
  337. IsSummary int `description:"是否是纪要库,1是,0否"`
  338. IsReport int `description:"是否属于报告,1是,0否"`
  339. ReportType int `description:"报告类型,1行业报告,2产业报告,0无"`
  340. }
  341. // 新增文章
  342. func AddCygxArticles(item *CygxArticle) (lastId int64, err error) {
  343. o := orm.NewOrm()
  344. lastId, err = o.Insert(item)
  345. return
  346. }
  347. func GetPermissionMappingById(categoryId int) (count int, err error) {
  348. o := orm.NewOrm()
  349. sql := `SELECT COUNT(1) AS count FROM cygx_permission_mapping WHERE category_id = ? `
  350. err = o.Raw(sql, categoryId).QueryRow(&count)
  351. return
  352. }
  353. func GetReportMappingById(categoryId int) (count int, err error) {
  354. o := orm.NewOrm()
  355. sql := `SELECT COUNT(1) AS count FROM cygx_report_mapping WHERE category_id = ? `
  356. err = o.Raw(sql, categoryId).QueryRow(&count)
  357. return
  358. }
  359. type ReportArticle struct {
  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. Abstract string `description:"摘要"`
  368. CategoryName string `description:"一级分类"`
  369. SubCategoryName string `description:"二级分类"`
  370. ExpertBackground string `description:"专家背景"`
  371. IsRed bool `description:"是否标记红点"`
  372. Readnum int `description:"阅读数量"`
  373. VideoUrl string `description:"链接"`
  374. IsHaveVideo bool `description:"是否含有音频文件"`
  375. ImgUrlPc string `description:"图片链接"`
  376. CategoryId string `description:"文章分类"`
  377. Annotation string `description:"核心观点"`
  378. Resource int `description:"来源类型,1:文章、2:产品内测"`
  379. }
  380. func GetReportPermission(categoryName string) (item []*ChartPermission, err error) {
  381. o := orm.NewOrm()
  382. sql := ` SELECT b.* FROM cygx_report_mapping AS a
  383. INNER JOIN chart_permission AS b ON a.chart_permission_id=b.chart_permission_id
  384. WHERE a.sub_category_name=? `
  385. _, err = o.Raw(sql, categoryName).QueryRows(&item)
  386. return
  387. }
  388. type ReportMappingCategoryRep struct {
  389. CategoryId int `description:"文章分类id"`
  390. }
  391. func GetReportMappingCategoryID() (item []*ReportMappingCategoryRep, err error) {
  392. o := orm.NewOrm()
  393. sql := ` SELECT category_id FROM cygx_permission_mapping GROUP BY category_id `
  394. _, err = o.Raw(sql).QueryRows(&item)
  395. return
  396. }
  397. type PermissionMappingCategoryRep struct {
  398. CategoryId int `description:"文章分类id"`
  399. }
  400. func GetPermissionMappingCategoryID() (item []*PermissionMappingCategoryRep, err error) {
  401. o := orm.NewOrm()
  402. sql := ` SELECT category_id FROM cygx_report_mapping GROUP BY category_id `
  403. _, err = o.Raw(sql).QueryRows(&item)
  404. return
  405. }
  406. // 检查用户是否阅读某一分类最新文章
  407. func GetUserIsReadThisNewCategoryArticleCount(categoryId, uid int) (count int, err error) {
  408. sqlCount := `SELECT
  409. COUNT( 1 ) AS count
  410. FROM
  411. cygx_article_history_record
  412. WHERE
  413. 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 )
  414. AND user_id = ?`
  415. o := orm.NewOrm()
  416. err = o.Raw(sqlCount, categoryId, uid).QueryRow(&count)
  417. return
  418. }
  419. type ArticleId struct {
  420. ArticleId int `description:"文章id"`
  421. }
  422. type ArticleIdAndTitle struct {
  423. Title string `description:"标题"`
  424. ArticleId int `description:"文章id"`
  425. }
  426. // 获取自定义分类的文章ID
  427. func GetCustomArticleId() (item []*ArticleId, err error) {
  428. o := orm.NewOrm()
  429. sql := ` SELECT article_id FROM cygx_article WHERE is_custom = 1 `
  430. _, err = o.Raw(sql).QueryRows(&item)
  431. return
  432. }
  433. type ArticleFollowDetail struct {
  434. DNum int `description:"作者被关注的数量"`
  435. MdNum int `description:"本人是否关注这个作者"`
  436. AcNum int `description:"文章被收藏的数量"`
  437. MacNum int `description:"本人是否收藏这个文章"`
  438. }
  439. // 获取文章被关注被收藏的详情
  440. func GetArticleFollowDetail(articleId, uid int) (item *ArticleFollowDetail, err error) {
  441. //d_num 作者被关注的数量 、 md_num 本人是否关注这个作者 、ac_num 文章被收藏的数量 、 mac_num 本人是否收藏这个文章
  442. o := orm.NewOrm()
  443. sql := ` SELECT
  444. ( SELECT count( 1 ) FROM cygx_article_department_follow AS af INNER JOIN wx_user as u ON u.user_id = af.user_id WHERE af.department_id = art.department_id AND af.type = 1 ) AS d_num,
  445. ( 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,
  446. ( SELECT count( 1 ) FROM cygx_article_collect AS ac INNER JOIN wx_user as u ON u.user_id = ac.user_id WHERE ac.article_id = art.article_id ) AS ac_num,
  447. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = art.article_id AND ac.user_id = ? ) AS mac_num
  448. FROM
  449. cygx_article AS art
  450. LEFT JOIN cygx_article_department_follow AS af ON af.department_id = art.department_id
  451. LEFT JOIN cygx_article_collect AS ac ON ac.article_id = art.article_id
  452. WHERE
  453. art.article_id = ?
  454. GROUP BY art.article_id `
  455. err = o.Raw(sql, uid, uid, articleId).QueryRow(&item)
  456. return
  457. }
  458. // 日度点评的数据同步
  459. type ReportDetail struct {
  460. Id int `orm:"column(id)" description:"报告Id"`
  461. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  462. ClassifyIdFirst int `description:"一级分类id"`
  463. ClassifyNameFirst string `description:"一级分类名称"`
  464. ClassifyIdSecond int `description:"二级分类id"`
  465. ClassifyNameSecond string `description:"二级分类名称"`
  466. Title string `description:"标题"`
  467. Abstract string `description:"摘要"`
  468. Author string `description:"作者"`
  469. Frequency string `description:"频度"`
  470. CreateTime string `description:"创建时间"`
  471. ModifyTime string `description:"修改时间"`
  472. State int `description:"1:未发布,2:已发布"`
  473. PublishTime string `description:"发布时间"`
  474. Stage int `description:"期数"`
  475. MsgIsSend int `description:"消息是否已发送,0:否,1:是"`
  476. Content string `description:"内容"`
  477. VideoUrl string `description:"音频文件URL"`
  478. VideoName string `description:"音频文件名称"`
  479. VideoPlaySeconds string `description:"音频播放时长"`
  480. ContentSub string `description:"内容前两个章节"`
  481. }
  482. func GetReportList() (items []*ReportDetail, err error) {
  483. o := orm.NewOrmUsingDB("rddp")
  484. sql := `SELECT * FROM report WHERE classify_id_second = '57'`
  485. _, err = o.Raw(sql).QueryRows(&items)
  486. return
  487. }
  488. func GetMaxArticleIdInfo() (item *ArticleDetail, err error) {
  489. o := orm.NewOrm()
  490. sql := `SELECT * FROM cygx_article ORDER BY article_id desc LIMIT 1`
  491. err = o.Raw(sql).QueryRow(&item)
  492. return
  493. }
  494. type ArticleResultApi struct {
  495. Data []ArticleResultApidate `json:"data"`
  496. Code int `json:"code"`
  497. Msg string `json:"msg"`
  498. }
  499. type ArticleDetailResultApi struct {
  500. Data ArticleResultApidate `json:"data"`
  501. Code int `json:"code"`
  502. Msg string `json:"msg"`
  503. }
  504. type ArticleResultApidate struct {
  505. ArticleId int `json:"id"`
  506. Title string `json:"title"`
  507. File string `json:"file"`
  508. TitleEn string `json:"title_en"`
  509. Frequency string `json:"frequency"`
  510. CreateDate string `json:"create_date"`
  511. UpdateDate string `json:"update_date"`
  512. PublishDate time.Time `json:"publish_date"`
  513. PublishStatus int `json:"publish_status"`
  514. IndustrId int `json:"industry_id"`
  515. SeriesId int `json:"series_id"`
  516. Series ArticleSeries `json:"series"`
  517. Content ArticleResultApiContent `json:"content"`
  518. Author ArticleResultApiAuthor `json:"author"`
  519. Industry ArticleResultApiIndustry `json:"industry"`
  520. Type ArticleResultApiType `json:"type"`
  521. Stock []string `json:"stock"`
  522. Field ArticleField `json:"field"`
  523. Corpus Corpus `json:"corpus"`
  524. Cover string `json:"cover"`
  525. TypeId int `json:"type_id"`
  526. IsActive bool `json:"is_active"`
  527. }
  528. type ArticleField struct {
  529. Id int `json:"id"`
  530. Name string `json:"name"`
  531. Description string `json:"description"`
  532. IndustryId int `json:"industry_id"`
  533. }
  534. type Corpus struct {
  535. Id int `json:"id"`
  536. ArticleId int `json:"article_id"`
  537. Corpus string `json:"corpus"`
  538. }
  539. type ArticleSeries struct {
  540. Name string `json:"name"`
  541. }
  542. type ArticleResultApiContent struct {
  543. ArticleId int `json:"id"`
  544. Body string `json:"body"`
  545. Abstract string `json:"abstract"`
  546. Annotation string `json:"annotation"`
  547. }
  548. type ArticleResultApiAuthor struct {
  549. PhoneNumber string `json:"phone_number"`
  550. Name string `json:"name"`
  551. }
  552. type ArticleResultApiIndustry struct {
  553. Name string `json:"name"`
  554. }
  555. type ArticleResultApiType struct {
  556. Name string `json:"name"`
  557. }
  558. type ArticleIndustryApi struct {
  559. Data []ArticleResultApiIndustrdate `json:"data"`
  560. Code int `json:"code"`
  561. Msg string `json:"msg"`
  562. }
  563. type ArticleResultApiIndustrdate struct {
  564. Id int `json:"id"`
  565. Name string `json:"name"`
  566. Series []ArticleResultApiSeriesdate `json:"series"`
  567. }
  568. type ArticleResultApiSeriesdate struct {
  569. Id int `json:"id"`
  570. Name string `json:"name"`
  571. }
  572. type ArticleApiMap struct {
  573. Id int `description:"新ID"`
  574. OldId int `description:"旧Id"`
  575. IsClass int `description:"是否自动归类,1是,0否"`
  576. IsReport int `description:"是否属于报告,1是,0否"`
  577. IsSummary int `description:"是否属于纪要,1是,0否"`
  578. }
  579. func GetArticleApiMap() (item []*ArticleApiMap, err error) {
  580. o := orm.NewOrm()
  581. sql := ` SELECT * FROM cygx_article_api_map WHERE old_id > 0 AND is_update = 1 ORDER BY old_id ASC `
  582. _, err = o.Raw(sql).QueryRows(&item)
  583. return
  584. }
  585. func GetArticleIdSubjectGroup(keyWord string) (articleid string, err error) {
  586. o := orm.NewOrm()
  587. sql := ` SELECT
  588. GROUP_CONCAT(DISTINCT art.article_id SEPARATOR ',') AS articleid
  589. FROM
  590. cygx_article AS art
  591. INNER JOIN cygx_industrial_article_group_subject AS sg ON sg.article_id = art.article_id
  592. INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = sg.industrial_subject_id
  593. WHERE
  594. s.subject_name LIKE '%` + keyWord + `%' `
  595. err = o.Raw(sql).QueryRow(&articleid)
  596. return
  597. }
  598. func GetArticleIndustrialIdGroup(keyWord string) (articleid string, err error) {
  599. o := orm.NewOrm()
  600. sql := ` SELECT
  601. GROUP_CONCAT(DISTINCT art.article_id SEPARATOR ',') AS article_id
  602. FROM
  603. cygx_article AS art
  604. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = art.article_id
  605. INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  606. WHERE
  607. m.industry_name LIKE '%` + keyWord + `%' `
  608. err = o.Raw(sql).QueryRow(&articleid)
  609. return
  610. }
  611. // 通过文章ID获取文章所关联的标的ID
  612. func GetSubjectIds(articleId int) (subjects string, err error) {
  613. sql := ` SELECT
  614. GROUP_CONCAT( DISTINCT industrial_subject_id ORDER BY id ASC SEPARATOR ',' ) AS subjects
  615. FROM
  616. cygx_industrial_article_group_subject WHERE article_id = ?`
  617. o := orm.NewOrm()
  618. err = o.Raw(sql, articleId).QueryRow(&subjects)
  619. return
  620. }
  621. // 修改发布状态
  622. func UpdateIsClassFail(articleId int) (err error) {
  623. sql := `UPDATE cygx_article SET is_class_fail=1 WHERE article_id=? `
  624. o := orm.NewOrm()
  625. _, err = o.Raw(sql, articleId).Exec()
  626. return
  627. }
  628. type SummaryArticleStock struct {
  629. Id int `description:"新ID"`
  630. ArticleId int `description:"文章id"`
  631. Stock string `description:"个股标签"`
  632. }
  633. // 综述报告
  634. func GetSummaryArticle(chartPermissionId int) (items []*SummaryArticleStock, err error) {
  635. o := orm.NewOrm()
  636. sql := `SELECT
  637. *
  638. FROM
  639. cygx_article AS c
  640. INNER JOIN cygx_report_mapping AS m
  641. WHERE
  642. c.type_name = '综述报告'
  643. AND m.category_id = c.category_id_two
  644. AND m.chart_permission_id = ? ORDER BY modify_time_by_cl DESC `
  645. _, err = o.Raw(sql, chartPermissionId).QueryRows(&items)
  646. return
  647. }
  648. type SummaryArticleStockResp struct {
  649. List []*SummaryArticleStock
  650. }
  651. // 综述报告
  652. func GetArticleStock() (items []*SummaryArticleStock, err error) {
  653. o := orm.NewOrm()
  654. sql := `SELECT
  655. stock,article_id
  656. FROM
  657. cygx_article AS art
  658. WHERE
  659. 1 = 1
  660. AND type_name = '综述报告' `
  661. _, err = o.Raw(sql).QueryRows(&items)
  662. return
  663. }