article.go 29 KB

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