report.go 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "hongze/hongze_cygx/models"
  6. "hongze/hongze_cygx/services"
  7. "hongze/hongze_cygx/utils"
  8. "html"
  9. "rdluck_tools/paging"
  10. "strconv"
  11. "strings"
  12. "time"
  13. )
  14. //报告
  15. type ReportController struct {
  16. BaseAuthController
  17. }
  18. type ReportCommonController struct {
  19. BaseCommonController
  20. }
  21. // @Title 行业报告分类列表接口
  22. // @Description 获取行业报告分类列表接口
  23. // @Param ChartPermissionId query int true "分类ID"
  24. // @Success 200 {object} models.IndustrialManagementList
  25. // @router /home/tradeList [get]
  26. func (this *ReportController) TradeList() {
  27. br := new(models.BaseResponse).Init()
  28. defer func() {
  29. this.Data["json"] = br
  30. this.ServeJSON()
  31. }()
  32. user := this.User
  33. if user == nil {
  34. br.Msg = "请重新登录"
  35. br.Ret = 408
  36. return
  37. }
  38. uid := user.UserId
  39. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  40. if ChartPermissionId < 1 {
  41. br.Msg = "请输入分类ID"
  42. return
  43. }
  44. list, err := models.GetTradeAll(ChartPermissionId)
  45. if err != nil {
  46. br.Msg = "获取信息失败"
  47. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  48. return
  49. }
  50. for k, v := range list {
  51. list[k].UpdateTime = utils.TimeRemoveHms(v.UpdateTime)
  52. count, err := models.CheckThisCategoryNewArticleIsRead(uid, v.CategoryId)
  53. if err != nil {
  54. br.Msg = "获取信息失败"
  55. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  56. return
  57. }
  58. if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.UpdateTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.UpdateTime)) {
  59. list[k].IsRed = true
  60. }
  61. }
  62. resp := new(models.TradeReportMappingResp)
  63. resp.List = list
  64. br.Ret = 200
  65. br.Success = true
  66. br.Msg = "获取成功"
  67. br.Data = resp
  68. }
  69. // @Title 产业报告分类列表接口
  70. // @Description 获取产业报告分类列表接口
  71. // @Param ChartPermissionId query int true "分类ID"
  72. // @Param IsNewLabel query string true "是否属于新标签,1是,0否"
  73. // @Param IsDeepLabel query string true "是否属于深标签,1是,0否"
  74. // @Param KeyWord query string true "搜索关键词"
  75. // @Param OrderColumn query int true "排序字段 ,NewTime 最近更新 ,Recommend弘则推荐"
  76. // @Param PageSize query int true "每页数据条数"
  77. // @Param CurrentIndex query int true "当前页页码,从1开始"
  78. // @Success 200 {object} models.IndustrialManagementList
  79. // @router /home/industryList [get]
  80. func (this *ReportController) IndustryList() {
  81. br := new(models.BaseResponse).Init()
  82. defer func() {
  83. this.Data["json"] = br
  84. this.ServeJSON()
  85. }()
  86. user := this.User
  87. if user == nil {
  88. br.Msg = "请重新登录"
  89. br.Ret = 408
  90. return
  91. }
  92. uid := user.UserId
  93. fmt.Println(uid)
  94. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  95. orderColumn := this.GetString("OrderColumn")
  96. isNewLabel := this.GetString("IsNewLabel")
  97. isDeepLabel := this.GetString("IsDeepLabel")
  98. keyWord := this.GetString("KeyWord")
  99. pageSize, _ := this.GetInt("PageSize")
  100. currentIndex, _ := this.GetInt("CurrentIndex")
  101. var orderSrt string
  102. var condition string
  103. var startSize int
  104. resp := new(models.IndustrialManagementList)
  105. if pageSize <= 0 {
  106. pageSize = utils.PageSize20
  107. }
  108. if currentIndex <= 0 {
  109. currentIndex = 1
  110. }
  111. startSize = paging.StartIndex(currentIndex, pageSize)
  112. if isNewLabel == "1" {
  113. condition += ` AND is_new_label = ` + isNewLabel
  114. }
  115. if isDeepLabel == "1" {
  116. condition += ` AND is_deep_label = ` + isDeepLabel
  117. }
  118. if keyWord != "" {
  119. //keyWordArr, err := services.GetIndustryMapNameSliceV2(keyWord)
  120. //if err != nil {
  121. // br.Msg = "获取信息失败"
  122. // br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  123. // return
  124. //}
  125. //var conditionkeyWord string
  126. //conditionkeyWord += ` subject_names LIKE '%` + keyWord + `%'`
  127. //keyWordArr = services.RemoveDuplicatesAndEmpty(keyWordArr)
  128. //keyWordLen := len(keyWordArr)
  129. //if keyWordLen <= 0 {
  130. // keyWordArr = append(keyWordArr, keyWord)
  131. // keyWordLen = len(keyWordArr)
  132. //}
  133. //for _, v := range keyWordArr {
  134. // conditionkeyWord += ` OR subject_names LIKE '%` + v + `%'`
  135. //}
  136. //industrialManagementIds, err := models.GetIndustrialManagementIdsBykeyWord(conditionkeyWord)
  137. //if err != nil {
  138. // br.Msg = "获取信息失败"
  139. // br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  140. // return
  141. //}
  142. //if industrialManagementIds == "" {
  143. // br.Ret = 200
  144. // br.Success = true
  145. // br.Msg = "获取成功"
  146. // br.Data = resp
  147. // return
  148. //}
  149. //condition += ` AND man.industrial_management_id IN (` + industrialManagementIds + `)`
  150. condition += ` AND subject_names LIKE '%` + keyWord + `%'`
  151. }
  152. var sqlChartPermissionId string
  153. if ChartPermissionId > 0 {
  154. sqlChartPermissionId += ` AND man_g.industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_management WHERE chart_permission_id = ` + strconv.Itoa(ChartPermissionId) + ` ) `
  155. condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
  156. }
  157. var list []*models.IndustrialManagement
  158. total, err := models.GetIndustrialManagementAllCount(condition)
  159. if err != nil {
  160. br.Msg = "获取信息失败"
  161. br.ErrMsg = "获取数量失败,Err:" + err.Error()
  162. return
  163. }
  164. page := paging.GetPaging(currentIndex, pageSize, total)
  165. if orderColumn == "" {
  166. orderColumn = "NewTime"
  167. }
  168. if orderColumn == "NewTime" {
  169. orderSrt = "update_time DESC"
  170. } else {
  171. orderSrt = "man.recommended_index DESC,update_time DESC"
  172. }
  173. if ChartPermissionId == 0 {
  174. ChartPermissionId = 20
  175. }
  176. detailHot3, err := models.GetIndustrialManagementHot3(ChartPermissionId)
  177. if err != nil {
  178. br.Msg = "获取信息失败"
  179. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  180. return
  181. }
  182. list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize)
  183. if err != nil {
  184. br.Msg = "获取信息失败"
  185. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  186. return
  187. }
  188. for k, v := range list {
  189. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  190. if err != nil {
  191. br.Msg = "获取信息失败"
  192. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  193. return
  194. }
  195. list[k].IndustrialSubjectList = industrialSubjectList
  196. list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  197. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  198. if err != nil {
  199. br.Msg = "获取信息失败"
  200. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  201. return
  202. }
  203. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  204. recordCount, err := models.GetUserToArticleCount(uid, newArtinfo.ArticleId)
  205. if err != nil && err.Error() != utils.ErrNoRow() {
  206. br.Msg = "获取信息失败"
  207. br.ErrMsg = "获取信息失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(newArtinfo.ArticleId)
  208. return
  209. }
  210. if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(newArtinfo.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(newArtinfo.PublishDate)) {
  211. list[k].IsRed = true
  212. }
  213. if v.ArticleReadNum >= detailHot3.ArticleReadNum {
  214. list[k].IsHot = true
  215. }
  216. }
  217. resp.List = list
  218. resp.Paging = page
  219. br.Ret = 200
  220. br.Success = true
  221. br.Msg = "获取成功"
  222. br.Data = resp
  223. }
  224. // @Title 产业下所关联的文章分类列表
  225. // @Description 产业下所关联的文章分类列表接口
  226. // @Param IndustrialManagementId query int true "产业ID"
  227. // @Success 200 {object} models.IndustrialToArticleCategoryListRep
  228. // @router /toArticleCategoryList [get]
  229. func (this *ReportController) ArticleCategoryList() {
  230. br := new(models.BaseResponse).Init()
  231. defer func() {
  232. this.Data["json"] = br
  233. this.ServeJSON()
  234. }()
  235. user := this.User
  236. if user == nil {
  237. br.Msg = "请重新登录"
  238. br.Ret = 408
  239. return
  240. }
  241. uid := user.UserId
  242. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  243. if industrialManagementId < 1 {
  244. br.Msg = "请输入分类ID"
  245. return
  246. }
  247. list, err := models.IndustrialToArticleCategory(industrialManagementId)
  248. if err != nil {
  249. br.Msg = "获取信息失败"
  250. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  251. return
  252. }
  253. for k, v := range list {
  254. recordCount, err := models.IndustrialUserRecordArticleCount(uid, industrialManagementId, v.CategoryId)
  255. if err != nil && err.Error() != utils.ErrNoRow() {
  256. br.Msg = "获取信息失败"
  257. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  258. return
  259. }
  260. Newdetail, err := models.GetNewIndustrialUserRecordArticle(industrialManagementId, v.CategoryId)
  261. if err != nil {
  262. br.Msg = "获取信息失败"
  263. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  264. return
  265. }
  266. if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
  267. list[k].IsRed = true
  268. }
  269. }
  270. detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  271. if err != nil {
  272. br.Msg = "获取信息失败"
  273. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  274. return
  275. }
  276. resp := new(models.IndustrialToArticleCategoryListRep)
  277. resp.List = list
  278. resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
  279. resp.IndustryName = detail.IndustryName
  280. resp.IndustrialManagementId = industrialManagementId
  281. br.Ret = 200
  282. br.Success = true
  283. br.Msg = "获取成功"
  284. br.Data = resp
  285. }
  286. // @Title 产业文章列表接口
  287. // @Description 获取产业文章列表接口
  288. // @Param PageSize query int true "每页数据条数"
  289. // @Param CurrentIndex query int true "当前页页码,从1开始"
  290. // @Param CategoryId query int true "分类ID"
  291. // @Param IndustrialManagementId query int true "产业ID"
  292. // @Success 200 {object} models.TacticsListResp
  293. // @router /industry/ArticleList [get]
  294. func (this *ReportController) List() {
  295. br := new(models.BaseResponse).Init()
  296. defer func() {
  297. this.Data["json"] = br
  298. this.ServeJSON()
  299. }()
  300. user := this.User
  301. if user == nil {
  302. br.Msg = "请重新登录"
  303. br.Ret = 408
  304. return
  305. }
  306. uid := user.UserId
  307. pageSize, _ := this.GetInt("PageSize")
  308. currentIndex, _ := this.GetInt("CurrentIndex")
  309. categoryId, _ := this.GetInt("CategoryId")
  310. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  311. var startSize int
  312. if pageSize <= 0 {
  313. pageSize = utils.PageSize20
  314. }
  315. if currentIndex <= 0 {
  316. currentIndex = 1
  317. }
  318. startSize = paging.StartIndex(currentIndex, pageSize)
  319. var pars []interface{}
  320. var total int
  321. resp := new(models.TacticsListResp)
  322. page := paging.GetPaging(currentIndex, pageSize, total)
  323. if categoryId < 1 {
  324. br.Msg = "请输入分类ID"
  325. return
  326. }
  327. if industrialManagementId < 1 {
  328. br.Msg = "请输入产业ID"
  329. return
  330. }
  331. total, err := models.GetReportIndustrialCount(categoryId, industrialManagementId)
  332. if err != nil {
  333. br.Msg = "获取信息失败"
  334. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  335. return
  336. }
  337. page = paging.GetPaging(currentIndex, pageSize, total)
  338. list, err := models.GetReportIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
  339. if err != nil {
  340. br.Msg = "获取信息失败"
  341. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  342. return
  343. }
  344. lenList := len(list)
  345. for i := 0; i < lenList; i++ {
  346. item := list[i]
  347. list[i].Body, _ = services.GetReportContentTextSub(item.Body)
  348. //list[i].Abstract = html.UnescapeString(item.Abstract)
  349. list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  350. }
  351. for k, v := range list {
  352. if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  353. list[k].IsRed = true
  354. }
  355. if v.VideoUrl != "" {
  356. list[k].IsHaveVideo = true
  357. }
  358. }
  359. resp.List = list
  360. resp.Paging = page
  361. br.Ret = 200
  362. br.Success = true
  363. br.Msg = "获取成功"
  364. br.Data = resp
  365. }
  366. // @Title 置顶/取消置顶
  367. // @Description 置顶
  368. // @Param request body models.CygxIndustryTopRep true "type json string"
  369. // @Success 200
  370. // @router /top [post]
  371. func (this *ReportController) ArticleCollect() {
  372. br := new(models.BaseResponse).Init()
  373. defer func() {
  374. this.Data["json"] = br
  375. this.ServeJSON()
  376. }()
  377. user := this.User
  378. if user == nil {
  379. br.Msg = "请重新登录"
  380. br.Ret = 408
  381. return
  382. }
  383. uid := user.UserId
  384. var req models.CygxIndustryTopRep
  385. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  386. if err != nil {
  387. br.Msg = "参数解析异常!"
  388. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  389. return
  390. }
  391. industrialManagementId := req.IndustrialManagementId
  392. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  393. if err != nil {
  394. br.Msg = "获取数据失败!"
  395. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  396. return
  397. }
  398. if countIndustrial == 0 {
  399. br.Msg = "产业不存在!"
  400. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  401. return
  402. }
  403. count, err := models.GetCygxIndustryTop(uid, industrialManagementId)
  404. if err != nil {
  405. br.Msg = "获取数据失败!"
  406. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  407. return
  408. }
  409. resp := new(models.ArticleCollectResp)
  410. if count <= 0 {
  411. item := new(models.CygxIndustryTop)
  412. item.IndustrialManagementId = req.IndustrialManagementId
  413. item.UserId = uid
  414. item.CreateTime = time.Now()
  415. _, err = models.AddCygxIndustryTop(item)
  416. if err != nil {
  417. br.Msg = "置顶失败"
  418. br.ErrMsg = "置顶失败,Err:" + err.Error()
  419. return
  420. }
  421. br.Msg = "置顶成功"
  422. resp.Status = 1
  423. } else {
  424. err = models.RemoveCygxIndustryTop(uid, industrialManagementId)
  425. if err != nil {
  426. br.Msg = "取消置顶失败"
  427. br.ErrMsg = "取消置顶失败,Err:" + err.Error()
  428. return
  429. }
  430. br.Msg = "已取消置顶"
  431. resp.Status = 2
  432. }
  433. br.Ret = 200
  434. br.Success = true
  435. br.Data = resp
  436. }
  437. // @Title 关注/取消关注产业
  438. // @Description 关注/取消关注 接口
  439. // @Param request body models.CygxIndustryFllowRep true "type json string"
  440. // @Success 200
  441. // @router /fllow [post]
  442. func (this *ReportController) Fllow() {
  443. br := new(models.BaseResponse).Init()
  444. defer func() {
  445. this.Data["json"] = br
  446. this.ServeJSON()
  447. }()
  448. user := this.User
  449. if user == nil {
  450. br.Msg = "请重新登录"
  451. br.Ret = 408
  452. return
  453. }
  454. uid := user.UserId
  455. var req models.CygxIndustryFllowRep
  456. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  457. if err != nil {
  458. br.Msg = "参数解析异常!"
  459. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  460. return
  461. }
  462. industrialManagementId := req.IndustrialManagementId
  463. var condition string
  464. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  465. if err != nil {
  466. br.Msg = "获取数据失败!"
  467. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  468. return
  469. }
  470. if countIndustrial == 0 {
  471. br.Msg = "产业不存在!"
  472. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  473. return
  474. }
  475. count, err := models.GetCountCygxIndustryFllow(uid, industrialManagementId, condition)
  476. if err != nil {
  477. br.Msg = "获取数据失败!"
  478. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  479. return
  480. }
  481. resp := new(models.CygxIndustryFllowResp)
  482. countUser, err := models.GetCountCygxIndustryFllowByUid(uid)
  483. if countUser == 0 {
  484. resp.GoFollow = true
  485. }
  486. if count == 0 {
  487. item := new(models.CygxIndustryFllow)
  488. item.IndustrialManagementId = industrialManagementId
  489. item.UserId = uid
  490. item.Email = user.Email
  491. item.Mobile = user.Mobile
  492. item.CompanyId = user.CompanyId
  493. item.CompanyName = user.CompanyName
  494. item.Type = 1
  495. item.CreateTime = time.Now()
  496. item.ModifyTime = time.Now()
  497. _, err = models.AddCygxIndustryFllow(item)
  498. if err != nil {
  499. br.Msg = "操作失败"
  500. br.ErrMsg = "操作失败,Err:" + err.Error()
  501. return
  502. }
  503. resp.Status = 1
  504. } else {
  505. var doType int
  506. condition = ` AND type = 1`
  507. count, err = models.GetCountCygxIndustryFllow(uid, industrialManagementId, condition)
  508. if err != nil {
  509. br.Msg = "操作失败!"
  510. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  511. return
  512. }
  513. if count == 1 {
  514. resp.Status = 2
  515. doType = 2
  516. } else {
  517. resp.Status = 1
  518. doType = 1
  519. }
  520. err = models.RemoveCygxIndustryFllow(uid, industrialManagementId, doType)
  521. if err != nil {
  522. br.Msg = "操作失败"
  523. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  524. return
  525. }
  526. }
  527. br.Msg = "操作成功"
  528. br.Ret = 200
  529. br.Success = true
  530. br.Data = resp
  531. }
  532. // @Title 产业报告分类关联作者列表接口
  533. // @Description 获取产业报告分类关联作者列表接口
  534. // @Param ChartPermissionId query int true "分类ID"
  535. // @Param PageSize query int true "每页数据条数"
  536. // @Param CurrentIndex query int true "当前页页码,从1开始"
  537. // @Success 200 {object} models.CygxArticleDepartmentList
  538. // @router /industryListByDepartment [get]
  539. func (this *ReportController) IndustryListByDepartment() {
  540. br := new(models.BaseResponse).Init()
  541. defer func() {
  542. this.Data["json"] = br
  543. this.ServeJSON()
  544. }()
  545. user := this.User
  546. if user == nil {
  547. br.Msg = "请重新登录"
  548. br.Ret = 408
  549. return
  550. }
  551. uid := user.UserId
  552. pageSize, _ := this.GetInt("PageSize")
  553. currentIndex, _ := this.GetInt("CurrentIndex")
  554. //chartPermissionId, _ := this.GetInt("ChartPermissionId")
  555. var startSize int
  556. var condition string
  557. //condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  558. condition = ` AND a.publish_status=1 `
  559. if pageSize <= 0 {
  560. pageSize = utils.PageSize20
  561. }
  562. if currentIndex <= 0 {
  563. currentIndex = 1
  564. }
  565. startSize = paging.StartIndex(currentIndex, pageSize)
  566. total, err := models.GetArticleDepartmentCount(condition)
  567. page := paging.GetPaging(currentIndex, pageSize, total)
  568. resp := new(models.CygxArticleDepartmentList)
  569. userType, _, err := services.GetUserType(user.CompanyId)
  570. if err != nil {
  571. br.Msg = "获取信息失败"
  572. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  573. return
  574. }
  575. if userType == 1 {
  576. resp.Paging = page
  577. br.Ret = 200
  578. br.Success = true
  579. br.Msg = "获取成功"
  580. br.Data = resp
  581. return
  582. }
  583. resp.HaveResearch = true
  584. //获取作者信息,并排序
  585. list, err := models.GetCygxArticleDepartmentList(startSize, pageSize, condition, uid)
  586. if err != nil {
  587. br.Msg = "获取信息失败"
  588. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  589. return
  590. }
  591. for k, v := range list {
  592. artList, err := models.GetArticleByDepartmentId(v.DepartmentId)
  593. if err != nil {
  594. br.Msg = "获取信息失败"
  595. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  596. return
  597. }
  598. for k2, v2 := range artList {
  599. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  600. if err != nil {
  601. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  602. br.ErrMsg = "获取失败,Err:" + err.Error()
  603. return
  604. }
  605. var subjectNamesNew string
  606. if len(subjectNames) > 0 {
  607. slice := strings.Split(subjectNames, "/")
  608. for k3, v3 := range slice {
  609. if k3 < 4 {
  610. subjectNamesNew += v3 + "/"
  611. }
  612. }
  613. }
  614. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  615. if err != nil && err.Error() != utils.ErrNoRow() {
  616. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  617. br.ErrMsg = "获取失败,Err:" + err.Error()
  618. return
  619. }
  620. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  621. artList[k2].SubjectName = subjectNamesNew
  622. artList[k2].DepartmentId = v.DepartmentId
  623. if subjectNamesNew == "" {
  624. artList[k2].IndustryName = industryName
  625. } else {
  626. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  627. }
  628. if artList[k2].IsReport == "1" {
  629. artList[k2].IndustryName = "【观点】" + artList[k2].IndustryName
  630. } else {
  631. artList[k2].IndustryName = "【纪要】" + artList[k2].IndustryName
  632. }
  633. }
  634. list[k].List = artList
  635. if v.FollowNum > 0 {
  636. list[k].IsMyFollow = true
  637. }
  638. }
  639. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  640. if err != nil {
  641. br.Msg = "获取信息失败"
  642. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  643. return
  644. }
  645. if len(listnNew) > 0 {
  646. for _, v := range listnNew {
  647. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  648. Management := new(models.IndustrialManagementIdInt)
  649. if firstStr == 0 {
  650. Management.IndustryName = v.IndustryName
  651. } else {
  652. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  653. if err != nil {
  654. br.Msg = "获取信息失败"
  655. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  656. return
  657. }
  658. var subjectNamesNew string
  659. for _, v1 := range listSub {
  660. subjectNamesNew += v1.SubjectName + "/"
  661. }
  662. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  663. Management.IndustryName = subjectNamesNew
  664. }
  665. Management.IndustrialManagementId = v.IndustrialManagementId
  666. Management.ArticleId = v.ArticleId
  667. resp.ListnNew = append(resp.ListnNew, Management)
  668. }
  669. }
  670. resp.List = list
  671. resp.Paging = page
  672. br.Ret = 200
  673. br.Success = true
  674. br.Msg = "获取成功"
  675. br.Data = resp
  676. }
  677. // @Title 关注作者/取消关注作者
  678. // @Description 关注作者/取消关注作者 接口
  679. // @Param request body models.CygxArticleDepartmentId true "type json string"
  680. // @Success 200
  681. // @router /fllowDepartment [post]
  682. func (this *ReportController) FllowDepartment() {
  683. br := new(models.BaseResponse).Init()
  684. defer func() {
  685. this.Data["json"] = br
  686. this.ServeJSON()
  687. }()
  688. user := this.User
  689. if user == nil {
  690. br.Msg = "请重新登录"
  691. br.Ret = 408
  692. return
  693. }
  694. uid := user.UserId
  695. var req models.CygxArticleDepartmentId
  696. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  697. if err != nil {
  698. br.Msg = "参数解析异常!"
  699. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  700. return
  701. }
  702. departmentId := req.DepartmentId
  703. var condition string
  704. countDepartment, err := models.GetDepartmentCount(departmentId)
  705. if err != nil {
  706. br.Msg = "获取数据失败!"
  707. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  708. return
  709. }
  710. if countDepartment == 0 {
  711. br.Msg = "作者不存在!"
  712. br.ErrMsg = "作者ID不存在:" + strconv.Itoa(departmentId)
  713. return
  714. }
  715. countUser, err := models.GetArticleDepartmentFollowByUid(uid)
  716. count, err := models.GetArticleDepartmentFollow(uid, departmentId, condition)
  717. if err != nil {
  718. br.Msg = "获取数据失败!"
  719. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  720. return
  721. }
  722. resp := new(models.CygxArticleDepartmentFollowResp)
  723. if countUser == 0 {
  724. resp.GoFollow = true
  725. }
  726. if count == 0 {
  727. item := new(models.CygxArticleDepartmentFollow)
  728. item.DepartmentId = departmentId
  729. item.UserId = uid
  730. item.Email = user.Email
  731. item.Mobile = user.Mobile
  732. item.CompanyId = user.CompanyId
  733. item.CompanyName = user.CompanyName
  734. item.Type = 1
  735. item.CreateTime = time.Now()
  736. item.ModifyTime = time.Now()
  737. _, err = models.AddArticleDepartmentFollow(item)
  738. if err != nil {
  739. br.Msg = "操作失败"
  740. br.ErrMsg = "操作失败,Err:" + err.Error()
  741. return
  742. }
  743. resp.Status = 1
  744. } else {
  745. var doType int
  746. condition = ` AND type = 1`
  747. count, err = models.GetArticleDepartmentFollow(uid, departmentId, condition)
  748. if err != nil {
  749. br.Msg = "操作失败!"
  750. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  751. return
  752. }
  753. if count == 1 {
  754. resp.Status = 2
  755. doType = 2
  756. } else {
  757. resp.Status = 1
  758. doType = 1
  759. }
  760. err = models.RemoveArticleDepartmentFollow(uid, departmentId, doType)
  761. if err != nil {
  762. br.Msg = "操作失败"
  763. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  764. return
  765. }
  766. }
  767. br.Msg = "操作成功"
  768. br.Ret = 200
  769. br.Success = true
  770. br.Data = resp
  771. }
  772. // @Title 研选文章列表接口
  773. // @Description 获取研选文章列表接口
  774. // @Param PageSize query int true "每页数据条数"
  775. // @Param CurrentIndex query int true "当前页页码,从1开始"
  776. // @Param ArticleId query int true "文章id"
  777. // @Param DepartmentId query int true "作者ID"
  778. // @Param IndustrialManagementId query int true "产业ID"
  779. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  780. // @router /industry/reportList [get]
  781. func (this *ReportController) ReportList() {
  782. br := new(models.BaseResponse).Init()
  783. defer func() {
  784. this.Data["json"] = br
  785. this.ServeJSON()
  786. }()
  787. user := this.User
  788. if user == nil {
  789. br.Msg = "请重新登录"
  790. br.Ret = 408
  791. return
  792. }
  793. uid := user.UserId
  794. pageSize, _ := this.GetInt("PageSize")
  795. currentIndex, _ := this.GetInt("CurrentIndex")
  796. departmentId, _ := this.GetInt("DepartmentId")
  797. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  798. articleId, _ := this.GetInt("ArticleId")
  799. var condition string
  800. var startSize int
  801. if pageSize <= 0 {
  802. pageSize = utils.PageSize20
  803. }
  804. if currentIndex <= 0 {
  805. currentIndex = 1
  806. }
  807. startSize = paging.StartIndex(currentIndex, pageSize)
  808. var pars []interface{}
  809. var total int
  810. resp := new(models.ReportArticleWhichIndustrialRepList)
  811. page := paging.GetPaging(currentIndex, pageSize, total)
  812. userType, _, err := services.GetUserType(user.CompanyId)
  813. if err != nil {
  814. br.Msg = "获取信息失败"
  815. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  816. return
  817. }
  818. if userType == 1 {
  819. resp.Paging = page
  820. br.Ret = 200
  821. br.Success = true
  822. br.Msg = "获取成功"
  823. br.Data = resp
  824. return
  825. }
  826. resp.HaveResearch = true
  827. if departmentId > 0 {
  828. condition += ` AND art.department_id = ` + strconv.Itoa(departmentId)
  829. detail, err := models.GetArticleDepartmentDateilById(departmentId)
  830. if err != nil {
  831. br.Msg = "获取信息失败"
  832. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  833. return
  834. }
  835. resp.NickName = detail.NickName
  836. }
  837. if industrialManagementId > 0 {
  838. condition += ` AND m.industrial_management_id = ` + strconv.Itoa(industrialManagementId)
  839. }
  840. if articleId > 0 {
  841. detail, err := models.GetArticleDetailById(articleId)
  842. if err != nil {
  843. br.Msg = "获取信息失败"
  844. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  845. return
  846. }
  847. condition += ` AND art.subject_ids = '` + detail.SubjectIds + `'`
  848. }
  849. total, err = models.GetWhichDepartmentCount(condition)
  850. if err != nil {
  851. br.Msg = "获取信息失败"
  852. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  853. return
  854. }
  855. page = paging.GetPaging(currentIndex, pageSize, total)
  856. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  857. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  858. if err != nil {
  859. br.Msg = "获取失败"
  860. br.ErrMsg = "获取失败,Err:" + err.Error()
  861. return
  862. }
  863. for k, v := range list {
  864. if v.Readnum == 0 {
  865. list[k].IsRed = true
  866. }
  867. list[k].IsResearch = true
  868. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  869. if err != nil {
  870. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  871. br.ErrMsg = "获取失败,Err:" + err.Error()
  872. return
  873. }
  874. var subjectNamesNew string
  875. if len(subjectNames) > 0 {
  876. slice := strings.Split(subjectNames, "/")
  877. for k3, v3 := range slice {
  878. if k3 < 4 {
  879. subjectNamesNew += v3 + "/"
  880. }
  881. }
  882. }
  883. industryName, err := models.GetIndustrialNames(v.ArticleId)
  884. if err != nil && err.Error() != utils.ErrNoRow() {
  885. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  886. br.ErrMsg = "获取失败,Err:" + err.Error()
  887. return
  888. }
  889. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  890. list[k].SubjectName = subjectNamesNew
  891. if subjectNamesNew != "" {
  892. list[k].IndustryName = industryName + "-" + subjectNamesNew
  893. } else {
  894. list[k].IndustryName = industryName
  895. }
  896. resp.IndustryName = industryName
  897. }
  898. resp.List = list
  899. resp.Paging = page
  900. br.Ret = 200
  901. br.Success = true
  902. br.Msg = "获取成功"
  903. br.Data = resp
  904. }
  905. // @Title 研选最新主题关键词文章列表接口
  906. // @Description 获取研选最新主题关键词文章列表接口
  907. // @Param PageSize query int true "每页数据条数"
  908. // @Param CurrentIndex query int true "当前页页码,从1开始"
  909. // @Param ArticleId query int true "文章id"
  910. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  911. // @router /industry/reportListNew [get]
  912. func (this *ReportController) ReportListNew() {
  913. br := new(models.BaseResponse).Init()
  914. defer func() {
  915. this.Data["json"] = br
  916. this.ServeJSON()
  917. }()
  918. user := this.User
  919. if user == nil {
  920. br.Msg = "请重新登录"
  921. br.Ret = 408
  922. return
  923. }
  924. uid := user.UserId
  925. pageSize, _ := this.GetInt("PageSize")
  926. currentIndex, _ := this.GetInt("CurrentIndex")
  927. articleId, _ := this.GetInt("ArticleId")
  928. var condition string
  929. var startSize int
  930. if pageSize <= 0 {
  931. pageSize = utils.PageSize20
  932. }
  933. if currentIndex <= 0 {
  934. currentIndex = 1
  935. }
  936. startSize = paging.StartIndex(currentIndex, pageSize)
  937. var pars []interface{}
  938. var total int
  939. resp := new(models.ReportArticleWhichIndustrialRepList)
  940. page := paging.GetPaging(currentIndex, pageSize, total)
  941. userType, _, err := services.GetUserType(user.CompanyId)
  942. if err != nil {
  943. br.Msg = "获取信息失败"
  944. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  945. return
  946. }
  947. if userType == 1 {
  948. resp.Paging = page
  949. br.Ret = 200
  950. br.Success = true
  951. br.Msg = "获取成功"
  952. br.Data = resp
  953. return
  954. }
  955. resp.HaveResearch = true
  956. if articleId > 0 {
  957. detail, err := models.GetArticleDetailById(articleId)
  958. if err != nil {
  959. br.Msg = "获取信息失败"
  960. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  961. return
  962. }
  963. firstStr := strings.Index(detail.IndustrialAndSubjectIds, "—")
  964. if firstStr == 0 {
  965. condition += ` AND art.industrial_management_id = '` + strconv.Itoa(detail.IndustrialManagementId) + `'`
  966. } else {
  967. condition += ` AND art.industrial_and_subject_ids = '` + detail.IndustrialAndSubjectIds + `'`
  968. }
  969. }
  970. total, err = models.GetWhichDepartmentCount(condition)
  971. if err != nil {
  972. br.Msg = "获取信息失败"
  973. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  974. return
  975. }
  976. page = paging.GetPaging(currentIndex, pageSize, total)
  977. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  978. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  979. if err != nil {
  980. br.Msg = "获取失败"
  981. br.ErrMsg = "获取失败,Err:" + err.Error()
  982. return
  983. }
  984. for k, v := range list {
  985. if v.Readnum == 0 {
  986. list[k].IsRed = true
  987. }
  988. list[k].IsResearch = true
  989. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  990. if err != nil {
  991. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  992. br.ErrMsg = "获取失败,Err:" + err.Error()
  993. return
  994. }
  995. var subjectNamesNew string
  996. if len(subjectNames) > 0 {
  997. slice := strings.Split(subjectNames, "/")
  998. for k3, v3 := range slice {
  999. if k3 < 4 {
  1000. subjectNamesNew += v3 + "/"
  1001. }
  1002. }
  1003. }
  1004. industryName, err := models.GetIndustrialNames(v.ArticleId)
  1005. if err != nil && err.Error() != utils.ErrNoRow() {
  1006. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1007. br.ErrMsg = "获取失败,Err:" + err.Error()
  1008. return
  1009. }
  1010. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1011. list[k].SubjectName = subjectNamesNew
  1012. if subjectNamesNew != "" {
  1013. list[k].IndustryName = industryName + "-" + subjectNamesNew
  1014. } else {
  1015. list[k].IndustryName = industryName
  1016. }
  1017. resp.IndustryName = industryName
  1018. }
  1019. resp.List = list
  1020. resp.Paging = page
  1021. br.Ret = 200
  1022. br.Success = true
  1023. br.Msg = "获取成功"
  1024. br.Data = resp
  1025. }
  1026. // @Title 是否展示绝密内参
  1027. // @Description 获取是否展示绝密内参接口
  1028. // @Param request body models.IsShow true "type json string"
  1029. // @Success 200
  1030. // @router /isShow [get]
  1031. func (this *ReportController) IsShow() {
  1032. br := new(models.BaseResponse).Init()
  1033. defer func() {
  1034. this.Data["json"] = br
  1035. this.ServeJSON()
  1036. }()
  1037. user := this.User
  1038. if user == nil {
  1039. br.Msg = "请重新登录"
  1040. br.Ret = 408
  1041. return
  1042. }
  1043. var resp models.IsShow
  1044. mobile := user.Mobile
  1045. if mobile == "" {
  1046. br.Ret = 200
  1047. br.Success = true
  1048. br.Data = resp
  1049. return
  1050. }
  1051. total, _ := models.GetUserIsAdminCount(mobile)
  1052. if total > 0 {
  1053. resp.IsShow = true
  1054. }
  1055. br.Ret = 200
  1056. br.Success = true
  1057. br.Data = resp
  1058. }
  1059. // @Title 报告精选、本周研究汇总、上周纪要汇总列表
  1060. // @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
  1061. // @Param PageSize query int true "每页数据条数"
  1062. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1063. // @Param ReportType string query true "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
  1064. // @Success 200 {object} models.CygxReportSelectionListPublicRep
  1065. // @router /reportList/byType [get]
  1066. func (this *ReportController) ReportListByType() {
  1067. br := new(models.BaseResponse).Init()
  1068. defer func() {
  1069. this.Data["json"] = br
  1070. this.ServeJSON()
  1071. }()
  1072. user := this.User
  1073. if user == nil {
  1074. br.Msg = "请重新登录"
  1075. br.Ret = 408
  1076. return
  1077. }
  1078. uid := user.UserId
  1079. pageSize, _ := this.GetInt("PageSize")
  1080. currentIndex, _ := this.GetInt("CurrentIndex")
  1081. reportType := this.GetString("ReportType")
  1082. var condition string
  1083. var startSize int
  1084. if pageSize <= 0 {
  1085. pageSize = utils.PageSize20
  1086. }
  1087. if currentIndex <= 0 {
  1088. currentIndex = 1
  1089. }
  1090. startSize = paging.StartIndex(currentIndex, pageSize)
  1091. var pars []interface{}
  1092. var total int
  1093. resp := new(models.CygxReportSelectionListPublicRep)
  1094. page := paging.GetPaging(currentIndex, pageSize, total)
  1095. var tbdb string
  1096. var readSql string
  1097. var reportTypeStr string
  1098. if reportType == "1" {
  1099. tbdb = "cygx_report_selection"
  1100. reportTypeStr = "bgjx"
  1101. } else if reportType == "2" {
  1102. tbdb = "cygx_research_summary"
  1103. reportTypeStr = "bzyjhz"
  1104. } else if reportType == "3" {
  1105. tbdb = "cygx_minutes_summary"
  1106. reportTypeStr = "szjyhz"
  1107. } else {
  1108. br.Msg = "请选择报告类型"
  1109. return
  1110. }
  1111. fmt.Println(tbdb)
  1112. condition = ` AND publish_status = 1`
  1113. total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
  1114. if err != nil {
  1115. br.Msg = "获取信息失败"
  1116. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1117. return
  1118. }
  1119. readSql = ` (SELECT COUNT(1) AS count FROM cygx_report_history_record AS h WHERE h.article_id = art.article_id AND report_type ='` + reportTypeStr + `' AND h.user_id = ` + strconv.Itoa(uid) + `) as read_num`
  1120. page = paging.GetPaging(currentIndex, pageSize, total)
  1121. list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
  1122. if err != nil {
  1123. br.Msg = "获取失败"
  1124. br.ErrMsg = "获取失败,Err:" + err.Error()
  1125. return
  1126. }
  1127. for k, v := range list {
  1128. if reportType == "1" {
  1129. list[k].Abstract = v.UpdateDescription
  1130. }
  1131. list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
  1132. if v.ReadNum == 0 {
  1133. list[k].IsRed = true
  1134. }
  1135. }
  1136. resp.List = list
  1137. resp.Paging = page
  1138. br.Ret = 200
  1139. br.Success = true
  1140. br.Msg = "获取成功"
  1141. br.Data = resp
  1142. }
  1143. // @Title 获取报告精选详情
  1144. // @Description 获取报告精选详情接口
  1145. // @Param ArticleId query int true "报告ID"
  1146. // @Success 200 {object} models.ReportSelectionLetailResp
  1147. // @router /reportSelection/detail [get]
  1148. func (this *ReportController) Detail() {
  1149. br := new(models.BaseResponse).Init()
  1150. defer func() {
  1151. this.Data["json"] = br
  1152. this.ServeJSON()
  1153. }()
  1154. user := this.User
  1155. if user == nil {
  1156. br.Msg = "请重新登录"
  1157. br.Ret = 408
  1158. return
  1159. }
  1160. uid := user.UserId
  1161. articleId, _ := this.GetInt("ArticleId")
  1162. if articleId < 0 {
  1163. br.Msg = "参数错误"
  1164. br.ErrMsg = "参数错误"
  1165. return
  1166. }
  1167. resp := new(models.ReportSelectionLetailResp)
  1168. //判断用户权限
  1169. hasPermission, err := services.GetUserhasPermission(user)
  1170. if err != nil {
  1171. br.Msg = "获取信息失败"
  1172. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1173. }
  1174. resp.HasPermission = hasPermission
  1175. if hasPermission != 1 {
  1176. br.Ret = 200
  1177. br.Success = true
  1178. br.Msg = "获取成功"
  1179. br.Data = resp
  1180. return
  1181. }
  1182. detail, err := models.GetCygxReportSelectionInfoById(articleId)
  1183. if err != nil {
  1184. br.Msg = "获取信息失败"
  1185. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1186. return
  1187. }
  1188. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1189. existMap := make(map[int]int)
  1190. var items []*models.ReportSelectionChartPermission
  1191. listLog, err := models.GetReportSelectionlogListAll(articleId)
  1192. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1193. if err != nil {
  1194. br.Msg = "获取失败"
  1195. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1196. return
  1197. }
  1198. //var itemLogs []*models.CygxReportSelectionLogDetail
  1199. for _, v := range listLog {
  1200. item := new(models.ReportSelectionChartPermission)
  1201. if existMap[v.ChartPermissionId] == 0 {
  1202. item.PermissionName = v.PermissionName + "领域深度调研和报告"
  1203. item.IcoLink = v.IcoLink
  1204. listSonLog, err := models.GetReportSelectionlogSonListAll(articleId, v.ChartPermissionId)
  1205. if err != nil && err.Error() != utils.ErrNoRow() {
  1206. br.Msg = "获取信息失败"
  1207. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1208. return
  1209. }
  1210. for k2, v2 := range listSonLog {
  1211. if v2.IndustrialManagementId != "" {
  1212. listIndustrial, err := models.GetIndustrialByIds(v2.IndustrialManagementId)
  1213. if err != nil && err.Error() != utils.ErrNoRow() {
  1214. br.Msg = "获取信息失败"
  1215. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1216. return
  1217. }
  1218. listSonLog[k2].List = listIndustrial
  1219. }
  1220. }
  1221. item.List = listSonLog
  1222. items = append(items, item)
  1223. //itemLogs = make([]*models.CygxReportSelectionLogDetail, 0)
  1224. }
  1225. existMap[v.ChartPermissionId] = v.ChartPermissionId
  1226. }
  1227. historyRecord := new(models.CygxReportHistoryRecord)
  1228. historyRecord.UserId = uid
  1229. historyRecord.ArticleId = articleId
  1230. historyRecord.CreateTime = time.Now()
  1231. historyRecord.Mobile = user.Mobile
  1232. historyRecord.Email = user.Email
  1233. historyRecord.CompanyId = user.CompanyId
  1234. historyRecord.CompanyName = user.CompanyName
  1235. historyRecord.ReportType = "bgjx"
  1236. go models.AddCygxReportHistoryRecord(historyRecord)
  1237. resp.List = items
  1238. resp.Detail = detail
  1239. br.Ret = 200
  1240. br.Success = true
  1241. br.Msg = "获取成功"
  1242. br.Data = resp
  1243. }
  1244. // @Title 获取本周研究汇总详情
  1245. // @Description 获取本周研究汇总详情接口
  1246. // @Param ArticleId query int true "报告ID"
  1247. // @Success 200 {object} models.ResearchSummaryLetailResp
  1248. // @router /researchSummary/detail [get]
  1249. func (this *ReportController) ResearchDetail() {
  1250. br := new(models.BaseResponse).Init()
  1251. defer func() {
  1252. this.Data["json"] = br
  1253. this.ServeJSON()
  1254. }()
  1255. user := this.User
  1256. if user == nil {
  1257. br.Msg = "请重新登录"
  1258. br.Ret = 408
  1259. return
  1260. }
  1261. uid := user.UserId
  1262. articleId, _ := this.GetInt("ArticleId")
  1263. if articleId < 0 {
  1264. br.Msg = "参数错误"
  1265. br.ErrMsg = "参数错误"
  1266. return
  1267. }
  1268. resp := new(models.ResearchSummaryLetailResp)
  1269. //判断用户权限
  1270. hasPermission, err := services.GetUserhasPermission(user)
  1271. if err != nil {
  1272. br.Msg = "获取信息失败"
  1273. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1274. }
  1275. resp.HasPermission = hasPermission
  1276. if hasPermission != 1 {
  1277. br.Ret = 200
  1278. br.Success = true
  1279. br.Msg = "获取成功"
  1280. br.Data = resp
  1281. return
  1282. }
  1283. detail, err := models.GetCygxResearchSummaryInfoById(articleId)
  1284. if err != nil {
  1285. br.Msg = "获取信息失败"
  1286. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1287. return
  1288. }
  1289. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1290. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1291. listFirst, err := models.GetResearchSummarylogListFirst(articleId)
  1292. if err != nil {
  1293. br.Msg = "获取失败"
  1294. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1295. return
  1296. }
  1297. for k, v := range listFirst {
  1298. listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
  1299. if err != nil && err.Error() != utils.ErrNoRow() {
  1300. br.Msg = "获取信息失败"
  1301. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1302. return
  1303. }
  1304. for k2, v2 := range listSecond {
  1305. listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
  1306. if err != nil && err.Error() != utils.ErrNoRow() {
  1307. br.Msg = "获取信息失败"
  1308. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1309. return
  1310. }
  1311. if v2.ChartPermissionId == utils.YanxSummaryPermissionId {
  1312. listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1313. listSecond[k2].PermissionName = "研选纪要"
  1314. } else if v2.ChartPermissionId == utils.YanxViewpointPermissionId {
  1315. listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1316. listSecond[k2].PermissionName = "研选观点"
  1317. }
  1318. if len(listThird) > 0 {
  1319. for k3, v3 := range listThird {
  1320. if v3.VideoUrl != "" {
  1321. listThird[k3].IsHaveVideo = true
  1322. }
  1323. if v3.ReportLink == "0" {
  1324. listThird[k3].ReportLink = ""
  1325. }
  1326. }
  1327. listSecond[k2].List = listThird
  1328. }
  1329. }
  1330. if len(listSecond) > 0 {
  1331. listFirst[k].List = listSecond
  1332. }
  1333. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1334. if v.Type == "SDBG" {
  1335. listFirst[k].ListName = "深度报告"
  1336. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211027/le8AcRjDz0MhA72bVDiaf3d5ALSe.png"
  1337. } else if v.Type == "BZCHJH" {
  1338. listFirst[k].ListName = "本周晨会精华"
  1339. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
  1340. } else if v.Type == "CYDYJY" {
  1341. listFirst[k].ListName = "产业调研纪要"
  1342. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1343. } else if v.Type == "SSGS" {
  1344. listFirst[k].ListName = "上市公司调研纪要篇"
  1345. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1346. } else if v.Type == "SJDP" {
  1347. listFirst[k].ListName = "事件点评"
  1348. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
  1349. } else if v.Type == "YANX" {
  1350. listFirst[k].ListName = "研选"
  1351. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1352. }
  1353. }
  1354. historyRecord := new(models.CygxReportHistoryRecord)
  1355. historyRecord.UserId = uid
  1356. historyRecord.ArticleId = articleId
  1357. historyRecord.CreateTime = time.Now()
  1358. historyRecord.Mobile = user.Mobile
  1359. historyRecord.Email = user.Email
  1360. historyRecord.CompanyId = user.CompanyId
  1361. historyRecord.CompanyName = user.CompanyName
  1362. historyRecord.ReportType = "bzyjhz"
  1363. go models.AddCygxReportHistoryRecord(historyRecord)
  1364. resp.List = listFirst
  1365. resp.Detail = detail
  1366. br.Ret = 200
  1367. br.Success = true
  1368. br.Msg = "获取成功"
  1369. br.Data = resp
  1370. }
  1371. // @Title 上周纪要汇总内容详情
  1372. // @Description 获取上周纪要汇总内容详情接口
  1373. // @Param ArticleId query int true "报告ID"
  1374. // @Success 200 {object} models.MinutesSummaryLetailResp
  1375. // @router /minutesSummary/detail [get]
  1376. func (this *ReportController) MinutesDetail() {
  1377. br := new(models.BaseResponse).Init()
  1378. defer func() {
  1379. this.Data["json"] = br
  1380. this.ServeJSON()
  1381. }()
  1382. user := this.User
  1383. if user == nil {
  1384. br.Msg = "请重新登录"
  1385. br.Ret = 408
  1386. return
  1387. }
  1388. uid := user.UserId
  1389. articleId, _ := this.GetInt("ArticleId")
  1390. if articleId < 0 {
  1391. br.Msg = "参数错误"
  1392. br.ErrMsg = "参数错误"
  1393. return
  1394. }
  1395. resp := new(models.MinutesSummaryLetailResp)
  1396. //判断用户权限
  1397. hasPermission, err := services.GetUserhasPermission(user)
  1398. if err != nil {
  1399. br.Msg = "获取信息失败"
  1400. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1401. }
  1402. resp.HasPermission = hasPermission
  1403. if hasPermission != 1 {
  1404. br.Ret = 200
  1405. br.Success = true
  1406. br.Msg = "获取成功"
  1407. br.Data = resp
  1408. return
  1409. }
  1410. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1411. if err != nil {
  1412. br.Msg = "获取信息失败"
  1413. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1414. return
  1415. }
  1416. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1417. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1418. listFirst, err := models.GetMinutesSummarylogListAll(articleId)
  1419. if err != nil {
  1420. br.Msg = "获取失败"
  1421. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1422. return
  1423. }
  1424. for k, v := range listFirst {
  1425. listSecond, err := models.GetMinutesSummarylogSonListSecond(articleId, v.Type)
  1426. if err != nil && err.Error() != utils.ErrNoRow() {
  1427. br.Msg = "获取信息失败"
  1428. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1429. return
  1430. }
  1431. for k2, v2 := range listSecond {
  1432. listThird, err := models.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
  1433. if err != nil && err.Error() != utils.ErrNoRow() {
  1434. br.Msg = "获取信息失败"
  1435. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1436. return
  1437. }
  1438. if len(listThird) > 0 {
  1439. for k3, v3 := range listThird {
  1440. if v3.VideoUrl != "" {
  1441. listThird[k3].IsHaveVideo = true
  1442. }
  1443. if v3.ReportLink == "0" {
  1444. listThird[k3].ReportLink = ""
  1445. }
  1446. }
  1447. listSecond[k2].List = listThird
  1448. }
  1449. }
  1450. if len(listSecond) > 0 {
  1451. listFirst[k].List = listSecond
  1452. }
  1453. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1454. if v.Type == "CYDYJY" {
  1455. listFirst[k].ListName = "产业调研纪要"
  1456. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1457. } else if v.Type == "SSGS" {
  1458. listFirst[k].ListName = "上市公司调研纪要篇"
  1459. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1460. } else if v.Type == "YANX" {
  1461. listFirst[k].ListName = "研选纪要"
  1462. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1463. }
  1464. }
  1465. historyRecord := new(models.CygxReportHistoryRecord)
  1466. historyRecord.UserId = uid
  1467. historyRecord.ArticleId = articleId
  1468. historyRecord.CreateTime = time.Now()
  1469. historyRecord.Mobile = user.Mobile
  1470. historyRecord.Email = user.Email
  1471. historyRecord.CompanyId = user.CompanyId
  1472. historyRecord.CompanyName = user.CompanyName
  1473. historyRecord.ReportType = "szjyhz"
  1474. go models.AddCygxReportHistoryRecord(historyRecord)
  1475. resp.List = listFirst
  1476. resp.Detail = detail
  1477. br.Ret = 200
  1478. br.Success = true
  1479. br.Msg = "获取成功"
  1480. br.Data = resp
  1481. }
  1482. // @Title 获取路演精华详情
  1483. // @Description 获取路演精华详情接口
  1484. // @Param ArticleId query int true "报告ID"
  1485. // @Success 200 {object} models.RoadshowDetailResp
  1486. // @router /roadshowEssence/detail [get]
  1487. func (this *ReportController) RoadshowDetail() {
  1488. br := new(models.BaseResponse).Init()
  1489. defer func() {
  1490. this.Data["json"] = br
  1491. this.ServeJSON()
  1492. }()
  1493. user := this.User
  1494. if user == nil {
  1495. br.Msg = "请登录"
  1496. br.ErrMsg = "请登录,用户信息为空"
  1497. br.Ret = 408
  1498. return
  1499. }
  1500. uid := user.UserId
  1501. articleId, err := this.GetInt("ArticleId")
  1502. if articleId <= 0 {
  1503. br.Msg = "文章不存在"
  1504. br.ErrMsg = "文章不存在,文章ID错误"
  1505. return
  1506. }
  1507. detail := new(models.ReportDetailRoadshow)
  1508. hasPermission := 0
  1509. hasFree := 0
  1510. //判断是否已经申请过
  1511. applyCount, err := models.GetApplyRecordCount(uid)
  1512. if err != nil && err.Error() != utils.ErrNoRow() {
  1513. br.Msg = "获取信息失败"
  1514. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1515. return
  1516. }
  1517. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  1518. if user.CompanyId > 1 {
  1519. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  1520. if err != nil {
  1521. br.Msg = "获取信息失败"
  1522. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1523. return
  1524. }
  1525. detail, err = models.GetReportRoadshowDetailById(articleId)
  1526. if err != nil {
  1527. br.Msg = "获取信息失败"
  1528. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1529. return
  1530. }
  1531. detail.Body = html.UnescapeString(detail.Body)
  1532. detail.Abstract, _ = services.GetReportContentTextSub(detail.Abstract)
  1533. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1534. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1535. if detail.ReportLink == "0" {
  1536. detail.ReportLink = ""
  1537. }
  1538. if companyPermission == "" {
  1539. if applyCount > 0 {
  1540. hasPermission = 5
  1541. } else {
  1542. hasPermission = 2
  1543. }
  1544. hasFree = 2
  1545. goto Loop
  1546. } else {
  1547. hasFree = 1
  1548. var articlePermissionPermissionName string
  1549. articlePermissionPermissionName = detail.CategoryName
  1550. var hasPersion bool
  1551. slice := strings.Split(articlePermissionPermissionName, ",")
  1552. for _, v := range slice {
  1553. if strings.Contains(companyPermission, v) {
  1554. hasPersion = true
  1555. }
  1556. }
  1557. if hasPersion {
  1558. hasPermission = 1
  1559. historyRecord := new(models.CygxArticleHistoryRecord)
  1560. historyRecord.UserId = uid
  1561. historyRecord.ArticleId = articleId
  1562. historyRecord.CreateTime = time.Now()
  1563. historyRecord.Mobile = user.Mobile
  1564. historyRecord.Email = user.Email
  1565. historyRecord.CompanyId = user.CompanyId
  1566. historyRecord.CompanyName = user.CompanyName
  1567. go models.AddCygxArticleHistoryRecord(historyRecord)
  1568. } else { //无该行业权限
  1569. hasPermission = 3
  1570. }
  1571. if hasPermission == 1 {
  1572. key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
  1573. if !utils.Rc.IsExist(key) {
  1574. //新增浏览记录
  1575. record := new(models.CygxArticleViewRecord)
  1576. record.UserId = uid
  1577. record.ArticleId = articleId
  1578. record.CreateTime = time.Now()
  1579. record.Mobile = user.Mobile
  1580. record.Email = user.Email
  1581. record.CompanyId = user.CompanyId
  1582. record.CompanyName = user.CompanyName
  1583. go models.AddCygxArticleViewRecord(record)
  1584. utils.Rc.Put(key, 1, 5*time.Second)
  1585. models.ModifyReportLastViewTime(uid)
  1586. }
  1587. }
  1588. }
  1589. } else { //潜在客户
  1590. if applyCount > 0 {
  1591. hasPermission = 5
  1592. } else {
  1593. hasPermission = 4
  1594. }
  1595. }
  1596. Loop:
  1597. if hasPermission != 1 {
  1598. detail.Body = ""
  1599. detail.Abstract = ""
  1600. }
  1601. resp := new(models.RoadshowDetailResp)
  1602. resp.HasPermission = hasPermission
  1603. resp.HasFree = hasFree
  1604. resp.Detail = detail
  1605. br.Ret = 200
  1606. br.Success = true
  1607. br.Msg = "获取成功"
  1608. br.Data = resp
  1609. }
  1610. // @Title 产业文章列表接口
  1611. // @Description 获取产业文章列表接口
  1612. // @Param KeyWord query string true "搜索关键词"
  1613. // @Success 200 {object} models.CygxIndustrySearchList
  1614. // @router /industryAndArticle/list [get]
  1615. func (this *ReportController) IndustryAndArticleList() {
  1616. br := new(models.BaseResponse).Init()
  1617. defer func() {
  1618. this.Data["json"] = br
  1619. this.ServeJSON()
  1620. }()
  1621. user := this.User
  1622. if user == nil {
  1623. br.Msg = "请重新登录"
  1624. br.Ret = 408
  1625. return
  1626. }
  1627. uid := user.UserId
  1628. keyWord := this.GetString("KeyWord")
  1629. orderSrt := "update_time DESC"
  1630. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  1631. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  1632. if err != nil {
  1633. br.Msg = "获取信息失败"
  1634. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1635. return
  1636. }
  1637. for k, v := range list {
  1638. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  1639. if err != nil {
  1640. br.Msg = "获取信息失败"
  1641. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1642. return
  1643. }
  1644. list[k].IndustrialSubjectList = industrialSubjectList
  1645. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  1646. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  1647. if err != nil {
  1648. br.Msg = "获取信息失败"
  1649. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1650. return
  1651. }
  1652. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  1653. }
  1654. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  1655. if err != nil {
  1656. br.Msg = "获取失败"
  1657. br.ErrMsg = "获取失败,Err:" + err.Error()
  1658. return
  1659. }
  1660. for k2, v2 := range artList {
  1661. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  1662. if err != nil {
  1663. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  1664. br.ErrMsg = "获取失败,Err:" + err.Error()
  1665. return
  1666. }
  1667. var subjectNamesNew string
  1668. if len(subjectNames) > 0 {
  1669. slice := strings.Split(subjectNames, "/")
  1670. for k3, v3 := range slice {
  1671. if k3 < 4 {
  1672. subjectNamesNew += v3 + "/"
  1673. }
  1674. }
  1675. }
  1676. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  1677. if err != nil && err.Error() != utils.ErrNoRow() {
  1678. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  1679. br.ErrMsg = "获取失败,Err:" + err.Error()
  1680. return
  1681. }
  1682. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1683. artList[k2].SubjectName = subjectNamesNew
  1684. if subjectNamesNew == "" {
  1685. artList[k2].IndustryName = industryName
  1686. } else {
  1687. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  1688. }
  1689. }
  1690. resp := new(models.CygxIndustrySearchList)
  1691. resp.ArtList = artList
  1692. resp.IndList = list
  1693. br.Ret = 200
  1694. br.Success = true
  1695. br.Msg = "获取成功"
  1696. br.Data = resp
  1697. }