report.go 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "hongze/hongze_clpt/models"
  7. "hongze/hongze_clpt/services"
  8. "hongze/hongze_clpt/utils"
  9. "strconv"
  10. "strings"
  11. "time"
  12. )
  13. //报告
  14. type ReportController struct {
  15. BaseAuthController
  16. }
  17. type ReportCommonController struct {
  18. BaseCommonController
  19. }
  20. type MobileReportController struct {
  21. BaseAuthMobileController
  22. }
  23. // @Title 行业报告分类列表接口
  24. // @Description 获取行业报告分类列表接口
  25. // @Param ChartPermissionId query int true "分类ID"
  26. // @Success 200 {object} models.TradeReportMappingResp
  27. // @router /tradeList [get]
  28. func (this *MobileReportController) TradeList() {
  29. br := new(models.BaseResponse).Init()
  30. defer func() {
  31. this.Data["json"] = br
  32. this.ServeJSON()
  33. }()
  34. user := this.User
  35. if user == nil {
  36. br.Msg = "请重新登录"
  37. br.Ret = 408
  38. return
  39. }
  40. fmt.Println(user)
  41. uid := user.UserId
  42. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  43. if ChartPermissionId < 1 {
  44. br.Msg = "请输入分类ID"
  45. return
  46. }
  47. //var result []*models.SearchItem
  48. var list []*models.TradeReportMapping
  49. var err error
  50. mapCategory := make(map[int]int)
  51. if ChartPermissionId == utils.CE_LUE_ID {
  52. listTrade, errTrade := models.GetReportMappingStrategyHomeAll()
  53. list = listTrade
  54. err = errTrade
  55. if user.Mobile != "" {
  56. //策略的处理
  57. categoryList, err := models.GetCygxXzsChooseCategoryList(user.Mobile)
  58. if err != nil && err.Error() != utils.ErrNoRow() {
  59. br.Msg = "获取信息失败"
  60. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  61. return
  62. }
  63. for _, v := range categoryList {
  64. mapCategory[v.CategoryId] = v.CategoryId
  65. }
  66. }
  67. } else {
  68. listTrade, errTrade := models.GetTradeAll(ChartPermissionId)
  69. err = errTrade
  70. list = listTrade
  71. }
  72. if err != nil {
  73. br.Msg = "获取信息失败"
  74. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  75. return
  76. }
  77. for k, v := range list {
  78. list[k].UpdateTime = utils.TimeRemoveHms(v.UpdateTime)
  79. count, err := models.CheckThisCategoryNewArticleIsRead(uid, v.CategoryId)
  80. if err != nil {
  81. br.Msg = "获取信息失败"
  82. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  83. return
  84. }
  85. if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.UpdateTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.UpdateTime)) {
  86. list[k].IsRed = true
  87. }
  88. var condition string
  89. var pars []interface{}
  90. categoryIdSet, errCategory := models.GetdetailByCategoryIdSet(v.CategoryId)
  91. if errCategory != nil {
  92. br.Msg = "获取信息失败"
  93. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(v.CategoryId)
  94. return
  95. }
  96. if categoryIdSet != "" {
  97. condition = ` AND a.category_id IN(` + categoryIdSet + `)`
  98. } else {
  99. condition = ` AND a.category_id IN(` + strconv.Itoa(v.CategoryId) + `)`
  100. }
  101. //condition = " AND a.category_id_two = " + strconv.Itoa(v.CategoryId)
  102. //condition += " OR a.category_id = " + strconv.Itoa(v.CategoryId)
  103. if ChartPermissionId != utils.CE_LUE_ID {
  104. var pageSize int
  105. //if ChartPermissionId == utils.KE_JI_ID {
  106. // pageSize = 12
  107. //} else {
  108. // pageSize = 3
  109. //}
  110. pageSize = 3
  111. listArticle, err := models.GetHomeList(condition, pars, 0, pageSize)
  112. if err != nil {
  113. br.Msg = "获取信息失败"
  114. br.Msg = "GetHomeList,Err:" + err.Error()
  115. return
  116. }
  117. list[k].ListArticle = listArticle
  118. } else {
  119. if mapCategory[v.CategoryId] > 0 {
  120. list[k].IsFollow = true
  121. }
  122. list[k].ListArticle = make([]*models.HomeArticle, 0)
  123. }
  124. }
  125. resp := new(models.TradeReportMappingResp)
  126. if len(list) == 0 {
  127. list = make([]*models.TradeReportMapping, 0)
  128. }
  129. resp.List = list
  130. br.Ret = 200
  131. br.Success = true
  132. br.Msg = "获取成功"
  133. br.Data = resp
  134. }
  135. // @Title 产业报告分类列表接口
  136. // @Description 获取产业报告分类列表接口
  137. // @Param ChartPermissionId query int true "分类ID"
  138. // @Param DeepCover query int false "是否选择深度覆盖,1是,0否 不填默认为0"
  139. // @Param RecommendFocus query int false "是否选择推荐关注,1是,0否 不填默认为0"
  140. // @Param PageSize query int true "每页数据条数"
  141. // @Param CurrentIndex query int true "当前页页码,从1开始"
  142. // @Param IsBillboard query bool false "是否属于榜单 是true 否 false"
  143. // @Success 200 {object} models.IndustrialManagementList
  144. // @router /industryList [get]
  145. func (this *MobileReportController) IndustryList() {
  146. br := new(models.BaseResponse).Init()
  147. defer func() {
  148. this.Data["json"] = br
  149. this.ServeJSON()
  150. }()
  151. user := this.User
  152. if user == nil {
  153. br.Msg = "请重新登录"
  154. br.Ret = 408
  155. return
  156. }
  157. uid := user.UserId
  158. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  159. orderColumn := this.GetString("OrderColumn")
  160. orderColumnNew := this.GetString("OrderColumn")
  161. isNewLabel := this.GetString("IsNewLabel")
  162. isDeepLabel := this.GetString("IsDeepLabel")
  163. pageSize, _ := this.GetInt("PageSize")
  164. currentIndex, _ := this.GetInt("CurrentIndex")
  165. deepCover, _ := this.GetInt("DeepCover")
  166. recommendFocus, _ := this.GetInt("RecommendFocus")
  167. isBillboard, _ := this.GetBool("IsBillboard", false)
  168. var orderSrt string
  169. var condition string
  170. var startSize int
  171. resp := new(models.IndustrialManagementList)
  172. if pageSize <= 0 {
  173. pageSize = utils.PageSize20
  174. }
  175. if currentIndex <= 0 {
  176. currentIndex = 1
  177. }
  178. startSize = paging.StartIndex(currentIndex, pageSize)
  179. if ChartPermissionId > 0 {
  180. condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
  181. }
  182. // 获取近一个月产业报告阅读次数最多的产业
  183. var topCond string
  184. var topPars []interface{}
  185. topReadIndustryId := 0
  186. if ChartPermissionId > 0 {
  187. topCond += ` AND chart_permission_id = ?`
  188. topPars = append(topPars, ChartPermissionId)
  189. }
  190. topReadIndustry, e := models.GetTopOneMonthArtReadNumIndustry(topCond, topPars)
  191. if e != nil && e.Error() != utils.ErrNoRow() {
  192. br.Msg = "获取信息失败"
  193. br.ErrMsg = "获取近一个月报告阅读次数最多的产业失败, Err: " + e.Error()
  194. return
  195. }
  196. if topReadIndustry != nil {
  197. topReadIndustryId = topReadIndustry.IndustrialManagementId
  198. }
  199. // 深度覆盖
  200. if deepCover == 1 {
  201. // 查询深标签产业报告数
  202. var deepCondition string
  203. var deepPars []interface{}
  204. deepCondition += ` AND man.is_deep_label = 1`
  205. if ChartPermissionId > 0 {
  206. deepCondition += ` AND man.chart_permission_id = ?`
  207. deepPars = append(deepPars, ChartPermissionId)
  208. }
  209. industryCountList, e := models.GetIndustryArtCountByCondition(deepCondition, deepPars)
  210. if e != nil {
  211. br.Msg = "获取信息失败"
  212. br.ErrMsg = "获取深标签产业报告数失败, Err: " + e.Error()
  213. return
  214. }
  215. deepIdArr := make([]string, 0)
  216. for i := range industryCountList {
  217. if industryCountList[i].ArtNum > 10 {
  218. deepIdArr = append(deepIdArr, strconv.Itoa(industryCountList[i].IndustrialManagementId))
  219. }
  220. }
  221. deepIds := strings.Join(deepIdArr, ",")
  222. if deepIds != "" {
  223. condition = `AND man.industrial_management_id IN (` + deepIds + `)`
  224. }
  225. }
  226. // 推荐关注
  227. if recommendFocus == 1 {
  228. condition += ` AND man.recommended_index >= 80`
  229. }
  230. var list []*models.IndustrialManagement
  231. total, err := models.GetIndustrialManagementAllCount(condition)
  232. if err != nil {
  233. br.Msg = "获取信息失败"
  234. br.ErrMsg = "获取数量失败,Err:" + err.Error()
  235. return
  236. }
  237. if orderColumn == "" {
  238. orderColumn = "NewTime"
  239. }
  240. if orderColumn == "NewTime" {
  241. orderSrt = "update_time DESC"
  242. } else {
  243. orderSrt = "man.recommended_index DESC,update_time DESC"
  244. }
  245. if isBillboard {
  246. // 查询有已归类行业报告的行业IDs
  247. activeIndustryIds, e := models.GetActiveArticleIndustryIds()
  248. if e != nil {
  249. br.Msg = "获取失败"
  250. br.ErrMsg = "获取已归类行业失败, Err:" + e.Error()
  251. return
  252. }
  253. activeIndustryLen := len(activeIndustryIds)
  254. //topNum := pageSize
  255. condition = ""
  256. var parsBd []interface{}
  257. if ChartPermissionId > 0 {
  258. condition += ` AND man.chart_permission_id = ? `
  259. parsBd = append(parsBd, ChartPermissionId)
  260. }
  261. if activeIndustryLen > 0 {
  262. condition += ` AND man.industrial_management_id IN (` + utils.GetOrmInReplace(activeIndustryLen) + `)`
  263. parsBd = append(parsBd, activeIndustryIds)
  264. }
  265. nowTime := time.Now().Local()
  266. startTime := nowTime.AddDate(0, -1, 0)
  267. endTime := nowTime.AddDate(0, 0, -1)
  268. condition += ` AND idf.create_time BETWEEN ? AND ?`
  269. parsBd = append(parsBd, startTime, endTime)
  270. list, e = models.GetTopIndustryFollowData(0, pageSize, condition, parsBd)
  271. if e != nil {
  272. br.Msg = "获取失败"
  273. br.ErrMsg = "获取关注度最高的产业数据失败, Err:" + e.Error()
  274. return
  275. }
  276. } else {
  277. list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize, isBillboard)
  278. if err != nil {
  279. br.Msg = "获取信息失败"
  280. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  281. return
  282. }
  283. }
  284. list, err = services.HandleIndustryList(list, user)
  285. if err != nil {
  286. br.Msg = "获取信息失败"
  287. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  288. return
  289. }
  290. industrialIdArr := make([]int, 0)
  291. for k, v := range list {
  292. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  293. if topReadIndustryId > 0 && list[k].IndustrialManagementId == topReadIndustryId {
  294. list[k].IsHot = true
  295. }
  296. }
  297. if orderColumnNew != "" {
  298. item := new(models.CygxReportIndustrialSeaarchHistory)
  299. item.UserId = user.UserId
  300. item.Mobile = user.Mobile
  301. item.CompanyId = user.CompanyId
  302. item.CompanyName = user.CompanyName
  303. item.CreateTime = time.Now()
  304. item.IsDeepLabel = isDeepLabel
  305. item.IsNewLabel = isNewLabel
  306. item.ChartPermissionId = ChartPermissionId
  307. if orderColumnNew == "NewTime" {
  308. item.OrderColumn = "0"
  309. } else {
  310. item.OrderColumn = "1"
  311. }
  312. go models.AddCygxReportIndustrialSeaarchHistory(item)
  313. }
  314. if len(list) == 0 {
  315. list = make([]*models.IndustrialManagement, 0)
  316. }
  317. page := paging.GetPaging(currentIndex, pageSize, total)
  318. if isBillboard {
  319. total = len(list)
  320. }
  321. resp.List = list
  322. resp.Paging = page
  323. br.Ret = 200
  324. br.Success = true
  325. br.Msg = "获取成功"
  326. br.Data = resp
  327. }
  328. // @Title 产业下所关联的文章分类列表
  329. // @Description 产业下所关联的文章分类列表接口
  330. // @Param IndustrialManagementId query int true "产业ID"
  331. // @Success 200 {object} models.IndustrialToArticleCategoryListRep
  332. // @router /toArticleCategoryList [get]
  333. func (this *MobileReportController) ArticleCategoryList() {
  334. br := new(models.BaseResponse).Init()
  335. defer func() {
  336. this.Data["json"] = br
  337. this.ServeJSON()
  338. }()
  339. user := this.User
  340. if user == nil {
  341. br.Msg = "请重新登录"
  342. br.Ret = 408
  343. return
  344. }
  345. uid := user.UserId
  346. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  347. if industrialManagementId < 1 {
  348. br.Msg = "请输入分类ID"
  349. return
  350. }
  351. detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  352. if err != nil {
  353. br.Msg = "获取信息失败"
  354. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  355. return
  356. }
  357. list, err := models.IndustrialToArticleCategory(industrialManagementId, detail.ChartPermissionId)
  358. if err != nil {
  359. br.Msg = "获取信息失败"
  360. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  361. return
  362. }
  363. for k, v := range list {
  364. recordCount, err := models.IndustrialUserRecordArticleCount(uid, industrialManagementId, v.CategoryId)
  365. if err != nil && err.Error() != utils.ErrNoRow() {
  366. br.Msg = "获取信息失败"
  367. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  368. return
  369. }
  370. Newdetail, err := models.GetNewIndustrialUserRecordArticle(industrialManagementId, v.CategoryId)
  371. if err != nil {
  372. br.Msg = "获取信息失败"
  373. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  374. return
  375. }
  376. if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
  377. list[k].IsRed = true
  378. }
  379. }
  380. //标的列表
  381. industrialSubjectList, err := models.GetIndustrialSubjectAll(industrialManagementId)
  382. if err != nil {
  383. br.Msg = "获取信息失败"
  384. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  385. return
  386. }
  387. videoSimple, au, err := services.GetindustryVideo(user, industrialManagementId)
  388. if err != nil {
  389. br.Msg = "获取失败"
  390. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  391. return
  392. }
  393. timeLineItem := models.IndustrialToArticleCategoryRep{
  394. CategoryId: utils.TIME_CATEGORYID,
  395. MatchTypeName: "时间线",
  396. }
  397. list = append([]*models.IndustrialToArticleCategoryRep{&timeLineItem}, list...)
  398. resp := new(models.IndustrialToArticleCategoryListRep)
  399. resp.List = list
  400. resp.ListSubject = industrialSubjectList
  401. resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
  402. resp.IndustryName = detail.IndustryName
  403. resp.IndustrialManagementId = industrialManagementId
  404. if videoSimple != nil && videoSimple.Id > 0 {
  405. resp.IndustryVideo = videoSimple
  406. }
  407. resp.AuthInfo = au
  408. br.Ret = 200
  409. br.Success = true
  410. br.Msg = "获取成功"
  411. br.Data = resp
  412. }
  413. // @Title 根据行业分类获取文章列表
  414. // @Description根据行业分类获取文章列表接口
  415. // @Param PageSize query int true "每页数据条数"
  416. // @Param CurrentIndex query int true "当前页页码,从1开始"
  417. // @Param CategoryId query int true "分类ID"
  418. // @Param IndustrialManagementId query int false "产业ID"
  419. // @Success 200 {object} models.TacticsListResp
  420. // @router /articleList/byCategoryId [get]
  421. func (this *MobileReportController) List() {
  422. br := new(models.BaseResponse).Init()
  423. defer func() {
  424. this.Data["json"] = br
  425. this.ServeJSON()
  426. }()
  427. user := this.User
  428. if user == nil {
  429. br.Msg = "请重新登录"
  430. br.Ret = 408
  431. return
  432. }
  433. //uid := user.UserId
  434. pageSize, _ := this.GetInt("PageSize")
  435. currentIndex, _ := this.GetInt("CurrentIndex")
  436. categoryId, _ := this.GetInt("CategoryId")
  437. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  438. var startSize int
  439. if pageSize <= 0 {
  440. pageSize = utils.PageSize20
  441. }
  442. if currentIndex <= 0 {
  443. currentIndex = 1
  444. }
  445. startSize = paging.StartIndex(currentIndex, pageSize)
  446. var condition string
  447. var pars []interface{}
  448. var total int
  449. resp := new(models.TacticsListResp)
  450. page := paging.GetPaging(currentIndex, pageSize, total)
  451. list := make([]*models.HomeArticle, 0)
  452. if categoryId == utils.TIME_CATEGORYID {
  453. var err error
  454. list, total, err = models.GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize)
  455. if err != nil {
  456. br.Msg = "获取信息失败"
  457. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  458. return
  459. }
  460. } else {
  461. //获取该产业下所对应的行业图片
  462. detail, errCategory := models.GetdetailByCategoryIdOne(categoryId)
  463. if errCategory != nil {
  464. br.Msg = "获取信息失败"
  465. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  466. return
  467. }
  468. //对应行业的图片
  469. detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
  470. if err != nil {
  471. br.Msg = "获取数据失败"
  472. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  473. return
  474. }
  475. chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
  476. mapChartPermission := make(map[string]string)
  477. var permissionName string
  478. var imgUrlChartPermission string
  479. for _, v := range chartPermissionUrlList {
  480. vslice := strings.Split(v, "_")
  481. permissionName = vslice[0]
  482. imgUrlChartPermission = vslice[len(vslice)-1]
  483. mapChartPermission[permissionName] = imgUrlChartPermission
  484. }
  485. //对应分类的所图片
  486. detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  487. if err != nil {
  488. br.Msg = "获取数据失败"
  489. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  490. return
  491. }
  492. categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  493. mapCategoryUrl := make(map[string]string)
  494. var categoryIdStr string
  495. var imgUrlChart string
  496. for _, v := range categoryUrlList {
  497. vslice := strings.Split(v, "_")
  498. categoryIdStr = vslice[0]
  499. imgUrlChart = vslice[len(vslice)-1]
  500. mapCategoryUrl[categoryIdStr] = imgUrlChart
  501. }
  502. //condition += ` AND category_id_two=? `
  503. //pars = append(pars, categoryId)
  504. categoryIdSet, errCategory := models.GetdetailByCategoryIdSet(categoryId)
  505. if errCategory != nil {
  506. br.Msg = "获取信息失败"
  507. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  508. return
  509. }
  510. if categoryIdSet != "" {
  511. condition = ` AND category_id IN(` + categoryIdSet + `)`
  512. } else {
  513. condition = ` AND category_id IN(` + strconv.Itoa(categoryId) + `)`
  514. }
  515. if industrialManagementId > 0 {
  516. industrialManageentList, err := models.GetIndustrialArticleGroupManagementByIndustrialManagementId(industrialManagementId)
  517. if err != nil {
  518. br.Msg = "获取信息失败"
  519. br.Msg = "获取产业关联的文章ID失败,GetIndustrialArticleGroupManagementByIndustrialManagementIdErr:" + err.Error()
  520. return
  521. }
  522. articleIdList := make([]string, 0)
  523. for _, v := range industrialManageentList {
  524. articleIdList = append(articleIdList, strconv.Itoa(v.ArticleId))
  525. }
  526. condition += ` AND a.article_id IN ( ` + utils.GetOrmInReplace(len(articleIdList)) + ` ) `
  527. pars = append(pars, articleIdList)
  528. }
  529. total, err = models.GetHomeCount(condition, pars)
  530. if err != nil {
  531. br.Msg = "获取信息失败"
  532. br.Msg = "获取帖子总数失败,Err:" + err.Error()
  533. return
  534. }
  535. list, err = models.GetHomeList(condition, pars, startSize, pageSize)
  536. if err != nil {
  537. br.Msg = "获取信息失败"
  538. br.Msg = "获取帖子数据失败,Err:" + err.Error()
  539. return
  540. }
  541. for k, v := range list {
  542. list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  543. }
  544. if categoryId > 0 {
  545. detail, errCategory := models.GetdetailByCategoryId(categoryId)
  546. if errCategory != nil {
  547. br.Msg = "获取信息失败"
  548. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  549. return
  550. }
  551. resp.MatchTypeName = detail.MatchTypeName
  552. }
  553. resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  554. }
  555. lenList := len(list)
  556. for i := 0; i < lenList; i++ {
  557. item := list[i]
  558. list[i].Body = ""
  559. list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  560. list[i].Annotation, _ = services.GetReportContentTextSub(item.Annotation)
  561. list[i].PublishDate = utils.StrTimeToTime(item.PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
  562. //行业比较研究、资金流向,显示报告的摘要
  563. if resp.MatchTypeName == "行业比较研究" || resp.MatchTypeName == "资金流向" {
  564. list[i].Annotation = list[i].Abstract
  565. }
  566. }
  567. if len(list) == 0 {
  568. list = make([]*models.HomeArticle, 0)
  569. }
  570. page = paging.GetPaging(currentIndex, pageSize, total)
  571. resp.List = list
  572. resp.Paging = page
  573. br.Ret = 200
  574. br.Success = true
  575. br.Msg = "获取成功"
  576. br.Data = resp
  577. }
  578. // @Title 产业关注/取消关注
  579. // @Description 产业关注/取消关注 接口
  580. // @Param request body models.CygxIndustryFllowRep true "type json string"
  581. // @Success 200
  582. // @router /industrial/fllow [post]
  583. func (this *ReportController) IndustrialFllow() {
  584. br := new(models.BaseResponse).Init()
  585. defer func() {
  586. this.Data["json"] = br
  587. this.ServeJSON()
  588. }()
  589. user := this.User
  590. if user == nil {
  591. br.Msg = "请重新登录"
  592. br.Ret = 408
  593. return
  594. }
  595. uid := user.UserId
  596. var req models.CygxIndustryFllowRep
  597. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  598. if err != nil {
  599. br.Msg = "参数解析异常!"
  600. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  601. return
  602. }
  603. industrialManagementId := req.IndustrialManagementId
  604. var condition string
  605. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  606. if err != nil {
  607. br.Msg = "获取数据失败!"
  608. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  609. return
  610. }
  611. if countIndustrial == 0 {
  612. br.Msg = "产业不存在!"
  613. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  614. return
  615. }
  616. count, err := models.GetCountCygxIndustryFllow(industrialManagementId, user.UserId, condition)
  617. if err != nil {
  618. br.Msg = "获取数据失败!"
  619. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  620. return
  621. }
  622. resp := new(models.CygxIndustryFllowResp)
  623. if count == 0 {
  624. item := new(models.CygxIndustryFllow)
  625. item.IndustrialManagementId = industrialManagementId
  626. item.UserId = uid
  627. item.Email = user.Email
  628. item.Mobile = user.Mobile
  629. item.RealName = user.RealName
  630. item.CompanyId = user.CompanyId
  631. item.CompanyName = user.CompanyName
  632. item.Type = 1
  633. item.CreateTime = time.Now()
  634. item.ModifyTime = time.Now()
  635. _, err = models.AddCygxIndustryFllow(item)
  636. if err != nil {
  637. br.Msg = "操作失败"
  638. br.ErrMsg = "操作失败,Err:" + err.Error()
  639. return
  640. }
  641. resp.Status = 1
  642. br.Msg = "关注成功"
  643. } else {
  644. err = models.RemoveCygxIndustryFllow(uid, industrialManagementId)
  645. if err != nil {
  646. br.Msg = "操作失败"
  647. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  648. return
  649. }
  650. resp.Status = 2
  651. br.Msg = "已取消关注"
  652. }
  653. //处理是否关注全部赛道字段
  654. go services.IndustryFllowWithTrack(industrialManagementId, count, uid)
  655. br.Ret = 200
  656. br.Success = true
  657. br.Data = resp
  658. }
  659. // @Title 行业关注/取消关注
  660. // @Description 行业关注/取消关注 接口
  661. // @Param request body models.CygxCategoryFllowRep true "type json string"
  662. // @Success 200
  663. // @router /category/fllow [post]
  664. func (this *ReportController) CategoryFllow() {
  665. br := new(models.BaseResponse).Init()
  666. defer func() {
  667. this.Data["json"] = br
  668. this.ServeJSON()
  669. }()
  670. user := this.User
  671. if user == nil {
  672. br.Msg = "请重新登录"
  673. br.Ret = 408
  674. return
  675. }
  676. uid := user.UserId
  677. var req models.CygxCategoryFllowRep
  678. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  679. if err != nil {
  680. br.Msg = "参数解析异常!"
  681. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  682. return
  683. }
  684. categoryId := req.CategoryId
  685. var condition string
  686. countCategory, err := models.GetCategoryCount(categoryId)
  687. if err != nil {
  688. br.Msg = "获取数据失败!"
  689. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  690. return
  691. }
  692. if countCategory == 0 {
  693. br.Msg = "产业不存在!"
  694. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(categoryId)
  695. return
  696. }
  697. count, err := models.GetCountCategoryFllow(categoryId, user.Mobile, condition)
  698. if err != nil {
  699. br.Msg = "获取数据失败!"
  700. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  701. return
  702. }
  703. resp := new(models.CygxIndustryFllowResp)
  704. if count == 0 {
  705. item := new(models.CygxXzsChooseCategory)
  706. item.CategoryId = categoryId
  707. item.UserId = uid
  708. item.Email = user.Email
  709. item.Mobile = user.Mobile
  710. item.RealName = user.RealName
  711. item.CompanyId = user.CompanyId
  712. item.CompanyName = user.CompanyName
  713. item.CreateTime = time.Now()
  714. item.ModifyTime = time.Now()
  715. _, err = models.AddCygxCategoryFllow(item)
  716. if err != nil {
  717. br.Msg = "操作失败"
  718. br.ErrMsg = "操作失败,Err:" + err.Error()
  719. return
  720. }
  721. resp.Status = 1
  722. br.Msg = "关注成功"
  723. } else {
  724. err = models.RemoveCygxCategoryFllow(user.Mobile, categoryId)
  725. if err != nil {
  726. br.Msg = "操作失败"
  727. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  728. return
  729. }
  730. resp.Status = 2
  731. br.Msg = "已取消关注"
  732. }
  733. br.Ret = 200
  734. br.Success = true
  735. br.Data = resp
  736. }
  737. // @Title 报告搜索
  738. // @Description 报告搜索接口
  739. // @Param PageSize query int true "每页数据条数"
  740. // @Param CurrentIndex query int true "当前页页码,从1开始"
  741. // @Param KeyWord query string true "搜索关键词"
  742. // @Success 200 {object} models.ReoprtSearchResp
  743. // @router /searchReport [get]
  744. func (this *MobileReportController) SearchReport() {
  745. br := new(models.BaseResponse).Init()
  746. defer func() {
  747. this.Data["json"] = br
  748. this.ServeJSON()
  749. }()
  750. user := this.User
  751. if user == nil {
  752. br.Msg = "请重新登录"
  753. br.Ret = 408
  754. return
  755. }
  756. pageSize, _ := this.GetInt("PageSize")
  757. currentIndex, _ := this.GetInt("CurrentIndex")
  758. keyWord := this.GetString("KeyWord")
  759. var condition string
  760. var conditionSql string
  761. //var sqlGroup string
  762. var total int
  763. var startSize int
  764. if pageSize <= 0 {
  765. pageSize = utils.PageSize20
  766. }
  767. if currentIndex <= 0 {
  768. currentIndex = 1
  769. }
  770. startSize = paging.StartIndex(currentIndex, pageSize)
  771. page := paging.GetPaging(currentIndex, pageSize, total)
  772. resp := new(models.ReoprtSearchResp)
  773. //匹配报告标题、
  774. condition = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
  775. conditionSql = ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + condition + ` OR ( article_type = 'lyjh' ` + condition + ` ) `
  776. total, err := models.GetReoprtSearchCount(conditionSql)
  777. if err != nil {
  778. br.Msg = "获取信息失败"
  779. br.Msg = "获取总数失败,Err:" + err.Error()
  780. return
  781. }
  782. //listHz, err := models.GetReoprtSearchList(` AND a.article_id < `+strconv.Itoa(utils.SummaryArticleId)+condition+` OR ( article_type = 'lyjh' `+condition+` ) `+sqlGroup, user.UserId, startSize, pageSize)
  783. listHz, err := models.GetReoprtSearchList(conditionSql, user.UserId, startSize, pageSize)
  784. if err != nil {
  785. br.Msg = "获取信息失败"
  786. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  787. return
  788. }
  789. for k, _ := range listHz {
  790. listHz[k].Source = 1
  791. }
  792. var articleIds string
  793. for _, v := range listHz {
  794. articleIds += strconv.Itoa(v.ArticleId) + ","
  795. }
  796. articleIds = strings.TrimRight(articleIds, ",")
  797. silcearticleIds := strings.Split(articleIds, ",")
  798. //获取文章关联的产业
  799. var pars []interface{}
  800. pars = make([]interface{}, 0)
  801. articleIdList := make([]string, 0)
  802. for _, v := range silcearticleIds {
  803. articleIdList = append(articleIdList, v)
  804. }
  805. condition = ` AND mg.article_id IN ( ` + utils.GetOrmInReplace(len(silcearticleIds)) + ` ) `
  806. pars = append(pars, articleIdList)
  807. industrialList, err := models.GetIndustrialListByarticleId(pars, condition)
  808. if err != nil {
  809. br.Msg = "获取失败"
  810. br.ErrMsg = "获取失败,GetSubjectList Err:" + err.Error()
  811. return
  812. }
  813. industrialMap := make(map[int][]*models.IndustrialManagementResp)
  814. if len(industrialList) > 0 {
  815. for _, v := range industrialList {
  816. item := new(models.IndustrialManagementResp)
  817. //item.ArticleId = v.ArticleId
  818. item.IndustrialManagementId = v.IndustrialManagementId
  819. item.IndustryName = v.IndustryName
  820. item.ChartPermissionId = v.ChartPermissionId
  821. industrialMap[v.ArticleId] = append(industrialMap[v.ArticleId], item)
  822. }
  823. }
  824. detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  825. if err != nil {
  826. br.Msg = "获取数据失败"
  827. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  828. return
  829. }
  830. categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  831. mapCategoryUrl := make(map[string]string)
  832. var categoryId string
  833. var imgUrlChart string
  834. for _, v := range categoryUrlList {
  835. vslice := strings.Split(v, "_")
  836. categoryId = vslice[0]
  837. imgUrlChart = vslice[len(vslice)-1]
  838. mapCategoryUrl[categoryId] = imgUrlChart
  839. }
  840. for k, v := range listHz {
  841. if len(industrialMap[v.ArticleId]) > 0 {
  842. listHz[k].List = industrialMap[v.ArticleId]
  843. } else {
  844. listHz[k].List = make([]*models.IndustrialManagementResp, 0)
  845. }
  846. listHz[k].Body = ""
  847. listHz[k].Abstract, _ = services.GetReportContentTextSub(v.Abstract)
  848. listHz[k].Annotation, _ = services.GetReportContentTextSub(v.Annotation)
  849. //行业比较研究、资金流向,显示报告的摘要
  850. if listHz[k].CategoryName == "行业比较研究" || listHz[k].CategoryName == "资金流向" {
  851. listHz[k].Annotation = listHz[k].Abstract
  852. }
  853. listHz[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  854. }
  855. if keyWord != "" {
  856. go services.AddUserSearchLog(user, keyWord, 5)
  857. }
  858. if len(listHz) == 0 {
  859. listHz = make([]*models.ArticleCollectionResp, 0)
  860. }
  861. page = paging.GetPaging(currentIndex, pageSize, total)
  862. resp.Paging = page
  863. resp.ListHz = listHz
  864. br.Ret = 200
  865. br.Success = true
  866. br.Msg = "获取成功"
  867. br.Data = resp
  868. }
  869. // @Title 资源包搜索
  870. // @Description 资源包搜索接口
  871. // @Param KeyWord query string true "搜索关键词"
  872. // @Success 200 {object} models.SearchResourceResp
  873. // @router /searchResource [get]
  874. func (this *MobileReportController) SearchResource() {
  875. br := new(models.BaseResponse).Init()
  876. defer func() {
  877. this.Data["json"] = br
  878. this.ServeJSON()
  879. }()
  880. user := this.User
  881. if user == nil {
  882. br.Msg = "请重新登录"
  883. br.Ret = 408
  884. return
  885. }
  886. uid := user.UserId
  887. fllowList, err := models.GetUserFllowIndustrialList(uid)
  888. if err != nil {
  889. br.Msg = "获取失败"
  890. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  891. return
  892. }
  893. fllowMap := make(map[int]int)
  894. if len(fllowList) > 0 {
  895. for _, v := range fllowList {
  896. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  897. }
  898. }
  899. keyWord := this.GetString("KeyWord")
  900. var condition string
  901. var conditionOr string
  902. conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  903. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  904. listHz, err := models.GetSearchResourceList(condition)
  905. if err != nil {
  906. br.Msg = "获取信息失败"
  907. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  908. return
  909. }
  910. //合并产业关联的标的
  911. listSubjcet, err := models.GetThemeHeatSubjectList("")
  912. if err != nil {
  913. br.Msg = "获取信息失败"
  914. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  915. return
  916. }
  917. industrialIdArr := make([]int, 0)
  918. for k, v := range listHz {
  919. listHz[k].Source = 1
  920. if fllowMap[v.IndustrialManagementId] > 0 {
  921. listHz[k].IsFollow = true
  922. }
  923. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  924. }
  925. if len(industrialIdArr) > 0 {
  926. //合并产业关联的标的
  927. listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
  928. if err != nil {
  929. br.Msg = "获取信息失败"
  930. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  931. return
  932. }
  933. mapIndustrial := make(map[string]int)
  934. for _, v := range listSubjcet {
  935. for k2, v2 := range listHz {
  936. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
  937. listHz[k2].IndustrialSubjectList = append(listHz[k2].IndustrialSubjectList, v)
  938. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
  939. }
  940. }
  941. }
  942. }
  943. mapUPdateTime := make(map[int]string)
  944. articleIdArr := make([]int, 0)
  945. //获取这些产业下最新更新的文章
  946. fmt.Println(industrialIdArr)
  947. listUpdateTime, err := models.GetNewArticleDetailByIndustrialIds(industrialIdArr)
  948. if err != nil && err.Error() != utils.ErrNoRow() {
  949. br.Msg = "获取信息失败"
  950. br.ErrMsg = "获取信息失败 GetNewArticleDetailByIndustrialIds ,Err:" + err.Error()
  951. return
  952. }
  953. for _, v := range listUpdateTime {
  954. mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
  955. articleIdArr = append(articleIdArr, v.ArticleId)
  956. }
  957. for k, v := range listHz {
  958. listHz[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
  959. }
  960. if keyWord != "" {
  961. go services.AddUserSearchLog(user, keyWord, 4)
  962. }
  963. resp := new(models.SearchResourceResp)
  964. if len(listHz) == 0 {
  965. listHz = make([]*models.IndustrialManagement, 0)
  966. }
  967. resp.ListHz = listHz
  968. br.Ret = 200
  969. br.Success = true
  970. br.Msg = "获取成功"
  971. br.Data = resp
  972. }
  973. // @Title 报告搜索、资源包搜索接口
  974. // @Description 报告搜索、资源包搜索接口接口
  975. // @Param KeyWord query string true "搜索关键词"
  976. // @Param PageSize query int true "每页数据条数"
  977. // @Param CurrentIndex query int true "当前页页码,从1开始"
  978. // @Param SearchType query int true "1:综合,2:全部"
  979. // @Success 200 {object} models.SearchReportAndResourceResp
  980. // @router /searchReportAndResource [get]
  981. func (this *MobileReportController) SearchReportAndResource() {
  982. br := new(models.BaseResponse).Init()
  983. defer func() {
  984. this.Data["json"] = br
  985. this.ServeJSON()
  986. }()
  987. user := this.User
  988. if user == nil {
  989. br.Msg = "请重新登录"
  990. br.Ret = 408
  991. return
  992. }
  993. //uid := user.UserId
  994. keyWord := this.GetString("KeyWord")
  995. pageSize, _ := this.GetInt("PageSize")
  996. currentIndex, _ := this.GetInt("CurrentIndex")
  997. searchType, _ := this.GetInt("SearchType")
  998. var total int
  999. var startSize int
  1000. if pageSize <= 0 {
  1001. pageSize = utils.PageSize20
  1002. }
  1003. if currentIndex <= 0 {
  1004. currentIndex = 1
  1005. }
  1006. startSize = paging.StartIndex(currentIndex, pageSize)
  1007. page := paging.GetPaging(currentIndex, pageSize, total)
  1008. var condition string
  1009. var conditionSql string
  1010. //匹配报告标题、
  1011. condition = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
  1012. conditionSql = ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + condition + ` OR ( article_type = 'lyjh' ` + condition + ` ) `
  1013. total, err := models.GetReoprtSearchCount(conditionSql)
  1014. if err != nil {
  1015. br.Msg = "获取信息失败"
  1016. br.Msg = "获取总数失败,Err:" + err.Error()
  1017. return
  1018. }
  1019. if searchType == 1 {
  1020. pageSize = utils.PageSize5
  1021. }
  1022. ListHzReport, err := services.GetReoprtSearchListHz(conditionSql, user.UserId, startSize, pageSize)
  1023. if err != nil {
  1024. br.Msg = "获取失败"
  1025. br.ErrMsg = "获取失败,GetReoprtSearchListHz Err:" + err.Error()
  1026. return
  1027. }
  1028. if len(ListHzReport) == 0 {
  1029. ListHzReport = make([]*models.ArticleCollectionResp, 0)
  1030. }
  1031. var conditionOr string
  1032. conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  1033. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  1034. listHzResource, err := services.GetSearchResourceListHz(condition, user)
  1035. if err != nil {
  1036. br.Msg = "获取信息失败"
  1037. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1038. return
  1039. }
  1040. resp := new(models.SearchReportAndResourceResp)
  1041. if len(listHzResource) == 0 {
  1042. listHzResource = make([]*models.IndustrialManagement, 0)
  1043. }
  1044. if keyWord != "" {
  1045. go services.AddUserSearchLog(user, keyWord, 5)
  1046. }
  1047. page = paging.GetPaging(currentIndex, pageSize, total)
  1048. resp.Paging = page
  1049. resp.ListHzResource = listHzResource
  1050. resp.ListHzReport = ListHzReport
  1051. br.Ret = 200
  1052. br.Success = true
  1053. br.Msg = "获取成功"
  1054. br.Data = resp
  1055. }
  1056. // @Title 公司速览
  1057. // @Description 公司速览接口
  1058. // @Param ChartPermissionId query int false "分类ID"
  1059. // @Success 200 {object} models.ArticleDataLogoListResp
  1060. // @router /companyList [get]
  1061. func (this *ReportCommonController) CompanyList() {
  1062. br := new(models.BaseResponse).Init()
  1063. defer func() {
  1064. this.Data["json"] = br
  1065. this.ServeJSON()
  1066. }()
  1067. var condition string
  1068. var pars []interface{}
  1069. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  1070. if chartPermissionId > 1 {
  1071. categoryId, err := models.GetCategoryId(chartPermissionId)
  1072. if err != nil && err.Error() != utils.ErrNoRow() {
  1073. br.Msg = "获取信息失败"
  1074. br.ErrMsg = "获取分类权限信息失败,Err:" + err.Error()
  1075. return
  1076. }
  1077. if categoryId != "" {
  1078. condition += ` AND a.category_id IN (` + categoryId + `)`
  1079. }
  1080. }
  1081. condition += ` AND a.type_name = '综述报告' ORDER BY a.modify_time_by_cl DESC `
  1082. list, err := models.CygxArticleDataList(condition, pars)
  1083. if err != nil {
  1084. br.Msg = "获取失败"
  1085. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  1086. return
  1087. }
  1088. listLogo := make([]*models.ArticleDataLogoResp, 0)
  1089. for i := range list {
  1090. v := list[i]
  1091. comapnyList := services.HandleArticleStock(v.Stock)
  1092. if len(comapnyList) > 1 {
  1093. for kC, vC := range comapnyList {
  1094. sliceCovers := strings.Split(v.Cover, "{|}")
  1095. cover := v.Cover
  1096. if len(sliceCovers) == len(comapnyList) {
  1097. cover = sliceCovers[kC]
  1098. }
  1099. listLogo = append(listLogo, &models.ArticleDataLogoResp{
  1100. ArticleId: v.ArticleId,
  1101. Cover: cover,
  1102. ComapnyList: services.HandleArticleStock(vC.ComapnyName),
  1103. })
  1104. }
  1105. } else {
  1106. listLogo = append(listLogo, &models.ArticleDataLogoResp{
  1107. ArticleId: v.ArticleId,
  1108. Cover: v.Cover,
  1109. ComapnyList: services.HandleArticleStock(v.Stock),
  1110. })
  1111. }
  1112. }
  1113. resp := new(models.ArticleDataLogoListResp)
  1114. resp.List = listLogo
  1115. br.Ret = 200
  1116. br.Success = true
  1117. br.Msg = "获取成功"
  1118. br.Data = resp
  1119. }
  1120. // @Title 时间线
  1121. // @Description 时间线接口
  1122. // @Param PageSize query int true "每页数据条数"
  1123. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1124. // @Param IndustrialManagementId query int false "产业ID"
  1125. // @Success 200 {object} models.TacticsListResp
  1126. // @router /timeline [get]
  1127. func (this *ReportCommonController) Timeline() {
  1128. br := new(models.BaseResponse).Init()
  1129. defer func() {
  1130. this.Data["json"] = br
  1131. this.ServeJSON()
  1132. }()
  1133. pageSize, _ := this.GetInt("PageSize")
  1134. currentIndex, _ := this.GetInt("CurrentIndex")
  1135. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  1136. var startSize int
  1137. if pageSize <= 0 {
  1138. pageSize = utils.PageSize20
  1139. }
  1140. if currentIndex <= 0 {
  1141. currentIndex = 1
  1142. }
  1143. startSize = paging.StartIndex(currentIndex, pageSize)
  1144. var total int
  1145. resp := new(models.TacticsListResp)
  1146. page := paging.GetPaging(currentIndex, pageSize, total)
  1147. list := make([]*models.HomeArticle, 0)
  1148. var err error
  1149. list, total, err = models.GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize)
  1150. if err != nil {
  1151. br.Msg = "获取信息失败"
  1152. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  1153. return
  1154. }
  1155. lenList := len(list)
  1156. for i := 0; i < lenList; i++ {
  1157. item := list[i]
  1158. list[i].Body = ""
  1159. list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  1160. list[i].Annotation, _ = services.GetReportContentTextSub(item.Annotation)
  1161. list[i].PublishDate = utils.StrTimeToTime(item.PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
  1162. //行业比较研究、资金流向,显示报告的摘要
  1163. if resp.MatchTypeName == "行业比较研究" || resp.MatchTypeName == "资金流向" {
  1164. list[i].Annotation = list[i].Abstract
  1165. }
  1166. }
  1167. if len(list) == 0 {
  1168. list = make([]*models.HomeArticle, 0)
  1169. }
  1170. page = paging.GetPaging(currentIndex, pageSize, total)
  1171. resp.List = list
  1172. resp.Paging = page
  1173. br.Ret = 200
  1174. br.Success = true
  1175. br.Msg = "获取成功"
  1176. br.Data = resp
  1177. }