article.go 45 KB

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