article.go 44 KB

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