article.go 43 KB

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