article.go 29 KB

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