article.go 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxArticle struct {
  7. Id int `orm:"column(id);pk"`
  8. ArticleId int `description:"文章id"`
  9. Title string `description:"标题"`
  10. TitleEn string `description:"英文标题 "`
  11. UpdateFrequency string `description:"更新周期"`
  12. CreateDate string `description:"创建时间"`
  13. PublishDate string `description:"发布时间"`
  14. Body string `description:"内容"`
  15. BodyText string `description:"内容"`
  16. Abstract string `description:"摘要"`
  17. CategoryName string `description:"一级分类"`
  18. SubCategoryName string `description:"二级分类"`
  19. PublishStatus int `description:"发布状态"`
  20. CategoryId int `description:"分类id"`
  21. ExpertBackground string `description:"专家背景"`
  22. ExpertNumber string `description:"专家编号"`
  23. InterviewDate string `description:"访谈日期"`
  24. Department string `description:"作者"`
  25. ArticleIdMd5 string `description:"ID,md5值"`
  26. IsClass int `description:"是否归类,1是,0否"`
  27. IsSummary int `description:"是否是纪要库,1是,0否"`
  28. IsReport int `description:"是否属于报告,1是,0否"`
  29. ReportType int `description:"报告类型,1行业报告,2产业报告,0无"`
  30. FileLink string `description:"下载预览链接"`
  31. MatchTypeName string `description:"匹配类型"`
  32. Periods string `description:"期数"`
  33. ReportLink string `description:"报告链接"`
  34. ArticleType string `description:"文章类型 文章类型,lyjh:路演精华 "`
  35. HavePublish int `description:"是否发布过,1是 ,0 否"`
  36. Source int `description:"来源 0策略平台同步,1小程序后台添加"`
  37. SellerAndMobile string `description:"销售和手机号"`
  38. VideoUrl string `description:"音频文件URL"`
  39. VideoName string `description:"音频文件名称"`
  40. VideoPlaySeconds string `description:"音频播放时长"`
  41. }
  42. type CygxArticleEs struct {
  43. Id int `orm:"column(id);pk"`
  44. ArticleId int `description:"文章id"`
  45. Title string `description:"标题"`
  46. TitleEn string `description:"英文标题 "`
  47. UpdateFrequency string `description:"更新周期"`
  48. CreateDate string `description:"创建时间"`
  49. PublishDate string `description:"发布时间"`
  50. Body string `description:"内容"`
  51. BodyText string `description:"内容"`
  52. Abstract string `description:"摘要"`
  53. CategoryName string `description:"一级分类"`
  54. SubCategoryName string `description:"二级分类"`
  55. PublishStatus int `description:"发布状态"`
  56. CategoryId string `description:"分类id"`
  57. ExpertBackground string `description:"专家背景"`
  58. ExpertNumber string `description:"专家编号"`
  59. InterviewDate string `description:"访谈日期"`
  60. Department string `description:"作者"`
  61. ArticleIdMd5 string `description:"ID,md5值"`
  62. IsClass int `description:"是否归类,1是,0否"`
  63. IsSummary bool `description:"是否是纪要库,1是,0否"`
  64. IsReport bool `description:"是否属于报告,1是,0否"`
  65. ReportType int `description:"报告类型,1行业报告,2产业报告,0无"`
  66. FileLink string `description:"下载预览链接"`
  67. MatchTypeName string `description:"匹配类型"`
  68. }
  69. //新增文章
  70. func AddCygxArticle(item *CygxArticle) (lastId int64, err error) {
  71. o := orm.NewOrm()
  72. lastId, err = o.Insert(item)
  73. return
  74. }
  75. type HomeArticle struct {
  76. ArticleId int `description:"文章id"`
  77. Title string `description:"标题"`
  78. TitleEn string `description:"英文标题 "`
  79. UpdateFrequency string `description:"更新周期"`
  80. CreateDate string `description:"创建时间"`
  81. PublishDate string `description:"发布时间"`
  82. Body string `description:"内容"`
  83. BodyHtml string `description:"内容带有HTML标签"`
  84. Abstract string `description:"摘要"`
  85. CategoryName string `description:"一级分类"`
  86. SubCategoryName string `description:"二级分类"`
  87. ExpertBackground string `description:"专家背景"`
  88. IsResearch bool `description:"是否属于研选"`
  89. Pv int `description:"PV"`
  90. ImgUrlPc string `description:"图片链接"`
  91. CategoryId string `description:"文章分类"`
  92. HttpUrl string `description:"文章链接跳转地址"`
  93. IsNeedJump bool `description:"是否需要跳转链接地址"`
  94. }
  95. type ArticleDetail struct {
  96. ArticleId int `description:"报告id"`
  97. Title string `description:"标题"`
  98. TitleEn string `description:"英文标题 "`
  99. UpdateFrequency string `description:"更新周期"`
  100. CreateDate string `description:"创建时间"`
  101. PublishDate string `description:"发布时间"`
  102. Body string `description:"内容"`
  103. Abstract string `description:"摘要"`
  104. CategoryName string `description:"一级分类"`
  105. SubCategoryName string `description:"二级分类"`
  106. IsCollect bool `description:"是否收藏:true,已收藏,false:未收藏"`
  107. IsInterviewApply bool `description:"是否申请访谈:true,已申请,false:未申请"`
  108. BodyText string `description:"内容"`
  109. InterviewApplyStatus string `description:"当前访谈申请状态:'待邀请','待访谈','已完成','已取消'"`
  110. InterviewDate string `description:"访谈时间"`
  111. ExpertBackground string `description:"专家背景"`
  112. ExpertNumber string `description:"专家编号"`
  113. Department string `description:"作者"`
  114. SellerMobile string `description:"销售手机号"`
  115. SellerName string `description:"销售名称"`
  116. ArticleIdMd5 string `description:"纪要id"`
  117. IsClass int `description:"是否归类,1是,0否"`
  118. CategoryId int `description:"分类ID"`
  119. IsSummary int `description:"是否是纪要库,1是,0否"`
  120. IsReport int `description:"是否属于报告,1是,0否"`
  121. IsResearch bool `description:"是否属于研选"`
  122. FileLink string `description:"下载预览链接"`
  123. SellerAndMobile string `description:"销售和手机号"`
  124. IsFollow bool `description:"是否关注,1是,0否"`
  125. IsBelongSummary bool `description:"是否属于纪要库"`
  126. IsBelongReport bool `description:"是否属于报告"`
  127. FollowNum int `description:"关注数量"`
  128. CollectionNum int `description:"收藏数量"`
  129. DepartmentId int `description:"作者ID"`
  130. DepartmentImgUrl string `description:"作者头像"`
  131. SubjectIds string `description:"文章关联标的的ID字符串"`
  132. IndustrialAndSubjectIds string `description:"文章关联产业和标的的ID字符串"`
  133. IndustrialManagementId int `description:"文章关联产业ID"`
  134. SellerList []*SellerRep
  135. HttpUrl string `description:"文章链接跳转地址"`
  136. IsNeedJump bool `description:"是否需要跳转链接地址"`
  137. }
  138. type ArticleDetailFileLink struct {
  139. FileLink string `description:"下载预览链接"`
  140. }
  141. type SellerRep struct {
  142. SellerMobile string `description:"销售手机号"`
  143. SellerName string `description:"销售名称"`
  144. }
  145. func GetArticleDetailById(articleId int) (item *ArticleDetail, err error) {
  146. o := orm.NewOrm()
  147. sql := `SELECT * FROM cygx_article WHERE article_id = ? `
  148. err = o.Raw(sql, articleId).QueryRow(&item)
  149. return
  150. }
  151. func GetSellerList(articleId int) (items []*SellerRep, err error) {
  152. o := orm.NewOrm()
  153. //o.Using("tactics")
  154. //sql := `SELECT
  155. // ac.phone_number as seller_mobile,
  156. // ac.name as seller_name
  157. // FROM
  158. // article_author AS au
  159. // INNER JOIN account_client as ac ON au.author_id = ac.phone_number
  160. // WHERE article_id = ?`
  161. sql := `SELECT
  162. au.mobile as seller_mobile,
  163. au.name as seller_name
  164. FROM
  165. cygx_article_author AS au
  166. WHERE article_id = ?`
  167. _, err = o.Raw(sql, articleId).QueryRows(&items)
  168. return
  169. }
  170. func GetArticleDetailByIdMd5(articleIdMd5 string) (item *ArticleDetail, err error) {
  171. o := orm.NewOrm()
  172. sql := `SELECT * FROM cygx_article WHERE article_id_md5 = ? `
  173. err = o.Raw(sql, articleIdMd5).QueryRow(&item)
  174. return
  175. }
  176. func GetArticleDetailByIdStr(articleIdStr string) (items []*ArticleDetail, err error) {
  177. o := orm.NewOrm()
  178. sql := `SELECT * FROM cygx_article WHERE article_id IN(` + articleIdStr + `) `
  179. _, err = o.Raw(sql).QueryRows(&items)
  180. return
  181. }
  182. //func GetArticlePermission(categoryName string) (item []*ChartPermission, err error) {
  183. // o := orm.NewOrm()
  184. // sql := ` SELECT b.* FROM cygx_permission_mapping AS a
  185. // INNER JOIN chart_permission AS b ON a.chart_permission_id=b.chart_permission_id
  186. // WHERE a.sub_category_name=? `
  187. // _, err = o.Raw(sql, categoryName).QueryRows(&item)
  188. // return
  189. //}
  190. func GetArticlePermission(companyId int) (item *ChartPermission, err error) {
  191. o := orm.NewOrm()
  192. sql := `SELECT
  193. b.*
  194. FROM
  195. cygx_report_mapping AS a
  196. INNER JOIN chart_permission AS b ON a.chart_permission_id = b.chart_permission_id
  197. WHERE
  198. a.category_id = ?`
  199. err = o.Raw(sql, companyId).QueryRow(&item)
  200. //_, err = o.Raw(sql, companyId).QueryRows(&item)
  201. return
  202. }
  203. type ArticleDetailResp struct {
  204. Detail *ArticleDetail
  205. HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
  206. HasFree int `description:"1:已付费(至少包含一个品类的权限),2:未付费(没有任何品类权限)"`
  207. HaveResearch bool `description:"是否有研选权限"`
  208. Mobile string `description:"用户手机号"`
  209. }
  210. type ArticleDetailHtgjResp struct {
  211. HasPermission int `description:"1:有该行业权限,正常展示,0:试用期已过期"`
  212. CompanyName string `description:"公司名称"`
  213. Detail *ArticleDetail
  214. }
  215. func ModifyArticleExpert(articleId int, expertNumStr, expertContentStr, interviewDateStr, bodyText string) (err error) {
  216. o := orm.NewOrm()
  217. sql := `UPDATE cygx_article SET expert_background=?,expert_number=?,interview_date=?,body_text=? WHERE article_id=? `
  218. _, err = o.Raw(sql, expertContentStr, expertNumStr, interviewDateStr, bodyText, articleId).Exec()
  219. return
  220. }
  221. type ArticleDetailTest struct {
  222. ArticleId int `description:"报告id"`
  223. Title string `description:"标题"`
  224. BodyText string `description:"内容"`
  225. Body string `json:"-" description:"内容"`
  226. }
  227. func GetArticleDetailTestById(articleId int) (item *ArticleDetailTest, err error) {
  228. o := orm.NewOrm()
  229. sql := `SELECT * FROM cygx_article WHERE article_id = ? `
  230. err = o.Raw(sql, articleId).QueryRow(&item)
  231. return
  232. }
  233. func GetArticleAll() (item []*ArticleDetail, err error) {
  234. o := orm.NewOrm()
  235. sql := `SELECT * FROM cygx_article WHERE is_summary=1 `
  236. _, err = o.Raw(sql).QueryRows(&item)
  237. return
  238. }
  239. func GetArticleAllDate(endDate string) (item []*ArticleDetail, err error) {
  240. o := orm.NewOrm()
  241. sql := `SELECT * FROM cygx_article WHERE is_summary=1 AND publish_date >= ? `
  242. _, err = o.Raw(sql, endDate).QueryRows(&item)
  243. return
  244. }
  245. func GetArticleAll2() (item []*ArticleDetail, err error) {
  246. o := orm.NewOrm()
  247. sql := `SELECT * FROM cygx_article `
  248. _, err = o.Raw(sql).QueryRows(&item)
  249. return
  250. }
  251. func ModifyArticleContent(articleId int, content, expertNumStr, expertContentStr, interviewDateStr string) (err error) {
  252. o := orm.NewOrm()
  253. sql := `UPDATE cygx_article SET body=?,expert_background=?,expert_number=?,interview_date=? WHERE article_id=? `
  254. _, err = o.Raw(sql, content, expertContentStr, expertNumStr, interviewDateStr, articleId).Exec()
  255. return
  256. }
  257. type ElasticArticleDetail struct {
  258. ArticleId int `description:"报告id"`
  259. Title string `description:"标题"`
  260. TitleEn string `description:"英文标题 "`
  261. UpdateFrequency string `description:"更新周期"`
  262. CreateDate string `description:"创建时间"`
  263. PublishDate string `description:"发布时间"`
  264. Abstract string `description:"摘要"`
  265. CategoryName string `description:"一级分类"`
  266. SubCategoryName string `description:"二级分类"`
  267. IsCollect bool `description:"是否收藏:true,已收藏,false:未收藏"`
  268. IsInterviewApply bool `description:"是否申请访谈:true,已申请,false:未申请"`
  269. BodyText string `description:"内容"`
  270. InterviewApplyStatus string `description:"当前访谈申请状态:'待邀请','待访谈','已完成','已取消'"`
  271. InterviewDate string `description:"访谈时间"`
  272. ExpertBackground string `description:"专家背景"`
  273. ExpertNumber string `description:"专家编号"`
  274. Department string `description:"作者"`
  275. SellerMobile string `description:"销售手机号"`
  276. SellerName string `description:"销售名称"`
  277. ArticleIdMd5 string `description:"纪要id"`
  278. }
  279. func GetArticleCountById(articleId int) (count int, err error) {
  280. o := orm.NewOrm()
  281. sql := `SELECT COUNT(1) AS count FROM cygx_article WHERE article_id = ? `
  282. err = o.Raw(sql, articleId).QueryRow(&count)
  283. return
  284. }
  285. type CygxArticles struct {
  286. Id int `orm:"column(id);pk"`
  287. ArticleId int `description:"文章id"`
  288. Title string `description:"标题"`
  289. TitleEn string `description:"英文标题 "`
  290. UpdateFrequency string `description:"更新周期"`
  291. CreateDate string `description:"创建时间"`
  292. PublishDate string `description:"发布时间"`
  293. Body string `description:"内容"`
  294. BodyText string `description:"内容"`
  295. Abstract string `description:"摘要"`
  296. CategoryName string `description:"一级分类"`
  297. SubCategoryName string `description:"二级分类"`
  298. PublishStatus int `description:"发布状态"`
  299. CategoryId int `description:"分类id"`
  300. ExpertBackground string `description:"专家背景"`
  301. ExpertNumber string `description:"专家编号"`
  302. InterviewDate string `description:"访谈日期"`
  303. Department string `description:"作者"`
  304. ArticleIdMd5 string `description:"ID,md5值"`
  305. IsClass int `description:"是否归类,1是,0否"`
  306. IsSummary int `description:"是否是纪要库,1是,0否"`
  307. IsReport int `description:"是否属于报告,1是,0否"`
  308. ReportType int `description:"报告类型,1行业报告,2产业报告,0无"`
  309. }
  310. //新增文章
  311. func AddCygxArticles(item *CygxArticle) (lastId int64, err error) {
  312. o := orm.NewOrm()
  313. lastId, err = o.Insert(item)
  314. return
  315. }
  316. func GetPermissionMappingById(categoryId int) (count int, err error) {
  317. o := orm.NewOrm()
  318. sql := `SELECT COUNT(1) AS count FROM cygx_permission_mapping WHERE category_id = ? `
  319. err = o.Raw(sql, categoryId).QueryRow(&count)
  320. return
  321. }
  322. func GetReportMappingById(categoryId int) (count int, err error) {
  323. o := orm.NewOrm()
  324. sql := `SELECT COUNT(1) AS count FROM cygx_report_mapping WHERE category_id = ? `
  325. err = o.Raw(sql, categoryId).QueryRow(&count)
  326. return
  327. }
  328. type ReportArticle struct {
  329. ArticleId int `description:"文章id"`
  330. Title string `description:"标题"`
  331. TitleEn string `description:"英文标题 "`
  332. UpdateFrequency string `description:"更新周期"`
  333. CreateDate string `description:"创建时间"`
  334. PublishDate string `description:"发布时间"`
  335. Body string `description:"内容"`
  336. Abstract string `description:"摘要"`
  337. CategoryName string `description:"一级分类"`
  338. SubCategoryName string `description:"二级分类"`
  339. ExpertBackground string `description:"专家背景"`
  340. IsRed bool `description:"是否标记红点"`
  341. Readnum int `description:"阅读数量"`
  342. VideoUrl string `description:"链接"`
  343. IsHaveVideo bool `description:"是否含有音频文件"`
  344. ImgUrlPc string `description:"图片链接"`
  345. CategoryId string `description:"文章分类"`
  346. }
  347. func GetReportPermission(categoryName string) (item []*ChartPermission, err error) {
  348. o := orm.NewOrm()
  349. sql := ` SELECT b.* FROM cygx_report_mapping AS a
  350. INNER JOIN chart_permission AS b ON a.chart_permission_id=b.chart_permission_id
  351. WHERE a.sub_category_name=? `
  352. _, err = o.Raw(sql, categoryName).QueryRows(&item)
  353. return
  354. }
  355. type ReportMappingCategoryRep struct {
  356. CategoryId int `description:"文章分类id"`
  357. }
  358. func GetReportMappingCategoryID() (item []*ReportMappingCategoryRep, err error) {
  359. o := orm.NewOrm()
  360. sql := ` SELECT category_id FROM cygx_permission_mapping GROUP BY category_id `
  361. _, err = o.Raw(sql).QueryRows(&item)
  362. return
  363. }
  364. type PermissionMappingCategoryRep struct {
  365. CategoryId int `description:"文章分类id"`
  366. }
  367. func GetPermissionMappingCategoryID() (item []*PermissionMappingCategoryRep, err error) {
  368. o := orm.NewOrm()
  369. sql := ` SELECT category_id FROM cygx_report_mapping GROUP BY category_id `
  370. _, err = o.Raw(sql).QueryRows(&item)
  371. return
  372. }
  373. //检查用户是否阅读某一分类最新文章
  374. func GetUserIsReadThisNewCategoryArticleCount(categoryId, uid int) (count int, err error) {
  375. sqlCount := `SELECT COUNT(1) as count FROM
  376. cygx_article_history_record
  377. WHERE
  378. article_id = ( SELECT article_id FROM cygx_article WHERE category_id = ? ORDER BY publish_date DESC LIMIT 0, 1 )
  379. AND user_id = ?`
  380. o := orm.NewOrm()
  381. err = o.Raw(sqlCount, categoryId, uid).QueryRow(&count)
  382. return
  383. }
  384. type ArticleId struct {
  385. ArticleId int `description:"文章id"`
  386. }
  387. //获取自定义分类的文章ID
  388. func GetCustomArticleId() (item []*ArticleId, err error) {
  389. o := orm.NewOrm()
  390. sql := ` SELECT article_id FROM cygx_article WHERE is_custom = 1 `
  391. _, err = o.Raw(sql).QueryRows(&item)
  392. return
  393. }
  394. type ArticleFollowDetail struct {
  395. DNum int `description:"作者被关注的数量"`
  396. MdNum int `description:"本人是否关注这个作者"`
  397. AcNum int `description:"文章被收藏的数量"`
  398. MacNum int `description:"本人是否收藏这个文章"`
  399. }
  400. //获取文章被关注被收藏的详情
  401. func GetArticleFollowDetail(articleId, uid int) (item *ArticleFollowDetail, err error) {
  402. //d_num 作者被关注的数量 、 md_num 本人是否关注这个作者 、ac_num 文章被收藏的数量 、 mac_num 本人是否收藏这个文章
  403. o := orm.NewOrm()
  404. sql := ` SELECT
  405. ( SELECT count( 1 ) FROM cygx_article_department_follow AS af INNER JOIN wx_user as u ON u.user_id = af.user_id WHERE af.department_id = art.department_id AND af.type = 1 ) AS d_num,
  406. ( 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,
  407. ( SELECT count( 1 ) FROM cygx_article_collect AS ac INNER JOIN wx_user as u ON u.user_id = ac.user_id WHERE ac.article_id = art.article_id ) AS ac_num,
  408. ( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = art.article_id AND ac.user_id = ? ) AS mac_num
  409. FROM
  410. cygx_article AS art
  411. LEFT JOIN cygx_article_department_follow AS af ON af.department_id = art.department_id
  412. LEFT JOIN cygx_article_collect AS ac ON ac.article_id = art.article_id
  413. WHERE
  414. art.article_id = ?
  415. GROUP BY art.article_id `
  416. err = o.Raw(sql, uid, uid, articleId).QueryRow(&item)
  417. return
  418. }
  419. //日度点评的数据同步
  420. type ReportDetail struct {
  421. Id int `orm:"column(id)" description:"报告Id"`
  422. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  423. ClassifyIdFirst int `description:"一级分类id"`
  424. ClassifyNameFirst string `description:"一级分类名称"`
  425. ClassifyIdSecond int `description:"二级分类id"`
  426. ClassifyNameSecond string `description:"二级分类名称"`
  427. Title string `description:"标题"`
  428. Abstract string `description:"摘要"`
  429. Author string `description:"作者"`
  430. Frequency string `description:"频度"`
  431. CreateTime string `description:"创建时间"`
  432. ModifyTime string `description:"修改时间"`
  433. State int `description:"1:未发布,2:已发布"`
  434. PublishTime string `description:"发布时间"`
  435. Stage int `description:"期数"`
  436. MsgIsSend int `description:"消息是否已发送,0:否,1:是"`
  437. Content string `description:"内容"`
  438. VideoUrl string `description:"音频文件URL"`
  439. VideoName string `description:"音频文件名称"`
  440. VideoPlaySeconds string `description:"音频播放时长"`
  441. ContentSub string `description:"内容前两个章节"`
  442. }
  443. func GetReportList() (items []*ReportDetail, err error) {
  444. o := orm.NewOrmUsingDB("rddp")
  445. sql := `SELECT * FROM report WHERE classify_id_second = '57'`
  446. _, err = o.Raw(sql).QueryRows(&items)
  447. return
  448. }
  449. func GetMaxArticleIdInfo() (item *ArticleDetail, err error) {
  450. o := orm.NewOrm()
  451. sql := `SELECT * FROM cygx_article ORDER BY article_id desc LIMIT 1`
  452. err = o.Raw(sql).QueryRow(&item)
  453. return
  454. }
  455. type ArticleResultApi struct {
  456. Data []ArticleResultApidate `json:"data"`
  457. Code int `json:"code"`
  458. Msg string `json:"msg"`
  459. }
  460. type ArticleResultApidate struct {
  461. ArticleId int `json:"id"`
  462. Title string `json:"title"`
  463. TitleEn string `json:"title_en"`
  464. Frequency string `json:"frequency"`
  465. CreateDate string `json:"create_date"`
  466. UpdateDate string `json:"update_date"`
  467. PublishDate time.Time `json:"publish_date"`
  468. PublishStatus int `json:"publish_status"`
  469. IndustrId int `json:"industry_id"`
  470. SeriesId int `json:"series_id"`
  471. Series ArticleSeries `json:"series"`
  472. Content ArticleResultApiContent `json:"content"`
  473. Author ArticleResultApiAuthor `json:"author"`
  474. Industry ArticleResultApiIndustry `json:"industry"`
  475. Type ArticleResultApiType `json:"type"`
  476. }
  477. type ArticleSeries struct {
  478. Name string `json:"name"`
  479. }
  480. type ArticleResultApiContent struct {
  481. ArticleId int `json:"id"`
  482. Body string `json:"body"`
  483. Abstract string `json:"abstract"`
  484. }
  485. type ArticleResultApiAuthor struct {
  486. PhoneNumber string `json:"phone_number"`
  487. Name string `json:"name"`
  488. }
  489. type ArticleResultApiIndustry struct {
  490. Name string `json:"name"`
  491. }
  492. type ArticleResultApiType struct {
  493. Name string `json:"name"`
  494. }
  495. type ArticleIndustryApi struct {
  496. Data []ArticleResultApiIndustrdate `json:"data"`
  497. Code int `json:"code"`
  498. Msg string `json:"msg"`
  499. }
  500. type ArticleResultApiIndustrdate struct {
  501. Id int `json:"id"`
  502. Name string `json:"name"`
  503. Series []ArticleResultApiSeriesdate `json:"series"`
  504. }
  505. type ArticleResultApiSeriesdate struct {
  506. Id int `json:"id"`
  507. Name string `json:"name"`
  508. }
  509. type ArticleApiMap struct {
  510. Id int `description:"新ID"`
  511. OldId int `description:"旧Id"`
  512. IsClass int `description:"是否自动归类,1是,0否"`
  513. IsReport int `description:"是否属于报告,1是,0否"`
  514. IsSummary int `description:"是否属于纪要,1是,0否"`
  515. }
  516. func GetArticleApiMap() (item []*ArticleApiMap, err error) {
  517. o := orm.NewOrm()
  518. sql := ` SELECT * FROM cygx_article_api_map WHERE old_id > 0 AND is_update = 1 ORDER BY old_id ASC `
  519. _, err = o.Raw(sql).QueryRows(&item)
  520. return
  521. }
  522. func GetArticleIdSubjectGroup(keyWord string) (articleid string, err error) {
  523. o := orm.NewOrm()
  524. sql := ` SELECT
  525. GROUP_CONCAT(DISTINCT art.article_id SEPARATOR ',') AS articleid
  526. FROM
  527. cygx_article AS art
  528. INNER JOIN cygx_industrial_article_group_subject AS sg ON sg.article_id = art.article_id
  529. INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = sg.industrial_subject_id
  530. WHERE
  531. s.subject_name LIKE '%` + keyWord + `%' `
  532. err = o.Raw(sql).QueryRow(&articleid)
  533. return
  534. }
  535. func GetArticleIndustrialIdGroup(keyWord string) (articleid string, err error) {
  536. o := orm.NewOrm()
  537. sql := ` SELECT
  538. GROUP_CONCAT(DISTINCT art.article_id SEPARATOR ',') AS article_id
  539. FROM
  540. cygx_article AS art
  541. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = art.article_id
  542. INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
  543. WHERE
  544. m.industry_name LIKE '%` + keyWord + `%' `
  545. err = o.Raw(sql).QueryRow(&articleid)
  546. return
  547. }