article.go 43 KB

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