report.go 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hongze_clpt/models"
  6. "hongze/hongze_clpt/services"
  7. "hongze/hongze_clpt/utils"
  8. "strconv"
  9. "strings"
  10. "time"
  11. )
  12. // 报告
  13. type ReportController struct {
  14. BaseAuthController
  15. }
  16. type ReportCommonController struct {
  17. BaseCommonController
  18. }
  19. type MobileReportController struct {
  20. BaseAuthMobileController
  21. }
  22. // @Title 行业报告分类列表接口
  23. // @Description 获取行业报告分类列表接口
  24. // @Param ChartPermissionId query int true "分类ID"
  25. // @Success 200 {object} models.TradeReportMappingResp
  26. // @router /tradeList [get]
  27. func (this *MobileReportController) TradeList() {
  28. br := new(models.BaseResponse).Init()
  29. defer func() {
  30. this.Data["json"] = br
  31. this.ServeJSON()
  32. }()
  33. user := this.User
  34. if user == nil {
  35. br.Msg = "请重新登录"
  36. br.Ret = 408
  37. return
  38. }
  39. //uid := user.UserId
  40. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  41. if ChartPermissionId < 1 {
  42. br.Msg = "请输入分类ID"
  43. return
  44. }
  45. //var result []*models.SearchItem
  46. var list []*models.TradeReportMapping
  47. var err error
  48. mapCategory := make(map[int]int)
  49. if ChartPermissionId == utils.CE_LUE_ID || ChartPermissionId == utils.GU_SHOU_ID {
  50. listTrade, errTrade := models.GetReportMappingStrategyHomeAllByCygx(user.UserId, ChartPermissionId)
  51. err = errTrade
  52. if ChartPermissionId == utils.CE_LUE_ID {
  53. cf, err := models.GetConfigByCode(utils.CYGX_TACTICS_TIME_LINE_STATUS)
  54. if err != nil {
  55. br.Msg = "获取失败"
  56. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  57. return
  58. }
  59. if cf.ConfigValue == "1" || user.CompanyId == utils.HZ_COMPANY_ID {
  60. item := new(models.TradeReportMapping)
  61. item.CategoryId = utils.TIME_LINE_ID
  62. item.MatchTypeName = utils.TIME_LINE_NAME
  63. list = append(list, item)
  64. }
  65. }
  66. for _, v := range listTrade {
  67. list = append(list, v)
  68. }
  69. if user.Mobile != "" {
  70. //策略的处理
  71. categoryList, err := models.GetCygxXzsChooseCategoryList(user.Mobile)
  72. if err != nil && err.Error() != utils.ErrNoRow() {
  73. br.Msg = "获取信息失败"
  74. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  75. return
  76. }
  77. for _, v := range categoryList {
  78. mapCategory[v.IdCygx] = v.IdCygx
  79. }
  80. }
  81. } else {
  82. listCategory, err := models.GetTradeArticleAndProductInterior(ChartPermissionId)
  83. if err != nil {
  84. br.Msg = "获取信息失败"
  85. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  86. return
  87. }
  88. categoryMap := make(map[int]int)
  89. for _, v := range listCategory {
  90. if categoryMap[v.CategoryId] > 0 {
  91. continue
  92. }
  93. categoryMap[v.CategoryId] = v.CategoryId
  94. list = append(list, v)
  95. }
  96. //加了一个需求,现有数据结构不支持,手动添加 2023-06-12
  97. //if ChartPermissionId == utils.KE_JI_ID {
  98. // list = append(list, &models.TradeReportMapping{MatchTypeName: "AI前沿", CategoryId: utils.ACTEGORY_ID_AI_QY})
  99. //}
  100. }
  101. if err != nil {
  102. br.Msg = "获取信息失败"
  103. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  104. return
  105. }
  106. for k, v := range list {
  107. if ChartPermissionId != utils.CE_LUE_ID && ChartPermissionId != utils.GU_SHOU_ID {
  108. var pageSize int
  109. var listArticle []*models.HomeArticle
  110. pageSize = 3
  111. if v.CategoryId == utils.ACTEGORY_ID_AI_QY {
  112. //加了一个需求,现有数据结构不支持,手动添加 2023-06-12
  113. listArticle, _, err = services.GetAiQianYanArtilceList(0, pageSize)
  114. } else {
  115. listArticle, _, err = models.GetReportAndproductIndustrylList(v.CategoryId, 0, pageSize)
  116. }
  117. if err != nil {
  118. br.Msg = "获取信息失败"
  119. br.Msg = "GetHomeList,Err:" + err.Error()
  120. return
  121. }
  122. if len(listArticle) > 0 {
  123. list[k].UpdateTime = utils.StrTimeToTime(listArticle[0].PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
  124. }
  125. list[k].ListArticle = listArticle
  126. } else {
  127. if mapCategory[v.CategoryId] > 0 {
  128. list[k].IsFollow = true
  129. }
  130. list[k].ListArticle = make([]*models.HomeArticle, 0)
  131. }
  132. }
  133. resp := new(models.TradeReportMappingResp)
  134. if len(list) == 0 {
  135. list = make([]*models.TradeReportMapping, 0)
  136. }
  137. resp.List = list
  138. br.Ret = 200
  139. br.Success = true
  140. br.Msg = "获取成功"
  141. br.Data = resp
  142. }
  143. // @Title 产业报告分类列表接口
  144. // @Description 获取产业报告分类列表接口
  145. // @Param ChartPermissionId query int true "分类ID"
  146. // @Param DeepCover query int false "是否选择深度覆盖,1是,0否 不填默认为0"
  147. // @Param RecommendFocus query int false "是否选择推荐关注,1是,0否 不填默认为0"
  148. // @Param PageSize query int true "每页数据条数"
  149. // @Param CurrentIndex query int true "当前页页码,从1开始"
  150. // @Param IsBillboard query bool false "是否属于榜单 是true 否 false"
  151. // @Success 200 {object} models.IndustrialManagementList
  152. // @router /industryList [get]
  153. func (this *MobileReportController) IndustryList() {
  154. br := new(models.BaseResponse).Init()
  155. defer func() {
  156. this.Data["json"] = br
  157. this.ServeJSON()
  158. }()
  159. user := this.User
  160. if user == nil {
  161. br.Msg = "请重新登录"
  162. br.Ret = 408
  163. return
  164. }
  165. uid := user.UserId
  166. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  167. orderColumn := this.GetString("OrderColumn")
  168. orderColumnNew := this.GetString("OrderColumn")
  169. isNewLabel := this.GetString("IsNewLabel")
  170. isDeepLabel := this.GetString("IsDeepLabel")
  171. pageSize, _ := this.GetInt("PageSize")
  172. currentIndex, _ := this.GetInt("CurrentIndex")
  173. deepCover, _ := this.GetInt("DeepCover")
  174. recommendFocus, _ := this.GetInt("RecommendFocus")
  175. isBillboard, _ := this.GetBool("IsBillboard", false)
  176. var orderSrt string
  177. var condition string
  178. var startSize int
  179. resp := new(models.IndustrialManagementList)
  180. if pageSize <= 0 {
  181. pageSize = utils.PageSize20
  182. }
  183. if currentIndex <= 0 {
  184. currentIndex = 1
  185. }
  186. startSize = paging.StartIndex(currentIndex, pageSize)
  187. if ChartPermissionId > 0 {
  188. condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
  189. }
  190. // 获取近一个月产业报告阅读次数最多的产业
  191. var topCond string
  192. var topPars []interface{}
  193. topReadIndustryId := 0
  194. if ChartPermissionId > 0 {
  195. topCond += ` AND chart_permission_id = ?`
  196. topPars = append(topPars, ChartPermissionId)
  197. }
  198. topReadIndustry, e := models.GetTopOneMonthArtReadNumIndustry(topCond, topPars)
  199. if e != nil && e.Error() != utils.ErrNoRow() {
  200. br.Msg = "获取信息失败"
  201. br.ErrMsg = "获取近一个月报告阅读次数最多的产业失败, Err: " + e.Error()
  202. return
  203. }
  204. if topReadIndustry != nil {
  205. topReadIndustryId = topReadIndustry.IndustrialManagementId
  206. }
  207. // 深度覆盖
  208. if deepCover == 1 {
  209. // 查询深标签产业报告数
  210. var deepCondition string
  211. var deepPars []interface{}
  212. deepCondition += ` AND man.is_deep_label = 1`
  213. if ChartPermissionId > 0 {
  214. deepCondition += ` AND man.chart_permission_id = ?`
  215. deepPars = append(deepPars, ChartPermissionId)
  216. }
  217. industryCountList, e := models.GetIndustryArtCountByCondition(deepCondition, deepPars)
  218. if e != nil {
  219. br.Msg = "获取信息失败"
  220. br.ErrMsg = "获取深标签产业报告数失败, Err: " + e.Error()
  221. return
  222. }
  223. deepIdArr := make([]string, 0)
  224. for i := range industryCountList {
  225. if industryCountList[i].ArtNum > 10 {
  226. deepIdArr = append(deepIdArr, strconv.Itoa(industryCountList[i].IndustrialManagementId))
  227. }
  228. }
  229. deepIds := strings.Join(deepIdArr, ",")
  230. if deepIds != "" {
  231. condition = `AND man.industrial_management_id IN (` + deepIds + `)`
  232. }
  233. }
  234. // 推荐关注
  235. if recommendFocus == 1 {
  236. condition += ` AND man.recommended_index >= 80`
  237. }
  238. var list []*models.IndustrialManagement
  239. total, err := models.GetIndustrialManagementAllCount(condition)
  240. if err != nil {
  241. br.Msg = "获取信息失败"
  242. br.ErrMsg = "获取数量失败,Err:" + err.Error()
  243. return
  244. }
  245. if orderColumn == "" {
  246. orderColumn = "NewTime"
  247. }
  248. if orderColumn == "NewTime" {
  249. orderSrt = "update_time DESC"
  250. } else {
  251. orderSrt = "man.recommended_index DESC,update_time DESC"
  252. }
  253. if isBillboard {
  254. // 查询有已归类行业报告的行业IDs
  255. activeIndustryIds, e := models.GetActiveArticleIndustryIds()
  256. if e != nil {
  257. br.Msg = "获取失败"
  258. br.ErrMsg = "获取已归类行业失败, Err:" + e.Error()
  259. return
  260. }
  261. activeIndustryLen := len(activeIndustryIds)
  262. //topNum := pageSize
  263. condition = ""
  264. var parsBd []interface{}
  265. if ChartPermissionId > 0 {
  266. condition += ` AND man.chart_permission_id = ? `
  267. parsBd = append(parsBd, ChartPermissionId)
  268. }
  269. if activeIndustryLen > 0 {
  270. condition += ` AND man.industrial_management_id IN (` + utils.GetOrmInReplace(activeIndustryLen) + `)`
  271. parsBd = append(parsBd, activeIndustryIds)
  272. }
  273. //nowTime := time.Now().Local()
  274. //startTime := nowTime.AddDate(0, -1, 0)
  275. //endTime := nowTime.AddDate(0, 0, -1)
  276. //condition += ` AND idf.create_time BETWEEN ? AND ?`
  277. //parsBd = append(parsBd, startTime, endTime)
  278. list, e = models.GetTopIndustryFollowData(0, pageSize, condition, parsBd)
  279. if e != nil {
  280. br.Msg = "获取失败"
  281. br.ErrMsg = "获取关注度最高的产业数据失败, Err:" + e.Error()
  282. return
  283. }
  284. } else {
  285. list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize, isBillboard)
  286. if err != nil {
  287. br.Msg = "获取信息失败"
  288. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  289. return
  290. }
  291. }
  292. var resource string
  293. if ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  294. resource = utils.REOURCE_YX
  295. } else {
  296. resource = utils.REOURCE_HZ
  297. }
  298. list, err = services.HandleIndustryList(list, user, resource)
  299. if err != nil {
  300. br.Msg = "获取信息失败"
  301. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  302. return
  303. }
  304. industrialIdArr := make([]int, 0)
  305. for k, v := range list {
  306. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  307. if topReadIndustryId > 0 && list[k].IndustrialManagementId == topReadIndustryId {
  308. list[k].IsHot = true
  309. }
  310. }
  311. if orderColumnNew != "" {
  312. item := new(models.CygxReportIndustrialSeaarchHistory)
  313. item.UserId = user.UserId
  314. item.Mobile = user.Mobile
  315. item.CompanyId = user.CompanyId
  316. item.CompanyName = user.CompanyName
  317. item.CreateTime = time.Now()
  318. item.IsDeepLabel = isDeepLabel
  319. item.IsNewLabel = isNewLabel
  320. item.ChartPermissionId = ChartPermissionId
  321. if orderColumnNew == "NewTime" {
  322. item.OrderColumn = "0"
  323. } else {
  324. item.OrderColumn = "1"
  325. }
  326. go models.AddCygxReportIndustrialSeaarchHistory(item)
  327. }
  328. if len(list) == 0 {
  329. list = make([]*models.IndustrialManagement, 0)
  330. }
  331. page := paging.GetPaging(currentIndex, pageSize, total)
  332. if isBillboard {
  333. total = len(list)
  334. }
  335. resp.List = list
  336. resp.Paging = page
  337. br.Ret = 200
  338. br.Success = true
  339. br.Msg = "获取成功"
  340. br.Data = resp
  341. }
  342. // @Title 产业下所关联的文章分类列表
  343. // @Description 产业下所关联的文章分类列表接口
  344. // @Param IndustrialManagementId query int true "产业ID"
  345. // @Success 200 {object} models.IndustrialToArticleCategoryListRep
  346. // @router /toArticleCategoryList [get]
  347. func (this *MobileReportController) ArticleCategoryList() {
  348. br := new(models.BaseResponse).Init()
  349. defer func() {
  350. this.Data["json"] = br
  351. this.ServeJSON()
  352. }()
  353. user := this.User
  354. if user == nil {
  355. br.Msg = "请重新登录"
  356. br.Ret = 408
  357. return
  358. }
  359. //uid := user.UserId
  360. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  361. if industrialManagementId < 1 {
  362. br.Msg = "请输入分类ID"
  363. return
  364. }
  365. detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  366. if err != nil {
  367. br.Msg = "获取信息失败"
  368. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  369. return
  370. }
  371. listCategory, err := models.IndustrialToArticleAndProductInteriorCategoryNew(industrialManagementId)
  372. if err != nil {
  373. br.Msg = "获取信息失败"
  374. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  375. return
  376. }
  377. var list []*models.IndustrialToArticleCategoryRep
  378. categoryMap := make(map[int]int)
  379. for _, v := range listCategory {
  380. if categoryMap[v.CategoryId] > 0 {
  381. continue
  382. }
  383. categoryMap[v.CategoryId] = v.CategoryId
  384. list = append(list, v)
  385. }
  386. //标的列表
  387. industrialSubjectList, err := models.GetIndustrialArticleGroupSubjectListByHz(industrialManagementId)
  388. if err != nil {
  389. br.Msg = "获取信息失败"
  390. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  391. return
  392. }
  393. videoSimple, au, err := services.GetindustryVideo(user, industrialManagementId)
  394. if err != nil {
  395. br.Msg = "获取失败"
  396. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  397. return
  398. }
  399. timeLineItem := models.IndustrialToArticleCategoryRep{
  400. CategoryId: utils.TIME_CATEGORYID,
  401. MatchTypeName: "时间线",
  402. }
  403. timeLineIsRed, err := services.GetShowTimeLineIsRed(user, industrialManagementId)
  404. if err != nil {
  405. br.Msg = "获取失败"
  406. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  407. return
  408. }
  409. timeLineItem.IsRed = timeLineIsRed
  410. list = append([]*models.IndustrialToArticleCategoryRep{&timeLineItem}, list...)
  411. resp := new(models.IndustrialToArticleCategoryListRep)
  412. resp.List = list
  413. resp.ListSubject = industrialSubjectList
  414. resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
  415. resp.IndustryName = detail.IndustryName
  416. resp.IndustrialManagementId = industrialManagementId
  417. if videoSimple != nil && videoSimple.Id > 0 {
  418. resp.IndustryVideo = videoSimple
  419. }
  420. resp.AuthInfo = au
  421. br.Ret = 200
  422. br.Success = true
  423. br.Msg = "获取成功"
  424. br.Data = resp
  425. }
  426. // @Title 根据行业分类获取文章列表
  427. // @Description根据行业分类获取文章列表接口
  428. // @Param PageSize query int true "每页数据条数"
  429. // @Param CurrentIndex query int true "当前页页码,从1开始"
  430. // @Param CategoryId query int true "分类ID"
  431. // @Param IndustrialManagementId query int false "产业ID"
  432. // @Success 200 {object} models.TacticsListResp
  433. // @router /articleList/byCategoryId [get]
  434. func (this *MobileReportController) List() {
  435. br := new(models.BaseResponse).Init()
  436. defer func() {
  437. this.Data["json"] = br
  438. this.ServeJSON()
  439. }()
  440. user := this.User
  441. if user == nil {
  442. br.Msg = "请重新登录"
  443. br.Ret = 408
  444. return
  445. }
  446. //uid := user.UserId
  447. pageSize, _ := this.GetInt("PageSize")
  448. currentIndex, _ := this.GetInt("CurrentIndex")
  449. categoryId, _ := this.GetInt("CategoryId")
  450. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  451. uid := user.UserId
  452. var startSize int
  453. if pageSize <= 0 {
  454. pageSize = utils.PageSize20
  455. }
  456. if currentIndex <= 0 {
  457. currentIndex = 1
  458. }
  459. startSize = paging.StartIndex(currentIndex, pageSize)
  460. //var condition string
  461. var pars []interface{}
  462. var total int
  463. resp := new(models.TacticsListResp)
  464. page := paging.GetPaging(currentIndex, pageSize, total)
  465. list := make([]*models.ArticleListResp, 0)
  466. if categoryId == utils.TIME_CATEGORYID {
  467. var err error
  468. list, total, err = models.GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize)
  469. if err != nil {
  470. br.Msg = "获取信息失败"
  471. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  472. return
  473. }
  474. } else {
  475. //获取该产业下所对应的行业图片
  476. //var reportType int
  477. //if industrialManagementId > 0 {
  478. // reportType = 2
  479. //} else {
  480. // reportType = 1
  481. //}
  482. //detail, errCategory := models.GetdetailByCategoryIdOne(categoryId, reportType)
  483. //if errCategory != nil {
  484. // br.Msg = "获取信息失败"
  485. // br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  486. // return
  487. //}
  488. //对应行业的图片
  489. detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
  490. if err != nil {
  491. br.Msg = "获取数据失败"
  492. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  493. return
  494. }
  495. chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
  496. mapChartPermission := make(map[string]string)
  497. var permissionName string
  498. var imgUrlChartPermission string
  499. for _, v := range chartPermissionUrlList {
  500. vslice := strings.Split(v, "_")
  501. permissionName = vslice[0]
  502. imgUrlChartPermission = vslice[len(vslice)-1]
  503. mapChartPermission[permissionName] = imgUrlChartPermission
  504. }
  505. //对应分类的所图片
  506. detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  507. if err != nil {
  508. br.Msg = "获取数据失败"
  509. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  510. return
  511. }
  512. categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  513. mapCategoryUrl := make(map[string]string)
  514. var categoryIdStr string
  515. var imgUrlChart string
  516. for _, v := range categoryUrlList {
  517. vslice := strings.Split(v, "_")
  518. categoryIdStr = vslice[0]
  519. imgUrlChart = vslice[len(vslice)-1]
  520. mapCategoryUrl[categoryIdStr] = imgUrlChart
  521. }
  522. list, total, err = models.GetReportAndproductInteriorIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
  523. if err != nil {
  524. br.Msg = "获取信息失败"
  525. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  526. return
  527. }
  528. articleIdMap, err := services.GetUserArticleHistoryRecord(user)
  529. if err != nil {
  530. br.Msg = "获取信息失败"
  531. br.Msg = "获取帖子数据失败,Err:" + err.Error()
  532. return
  533. }
  534. for k, v := range list {
  535. list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  536. if !articleIdMap[v.ArticleId] && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  537. list[k].IsRed = true
  538. }
  539. }
  540. }
  541. listPublic, err := services.HandleArticleCategoryImg(list, user)
  542. if err != nil {
  543. br.Msg = "获取失败"
  544. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  545. return
  546. }
  547. var articleIds []int
  548. for _, v := range listPublic {
  549. if v.Resource == 1 {
  550. articleIds = append(articleIds, v.ArticleId)
  551. }
  552. }
  553. articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
  554. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
  555. articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
  556. listResp := make([]*models.HomeArticle, 0)
  557. //listResp :=
  558. for _, v := range listPublic {
  559. listResp = append(listResp, &models.HomeArticle{
  560. ArticleId: v.ArticleId,
  561. Title: v.Title,
  562. Annotation: "核心观点:" + v.Annotation,
  563. Abstract: v.Abstract,
  564. ImgUrlPc: v.ImgUrlPc,
  565. PublishDate: v.PublishDate,
  566. Resource: v.Resource,
  567. Pv: articleMapPv[v.ArticleId],
  568. IsCollect: articleCollectMap[v.ArticleId],
  569. CollectNum: articleCollectNumMap[v.ArticleId],
  570. })
  571. }
  572. //lenList := len(list)
  573. //for i := 0; i < lenList; i++ {
  574. // item := list[i]
  575. // list[i].Body = ""
  576. // list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  577. // list[i].Annotation, _ = services.GetReportContentTextSub(item.Annotation)
  578. // list[i].PublishDate = utils.StrTimeToTime(item.PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
  579. // //行业比较研究、资金流向,显示报告的摘要
  580. // if resp.MatchTypeName == "行业比较研究" || resp.MatchTypeName == "资金流向" {
  581. // list[i].Annotation = list[i].Abstract
  582. // }
  583. //}
  584. if len(listResp) == 0 {
  585. listResp = make([]*models.HomeArticle, 0)
  586. }
  587. page = paging.GetPaging(currentIndex, pageSize, total)
  588. resp.List = listResp
  589. resp.Paging = page
  590. br.Ret = 200
  591. br.Success = true
  592. br.Msg = "获取成功"
  593. br.Data = resp
  594. }
  595. // @Title 产业关注/取消关注
  596. // @Description 产业关注/取消关注 接口
  597. // @Param request body models.CygxIndustryFllowRep true "type json string"
  598. // @Success 200
  599. // @router /industrial/fllow [post]
  600. func (this *ReportController) IndustrialFllow() {
  601. br := new(models.BaseResponse).Init()
  602. defer func() {
  603. this.Data["json"] = br
  604. this.ServeJSON()
  605. }()
  606. user := this.User
  607. if user == nil {
  608. br.Msg = "请重新登录"
  609. br.Ret = 408
  610. return
  611. }
  612. uid := user.UserId
  613. var req models.CygxIndustryFllowRep
  614. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  615. if err != nil {
  616. br.Msg = "参数解析异常!"
  617. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  618. return
  619. }
  620. industrialManagementId := req.IndustrialManagementId
  621. var condition string
  622. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  623. if err != nil {
  624. br.Msg = "获取数据失败!"
  625. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  626. return
  627. }
  628. if countIndustrial == 0 {
  629. br.Msg = "产业不存在!"
  630. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  631. return
  632. }
  633. count, err := models.GetCountCygxIndustryFllow(industrialManagementId, user.UserId, condition)
  634. if err != nil {
  635. br.Msg = "获取数据失败!"
  636. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  637. return
  638. }
  639. resp := new(models.CygxIndustryFllowResp)
  640. item := new(models.CygxIndustryFllow)
  641. item.IndustrialManagementId = industrialManagementId
  642. item.UserId = uid
  643. item.Email = user.Email
  644. item.Mobile = user.Mobile
  645. item.RealName = user.RealName
  646. item.Source = utils.REGISTER_PLATFORM
  647. item.CompanyId = user.CompanyId
  648. item.CompanyName = user.CompanyName
  649. if count == 0 {
  650. item.Type = 1
  651. item.CreateTime = time.Now()
  652. item.ModifyTime = time.Now()
  653. _, err = models.AddCygxIndustryFllow(item)
  654. if err != nil {
  655. br.Msg = "操作失败"
  656. br.ErrMsg = "操作失败,Err:" + err.Error()
  657. return
  658. }
  659. resp.Status = 1
  660. br.Msg = "关注成功"
  661. } else {
  662. item.Type = 2
  663. err = models.RemoveCygxIndustryFllow(uid, industrialManagementId)
  664. if err != nil {
  665. br.Msg = "操作失败"
  666. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  667. return
  668. }
  669. resp.Status = 2
  670. br.Msg = "已取消关注"
  671. }
  672. //处理是否关注全部赛道字段
  673. go services.IndustryFllowWithTrack(industrialManagementId, count, uid)
  674. go services.IndustryFllowUserLabelLogAdd(industrialManagementId, count, uid) //处理用户标签
  675. go services.AddCygxIndustryFllowLog(item) //添加操作日志记录
  676. br.Ret = 200
  677. br.Success = true
  678. br.Data = resp
  679. }
  680. // @Title 行业关注/取消关注
  681. // @Description 行业关注/取消关注 接口
  682. // @Param request body models.CygxCategoryFllowRep true "type json string"
  683. // @Success 200
  684. // @router /category/fllow [post]
  685. func (this *ReportController) CategoryFllow() {
  686. br := new(models.BaseResponse).Init()
  687. defer func() {
  688. this.Data["json"] = br
  689. this.ServeJSON()
  690. }()
  691. user := this.User
  692. if user == nil {
  693. br.Msg = "请重新登录"
  694. br.Ret = 408
  695. return
  696. }
  697. uid := user.UserId
  698. var req models.CygxCategoryFllowRep
  699. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  700. if err != nil {
  701. br.Msg = "参数解析异常!"
  702. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  703. return
  704. }
  705. categoryId := req.CategoryId
  706. var condition string
  707. //countCategory, err := models.GetCategoryCount(categoryId)
  708. //if err != nil {
  709. // br.Msg = "获取数据失败!"
  710. // br.ErrMsg = "获取数据失败,Err:" + err.Error()
  711. // return
  712. //}
  713. //if countCategory == 0 {
  714. // br.Msg = "产业不存在!"
  715. // br.ErrMsg = "产业ID不存在:" + strconv.Itoa(categoryId)
  716. // return
  717. //}
  718. listMap, err := models.GetCygxXzsChooseCategoryMapList()
  719. if err != nil {
  720. br.Msg = "操作失败!"
  721. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  722. return
  723. }
  724. mapReport := make(map[int]int)
  725. for _, v := range listMap {
  726. mapReport[v.Id] = v.CategoryId
  727. }
  728. if mapReport[categoryId] == 0 {
  729. br.Msg = "操作失败!"
  730. br.ErrMsg = "分类ID不存在,ID:" + strconv.Itoa(categoryId)
  731. return
  732. }
  733. count, err := models.GetCountCategoryFllow(mapReport[categoryId], user.Mobile, condition)
  734. if err != nil {
  735. br.Msg = "获取数据失败!"
  736. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  737. return
  738. }
  739. resp := new(models.CygxIndustryFllowResp)
  740. if count == 0 {
  741. item := new(models.CygxXzsChooseCategory)
  742. item.CategoryId = mapReport[categoryId]
  743. item.IdCygx = categoryId
  744. item.UserId = uid
  745. item.Email = user.Email
  746. item.Mobile = user.Mobile
  747. item.RealName = user.RealName
  748. item.CompanyId = user.CompanyId
  749. item.CompanyName = user.CompanyName
  750. item.CreateTime = time.Now()
  751. item.ModifyTime = time.Now()
  752. _, err = models.AddCygxCategoryFllow(item)
  753. if err != nil {
  754. br.Msg = "操作失败"
  755. br.ErrMsg = "操作失败,Err:" + err.Error()
  756. return
  757. }
  758. resp.Status = 1
  759. br.Msg = "关注成功"
  760. } else {
  761. err = models.RemoveCygxCategoryFllow(user.Mobile, mapReport[categoryId])
  762. if err != nil {
  763. br.Msg = "操作失败"
  764. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  765. return
  766. }
  767. resp.Status = 2
  768. br.Msg = "已取消关注"
  769. }
  770. go services.CategoryFllowUserLabelLogAdd(categoryId, count, uid) //处理用户标签
  771. br.Ret = 200
  772. br.Success = true
  773. br.Data = resp
  774. }
  775. // @Title 报告搜索
  776. // @Description 报告搜索接口
  777. // @Param PageSize query int true "每页数据条数"
  778. // @Param CurrentIndex query int true "当前页页码,从1开始"
  779. // @Param KeyWord query string true "搜索关键词"
  780. // @Param ArticleType query int true "文章类型,1弘则报告、2研选 "
  781. // @Param IsAll query bool true "是否为综合 "
  782. // @Success 200 {object} models.ReoprtSearchResp
  783. // @router /searchReport [get]
  784. func (this *MobileReportController) SearchReport() {
  785. br := new(models.BaseResponse).Init()
  786. defer func() {
  787. this.Data["json"] = br
  788. this.ServeJSON()
  789. }()
  790. user := this.User
  791. if user == nil {
  792. br.Msg = "请重新登录"
  793. br.Ret = 408
  794. return
  795. }
  796. pageSize, _ := this.GetInt("PageSize")
  797. currentIndex, _ := this.GetInt("CurrentIndex")
  798. articleType, _ := this.GetInt("ArticleType", 1)
  799. keyWord := this.GetString("KeyWord")
  800. isAll, _ := this.GetBool("IsAll")
  801. var condition string
  802. var conditionYxSpecial string
  803. var pars []interface{}
  804. //var conditionSql string
  805. var total int
  806. var startSize int
  807. if pageSize <= 0 {
  808. pageSize = utils.PageSize20
  809. }
  810. if isAll {
  811. pageSize = utils.PageSize5
  812. }
  813. if currentIndex <= 0 {
  814. currentIndex = 1
  815. }
  816. startSize = paging.StartIndex(currentIndex, pageSize)
  817. resp := new(models.ReoprtSearchResp)
  818. //匹配报告标题、
  819. articleTypeIds, err := services.GetYanXuanArticleTypeIds()
  820. if err != nil {
  821. br.Msg = "获取信息失败"
  822. br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
  823. return
  824. }
  825. if articleTypeIds == "" {
  826. br.Msg = "获取信息失败"
  827. br.ErrMsg = "研选分类ID不能为空"
  828. return
  829. }
  830. //处理对应的文章类型标签按钮
  831. nameMap, styleMap, err := services.GetArticleTypeMap()
  832. if err != nil {
  833. br.Msg = "获取信息失败"
  834. br.ErrMsg = "GetArticleTypeMap Err:" + err.Error()
  835. return
  836. }
  837. if isAll {
  838. total = utils.PageSize5
  839. conditionHz := ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 AND a.article_type_id NOT IN (` + articleTypeIds + `) `
  840. conditionYx := ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 AND a.article_type_id IN (` + articleTypeIds + `) `
  841. listHz, err := models.GetArticleResearchListHz(conditionHz, pars, startSize, pageSize, user.UserId)
  842. if err != nil {
  843. br.Msg = "获取信息失败"
  844. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  845. return
  846. }
  847. listYx, err := models.GetArticleResearchList(conditionYx, pars, startSize, pageSize, user.UserId, true)
  848. if err != nil {
  849. br.Msg = "获取信息失败"
  850. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  851. return
  852. }
  853. listHz, err = services.HandleArticleCategoryImg(listHz, user)
  854. if err != nil {
  855. br.Msg = "获取信息失败"
  856. br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
  857. return
  858. }
  859. listYx, err = services.HandleArticleCategoryImg(listYx, user)
  860. if err != nil {
  861. br.Msg = "获取信息失败"
  862. br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
  863. return
  864. }
  865. for _, v := range listHz {
  866. item := models.ArticleResearchResp{
  867. ArticleId: v.ArticleId,
  868. ArticleTypeId: v.ArticleTypeId,
  869. Title: v.Title,
  870. PublishDate: v.PublishDate,
  871. DepartmentId: v.DepartmentId,
  872. NickName: v.NickName,
  873. IsCollect: v.IsCollect,
  874. Pv: v.Pv,
  875. CollectNum: v.CollectNum,
  876. Abstract: v.Abstract,
  877. Annotation: v.Annotation,
  878. ImgUrlPc: v.ImgUrlPc,
  879. ArticleTypeName: nameMap[v.ArticleTypeId],
  880. ButtonStyle: styleMap[v.ArticleTypeId],
  881. List: v.List,
  882. }
  883. resp.ListHz = append(resp.ListHz, &item)
  884. }
  885. for _, v := range listYx {
  886. item := models.ArticleResearchResp{
  887. ArticleId: v.ArticleId,
  888. ArticleTypeId: v.ArticleTypeId,
  889. Title: v.Title,
  890. PublishDate: v.PublishDate,
  891. DepartmentId: v.DepartmentId,
  892. NickName: v.NickName,
  893. IsCollect: v.IsCollect,
  894. Pv: v.Pv,
  895. CollectNum: v.CollectNum,
  896. Abstract: v.Abstract,
  897. Annotation: v.Annotation,
  898. ImgUrlPc: v.ImgUrlPc,
  899. ArticleTypeName: nameMap[v.ArticleTypeId],
  900. ButtonStyle: styleMap[v.ArticleTypeId],
  901. List: v.List,
  902. }
  903. resp.ListYx = append(resp.ListYx, &item)
  904. }
  905. } else {
  906. if keyWord != "" {
  907. if articleType == 1 {
  908. condition = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 AND a.article_type_id NOT IN (` + articleTypeIds + `) `
  909. total, err = models.GetReoprtSearchCountHz(condition)
  910. } else {
  911. condition = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 AND a.article_type_id IN (` + articleTypeIds + `) `
  912. total, err = models.GetReoprtSearchCountYx(condition)
  913. }
  914. conditionYxSpecial = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.content LIKE '%` + keyWord + `%') `
  915. }
  916. if err != nil {
  917. br.Msg = "获取信息失败"
  918. br.Msg = "获取总数失败,Err:" + err.Error()
  919. return
  920. }
  921. var list []*models.ArticleListResp
  922. //list := new([]models.ArticleResearchResp)
  923. if articleType == 1 {
  924. list, err = models.GetArticleResearchListHz(condition, pars, startSize, pageSize, user.UserId)
  925. } else {
  926. total, list, err = models.GetArticleResearchAndYxSpecialList(condition, conditionYxSpecial, pars, startSize, pageSize, user.UserId, true)
  927. }
  928. if err != nil {
  929. br.Msg = "获取信息失败"
  930. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  931. return
  932. }
  933. //return
  934. list, err = services.HandleArticleCategoryImg(list, user)
  935. if err != nil {
  936. br.Msg = "获取信息失败"
  937. br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
  938. return
  939. }
  940. for _, v := range list {
  941. item := models.ArticleResearchResp{
  942. ArticleId: v.ArticleId,
  943. ArticleTypeId: v.ArticleTypeId,
  944. Title: v.Title,
  945. PublishDate: v.PublishDate,
  946. DepartmentId: v.DepartmentId,
  947. NickName: v.NickName,
  948. IsCollect: v.IsCollect,
  949. Pv: v.Pv,
  950. CollectNum: v.CollectNum,
  951. Abstract: v.Abstract,
  952. Annotation: v.Annotation,
  953. ImgUrlPc: v.ImgUrlPc,
  954. ArticleTypeName: nameMap[v.ArticleTypeId],
  955. ButtonStyle: styleMap[v.ArticleTypeId],
  956. List: v.List,
  957. }
  958. if v.IsSpecial == 1 {
  959. //去除图片标签
  960. item.Annotation = utils.ArticleRemoveImgUrl(item.Annotation)
  961. item.IsSpecial = true
  962. item.ImgUrlPc = utils.CYGX_YANXUAN_SPECIAL_IMG_PC
  963. if v.CompanyTags != "" {
  964. item.CompanyTags = strings.Split(v.CompanyTags, ",")
  965. } else {
  966. item.CompanyTags = []string{}
  967. }
  968. if v.IndustryTags != "" {
  969. item.IndustryTags = strings.Split(v.IndustryTags, ",")
  970. } else {
  971. item.IndustryTags = []string{}
  972. }
  973. item.ArticleTypeName = utils.CYGX_YANXUAN_SPECIAL
  974. if v.SpecialType == 1 {
  975. item.Title = "【笔记】" + item.Title
  976. } else if v.SpecialType == 2 {
  977. item.Title = "【观点】" + item.Title
  978. }
  979. if v.MyCollectNum > 0 {
  980. item.IsCollect = true
  981. }
  982. }
  983. if articleType == 1 {
  984. resp.ListHz = append(resp.ListHz, &item)
  985. } else {
  986. resp.ListYx = append(resp.ListYx, &item)
  987. }
  988. }
  989. }
  990. if keyWord != "" {
  991. //go services.AddUserSearchLog(user, keyWord, 5)
  992. }
  993. if len(resp.ListHz) == 0 {
  994. resp.ListHz = make([]*models.ArticleResearchResp, 0)
  995. }
  996. if len(resp.ListYx) == 0 {
  997. resp.ListYx = make([]*models.ArticleResearchResp, 0)
  998. }
  999. page := paging.GetPaging(currentIndex, pageSize, total)
  1000. resp.Paging = page
  1001. br.Ret = 200
  1002. br.Success = true
  1003. br.Msg = "获取成功"
  1004. br.Data = resp
  1005. }
  1006. // @Title 资源包搜索
  1007. // @Description 资源包搜索接口
  1008. // @Param KeyWord query string true "搜索关键词"
  1009. // @Success 200 {object} models.SearchResourceResp
  1010. // @router /searchResource [get]
  1011. func (this *MobileReportController) SearchResource() {
  1012. br := new(models.BaseResponse).Init()
  1013. defer func() {
  1014. this.Data["json"] = br
  1015. this.ServeJSON()
  1016. }()
  1017. user := this.User
  1018. if user == nil {
  1019. br.Msg = "请重新登录"
  1020. br.Ret = 408
  1021. return
  1022. }
  1023. uid := user.UserId
  1024. fllowList, err := models.GetUserFllowIndustrialList(uid)
  1025. if err != nil {
  1026. br.Msg = "获取失败"
  1027. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  1028. return
  1029. }
  1030. fllowMap := make(map[int]int)
  1031. if len(fllowList) > 0 {
  1032. for _, v := range fllowList {
  1033. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  1034. }
  1035. }
  1036. keyWord := this.GetString("KeyWord")
  1037. var condition string
  1038. articleTypeIds, err := services.GetYanXuanArticleTypeIds()
  1039. if err != nil {
  1040. br.Msg = "获取信息失败"
  1041. br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
  1042. return
  1043. }
  1044. if articleTypeIds == "" {
  1045. br.Msg = "获取信息失败"
  1046. br.ErrMsg = "研选分类ID不能为空"
  1047. return
  1048. }
  1049. condition = ` AND a.publish_status = 1 AND a.article_type_id NOT IN (` + articleTypeIds + `) AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%' ) `
  1050. listHz, err := models.GetSearchResourceList(condition)
  1051. if err != nil {
  1052. br.Msg = "获取信息失败"
  1053. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1054. return
  1055. }
  1056. condition = ` AND a.publish_status = 1 AND a.article_type_id IN (` + articleTypeIds + `) AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%' ) `
  1057. listYx, err := models.GetSearchResourceList(condition)
  1058. if err != nil {
  1059. br.Msg = "获取信息失败"
  1060. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1061. return
  1062. }
  1063. if len(listYx) > 0 {
  1064. listYx, err = services.HandleIndustryList(listYx, user, "Yx")
  1065. if err != nil {
  1066. br.Msg = "获取信息失败"
  1067. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1068. return
  1069. }
  1070. }
  1071. if len(listHz) > 0 {
  1072. listHz, err = services.HandleIndustryList(listHz, user, "Hz")
  1073. if err != nil {
  1074. br.Msg = "获取信息失败"
  1075. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1076. return
  1077. }
  1078. }
  1079. if keyWord != "" {
  1080. //go services.AddUserSearchLog(user, keyWord, 4)
  1081. }
  1082. resp := new(models.SearchResourceResp)
  1083. if len(listHz) == 0 {
  1084. listHz = make([]*models.IndustrialManagement, 0)
  1085. }
  1086. if len(listYx) == 0 {
  1087. listYx = make([]*models.IndustrialManagement, 0)
  1088. }
  1089. resp.ListHz = listHz
  1090. resp.ListYx = listYx
  1091. br.Ret = 200
  1092. br.Success = true
  1093. br.Msg = "获取成功"
  1094. br.Data = resp
  1095. }
  1096. // @Title 报告搜索、资源包搜索接口
  1097. // @Description 报告搜索、资源包搜索接口接口
  1098. // @Param KeyWord query string true "搜索关键词"
  1099. // @Param PageSize query int true "每页数据条数"
  1100. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1101. // @Param SearchType query int true "1:综合,2:全部"
  1102. // @Success 200 {object} models.SearchReportAndResourceResp
  1103. // @router /searchReportAndResource [get]
  1104. func (this *MobileReportController) SearchReportAndResource() {
  1105. br := new(models.BaseResponse).Init()
  1106. defer func() {
  1107. this.Data["json"] = br
  1108. this.ServeJSON()
  1109. }()
  1110. user := this.User
  1111. if user == nil {
  1112. br.Msg = "请重新登录"
  1113. br.Ret = 408
  1114. return
  1115. }
  1116. //uid := user.UserId
  1117. keyWord := this.GetString("KeyWord")
  1118. pageSize, _ := this.GetInt("PageSize")
  1119. currentIndex, _ := this.GetInt("CurrentIndex")
  1120. searchType, _ := this.GetInt("SearchType")
  1121. var total int
  1122. var startSize int
  1123. if pageSize <= 0 {
  1124. pageSize = utils.PageSize20
  1125. }
  1126. if currentIndex <= 0 {
  1127. currentIndex = 1
  1128. }
  1129. startSize = paging.StartIndex(currentIndex, pageSize)
  1130. page := paging.GetPaging(currentIndex, pageSize, total)
  1131. var condition string
  1132. var conditionSql string
  1133. //匹配报告标题、
  1134. condition = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
  1135. conditionSql = ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + condition + ` OR ( article_type = 'lyjh' ` + condition + ` ) `
  1136. total, err := models.GetReoprtSearchCount(conditionSql)
  1137. if err != nil {
  1138. br.Msg = "获取信息失败"
  1139. br.Msg = "获取总数失败,Err:" + err.Error()
  1140. return
  1141. }
  1142. if searchType == 1 {
  1143. pageSize = utils.PageSize5
  1144. }
  1145. ListHzReport, err := services.GetReoprtSearchListHz(conditionSql, user.UserId, startSize, pageSize)
  1146. if err != nil {
  1147. br.Msg = "获取失败"
  1148. br.ErrMsg = "获取失败,GetReoprtSearchListHz Err:" + err.Error()
  1149. return
  1150. }
  1151. if len(ListHzReport) == 0 {
  1152. ListHzReport = make([]*models.ArticleCollectionResp, 0)
  1153. }
  1154. var conditionOr string
  1155. conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  1156. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  1157. listHzResource, err := services.GetSearchResourceListHz(condition, user)
  1158. if err != nil {
  1159. br.Msg = "获取信息失败"
  1160. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1161. return
  1162. }
  1163. resp := new(models.SearchReportAndResourceResp)
  1164. if len(listHzResource) == 0 {
  1165. listHzResource = make([]*models.IndustrialManagement, 0)
  1166. }
  1167. if keyWord != "" {
  1168. //go services.AddUserSearchLog(user, keyWord, 5)
  1169. }
  1170. page = paging.GetPaging(currentIndex, pageSize, total)
  1171. resp.Paging = page
  1172. resp.ListHzResource = listHzResource
  1173. resp.ListHzReport = ListHzReport
  1174. br.Ret = 200
  1175. br.Success = true
  1176. br.Msg = "获取成功"
  1177. br.Data = resp
  1178. }
  1179. // @Title 公司速览
  1180. // @Description 公司速览接口
  1181. // @Param ChartPermissionId query int false "分类ID"
  1182. // @Success 200 {object} models.ArticleDataLogoListResp
  1183. // @router /companyList [get]
  1184. func (this *ReportCommonController) CompanyList() {
  1185. br := new(models.BaseResponse).Init()
  1186. defer func() {
  1187. this.Data["json"] = br
  1188. this.ServeJSON()
  1189. }()
  1190. var condition string
  1191. var pars []interface{}
  1192. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  1193. if chartPermissionId > 1 {
  1194. categoryId, err := models.GetCategoryId(chartPermissionId)
  1195. if err != nil && err.Error() != utils.ErrNoRow() {
  1196. br.Msg = "获取信息失败"
  1197. br.ErrMsg = "获取分类权限信息失败,Err:" + err.Error()
  1198. return
  1199. }
  1200. if categoryId != "" {
  1201. condition += ` AND a.category_id IN (` + categoryId + `)`
  1202. }
  1203. }
  1204. condition += ` AND a.type_name = '综述报告' ORDER BY a.modify_time_by_cl DESC `
  1205. list, err := models.CygxArticleDataList(condition, pars)
  1206. if err != nil {
  1207. br.Msg = "获取失败"
  1208. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  1209. return
  1210. }
  1211. listLogo := make([]*models.ArticleDataLogoResp, 0)
  1212. for i := range list {
  1213. v := list[i]
  1214. comapnyList := services.HandleArticleStock(v.Stock)
  1215. if len(comapnyList) > 1 {
  1216. for kC, vC := range comapnyList {
  1217. sliceCovers := strings.Split(v.Cover, "{|}")
  1218. cover := v.Cover
  1219. if len(sliceCovers) == len(comapnyList) {
  1220. cover = sliceCovers[kC]
  1221. }
  1222. listLogo = append(listLogo, &models.ArticleDataLogoResp{
  1223. ArticleId: v.ArticleId,
  1224. Cover: cover,
  1225. ComapnyList: services.HandleArticleStock(vC.ComapnyName),
  1226. })
  1227. }
  1228. } else {
  1229. listLogo = append(listLogo, &models.ArticleDataLogoResp{
  1230. ArticleId: v.ArticleId,
  1231. Cover: v.Cover,
  1232. ComapnyList: services.HandleArticleStock(v.Stock),
  1233. })
  1234. }
  1235. }
  1236. resp := new(models.ArticleDataLogoListResp)
  1237. resp.List = listLogo
  1238. br.Ret = 200
  1239. br.Success = true
  1240. br.Msg = "获取成功"
  1241. br.Data = resp
  1242. }
  1243. // @Title 时间线
  1244. // @Description 时间线接口
  1245. // @Param PageSize query int true "每页数据条数"
  1246. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1247. // @Param IndustrialManagementId query int false "产业ID"
  1248. // @Success 200 {object} models.TacticsListResp
  1249. // @router /timeline [get]
  1250. func (this *MobileReportController) Timeline() {
  1251. br := new(models.BaseResponse).Init()
  1252. defer func() {
  1253. this.Data["json"] = br
  1254. this.ServeJSON()
  1255. }()
  1256. user := this.User
  1257. if user == nil {
  1258. br.Msg = "请重新登录"
  1259. br.Ret = 408
  1260. return
  1261. }
  1262. pageSize, _ := this.GetInt("PageSize")
  1263. currentIndex, _ := this.GetInt("CurrentIndex")
  1264. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  1265. var startSize int
  1266. if pageSize <= 0 {
  1267. pageSize = utils.PageSize20
  1268. }
  1269. if currentIndex <= 0 {
  1270. currentIndex = 1
  1271. }
  1272. startSize = paging.StartIndex(currentIndex, pageSize)
  1273. var total int
  1274. resp := new(models.TacticsListTimeResp)
  1275. page := paging.GetPaging(currentIndex, pageSize, total)
  1276. list := make([]*models.TimeLineReportItem, 0)
  1277. var err error
  1278. list, total, err = models.GetTimeLineReportIndustrialListTime(user.UserId, industrialManagementId, startSize, pageSize)
  1279. if err != nil {
  1280. br.Msg = "获取信息失败"
  1281. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  1282. return
  1283. }
  1284. //处理晨会精华关联的标的,以及要跳转的文章ID
  1285. var meetingreviewchaptIds []int
  1286. var articleIds []int
  1287. mapchaptIdAndArticleId := make(map[int]int) // 晨会精华ID与跳转文章ID的映射关系
  1288. mapchaptIdListSubject := make(map[int][]*models.CygxIndustrialSubject) // 晨会精华ID与标的列表的映射关系
  1289. mapArticleIdListSubject := make(map[int][]*models.CygxIndustrialSubject) // 报告ID与标的列表的映射关系
  1290. for _, v := range list {
  1291. if v.Resource == 3 {
  1292. meetingreviewchaptIds = append(meetingreviewchaptIds, v.Id)
  1293. }
  1294. if v.Resource == 1 {
  1295. articleIds = append(articleIds, v.ArticleId)
  1296. }
  1297. }
  1298. if len(meetingreviewchaptIds) > 0 {
  1299. listMeet, err := services.GetCygxMorningMeetingReviewChapterListByIds(meetingreviewchaptIds)
  1300. if err != nil {
  1301. br.Msg = "获取失败"
  1302. br.ErrMsg = "GetCygxMorningMeetingReviewChapterListByIds,Err:" + err.Error()
  1303. }
  1304. for _, v := range listMeet {
  1305. mapchaptIdAndArticleId[v.Id] = v.LinkArticleId
  1306. mapchaptIdListSubject[v.Id] = v.ListSubject
  1307. }
  1308. }
  1309. if len(articleIds) > 0 {
  1310. mapArticleIdListSubject = services.GetArticleGroupSubjectMapByIndustrialManagementId(articleIds, industrialManagementId)
  1311. }
  1312. //查询用户今天是否看过时间线
  1313. //count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
  1314. //if err != nil {
  1315. // br.Msg = "查询浏览记录数量失败"
  1316. // br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
  1317. // return
  1318. //}
  1319. //var recordItem *models.CygxPageHistoryRecord
  1320. //if count > 1 {
  1321. // recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
  1322. // if err != nil {
  1323. // br.Msg = "查询浏览记录失败"
  1324. // br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
  1325. // return
  1326. // }
  1327. //}
  1328. for k, v := range list {
  1329. if v.SubCategoryName != "时间线" && v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  1330. list[k].IsRed = true
  1331. }
  1332. //timeLineRed := false
  1333. //if count < 2 && v.SubCategoryName == "时间线" {
  1334. // timeLineRed = true
  1335. //} else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(v.PublishDate)) {
  1336. // timeLineRed = true
  1337. //}
  1338. //if v.SubCategoryName == "时间线" && timeLineRed {
  1339. list[k].IsRed = true
  1340. //}
  1341. if v.VideoUrl != "" {
  1342. list[k].IsHaveVideo = true
  1343. }
  1344. v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
  1345. if v.Resource == 3 {
  1346. v.LinkArticleId = mapchaptIdAndArticleId[v.Id]
  1347. v.ListSubject = mapchaptIdListSubject[v.Id]
  1348. }
  1349. if v.Resource == 1 {
  1350. v.ListSubject = mapArticleIdListSubject[v.Id]
  1351. }
  1352. }
  1353. //添加我的日程访问记录
  1354. item := new(models.CygxPageHistoryRecord)
  1355. item.UserId = user.UserId
  1356. item.CreateTime = time.Now()
  1357. item.CompanyId = user.CompanyId
  1358. item.CompanyName = user.CompanyName
  1359. item.Router = utils.TIME_LINE_ROUTE + strconv.Itoa(industrialManagementId)
  1360. go models.AddCygxPageHistoryRecord(item)
  1361. if len(list) == 0 {
  1362. list = make([]*models.TimeLineReportItem, 0)
  1363. }
  1364. go services.AddCygxTimelineLog(user, industrialManagementId)
  1365. page = paging.GetPaging(currentIndex, pageSize, total)
  1366. resp.List = list
  1367. resp.Paging = page
  1368. br.Ret = 200
  1369. br.Success = true
  1370. br.Msg = "获取成功"
  1371. br.Data = resp
  1372. }
  1373. // @Title 文章留言接口
  1374. // @Description 文章留言接口
  1375. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  1376. // @Success 200 {object} models.TacticsListResp
  1377. // @router /commentAdd [post]
  1378. func (this *ReportController) CommentAdd() {
  1379. br := new(models.BaseResponse).Init()
  1380. defer func() {
  1381. this.Data["json"] = br
  1382. this.ServeJSON()
  1383. }()
  1384. user := this.User
  1385. if user == nil {
  1386. br.Msg = "请重新登录"
  1387. br.Ret = 408
  1388. return
  1389. }
  1390. var req models.AddCygxArticleCommentReq
  1391. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1392. if err != nil {
  1393. br.Msg = "参数解析异常!"
  1394. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1395. return
  1396. }
  1397. if req.ArticleId <= 0 {
  1398. br.Msg = "文章不存在"
  1399. br.ErrMsg = "文章不存在,文章ID错误"
  1400. return
  1401. }
  1402. if req.Content == "" {
  1403. br.Msg = "建议内容不可为空"
  1404. return
  1405. }
  1406. content := req.Content
  1407. if content == "" {
  1408. br.Msg = "留言内容不能为空!"
  1409. return
  1410. }
  1411. //itemToken, err := services.WxGetToken()
  1412. //if err != nil {
  1413. // br.Msg = "GetWxAccessToken Err:" + err.Error()
  1414. // return
  1415. //}
  1416. //if itemToken.AccessToken == "" {
  1417. // br.Msg = "accessToken is empty"
  1418. // return
  1419. //}
  1420. //commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  1421. //if err != nil {
  1422. // br.Msg = "内容校验失败!"
  1423. // br.ErrMsg = "内容校验失败,Err:" + err.Error()
  1424. // return
  1425. //}
  1426. //if commerr.ErrCode != 0 {
  1427. // br.Msg = "内容违规,请重新提交!"
  1428. // br.ErrMsg = "内容违规,Err:" + commerr.ErrMSG
  1429. // return
  1430. //}
  1431. articleId := req.ArticleId
  1432. articleInfo, errInfo := models.GetArticleDetailById(articleId)
  1433. if articleInfo == nil {
  1434. br.Msg = "操作失败"
  1435. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  1436. return
  1437. }
  1438. if errInfo != nil {
  1439. br.Msg = "操作失败"
  1440. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1441. return
  1442. }
  1443. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  1444. if err != nil {
  1445. br.Msg = "提交失败!"
  1446. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1447. return
  1448. }
  1449. if companyDetail == nil {
  1450. br.Msg = "提交失败!"
  1451. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  1452. return
  1453. }
  1454. item := models.CygxArticleComment{
  1455. UserId: user.UserId,
  1456. ArticleId: req.ArticleId,
  1457. CreateTime: time.Now(),
  1458. Mobile: user.Mobile,
  1459. Email: user.Email,
  1460. CompanyId: user.CompanyId,
  1461. CompanyName: companyDetail.CompanyName,
  1462. Content: content,
  1463. Title: articleInfo.Title,
  1464. }
  1465. msgId, err := models.AddArticleComment(&item)
  1466. if err != nil {
  1467. br.Msg = "提交失败"
  1468. br.ErrMsg = "提交留言失败,Err:" + err.Error()
  1469. return
  1470. }
  1471. go services.SendCommentWxTemplateMsg(req, user, articleInfo, int(msgId))
  1472. go services.SendCommentWxTemplateMsgByYxCategory(req, user, articleInfo, int(msgId)) // 发送用户留言提醒(研选公众号类目模版消息)
  1473. br.Ret = 200
  1474. br.Success = true
  1475. br.Msg = "提交成功"
  1476. }
  1477. // @Title 报告精选、本周研究汇总、上周纪要汇总列表
  1478. // @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
  1479. // @Param PageSize query int true "每页数据条数"
  1480. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1481. // @Param ReportType string query true "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
  1482. // @Success 200 {object} models.CygxReportSelectionListPublicRep
  1483. // @router /reportList/byType [get]
  1484. func (this *ReportController) ReportListByType() {
  1485. br := new(models.BaseResponse).Init()
  1486. defer func() {
  1487. this.Data["json"] = br
  1488. this.ServeJSON()
  1489. }()
  1490. user := this.User
  1491. if user == nil {
  1492. br.Msg = "请重新登录"
  1493. br.Ret = 408
  1494. return
  1495. }
  1496. uid := user.UserId
  1497. pageSize, _ := this.GetInt("PageSize")
  1498. currentIndex, _ := this.GetInt("CurrentIndex")
  1499. reportType := this.GetString("ReportType")
  1500. var condition string
  1501. var startSize int
  1502. if pageSize <= 0 {
  1503. pageSize = utils.PageSize20
  1504. }
  1505. if currentIndex <= 0 {
  1506. currentIndex = 1
  1507. }
  1508. startSize = paging.StartIndex(currentIndex, pageSize)
  1509. var pars []interface{}
  1510. var total int
  1511. resp := new(models.CygxReportSelectionListPublicRep)
  1512. page := paging.GetPaging(currentIndex, pageSize, total)
  1513. var tbdb string
  1514. var readSql string
  1515. var reportTypeStr string
  1516. if reportType == "1" {
  1517. tbdb = "cygx_report_selection"
  1518. reportTypeStr = "bgjx"
  1519. } else if reportType == "2" {
  1520. tbdb = "cygx_research_summary"
  1521. reportTypeStr = "bzyjhz"
  1522. } else if reportType == "3" {
  1523. tbdb = "cygx_minutes_summary"
  1524. reportTypeStr = "szjyhz"
  1525. } else {
  1526. br.Msg = "请选择报告类型"
  1527. return
  1528. }
  1529. condition = ` AND publish_status = 1 `
  1530. if user.CompanyId != utils.HZ_COMPANY_ID {
  1531. condition += ` AND visible_range = 1 `
  1532. }
  1533. total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
  1534. if err != nil {
  1535. br.Msg = "获取信息失败"
  1536. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1537. return
  1538. }
  1539. //研究汇总--报告精选 只显示最新一期,往期都隐藏
  1540. if reportType == "1" {
  1541. startSize = 0
  1542. pageSize = 1
  1543. total = 1
  1544. }
  1545. 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`
  1546. page = paging.GetPaging(currentIndex, pageSize, total)
  1547. list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
  1548. if err != nil {
  1549. br.Msg = "获取失败"
  1550. br.ErrMsg = "获取失败,Err:" + err.Error()
  1551. return
  1552. }
  1553. for k, v := range list {
  1554. if reportType == "1" {
  1555. list[k].Abstract = v.UpdateDescription
  1556. }
  1557. list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
  1558. if v.ReadNum == 0 {
  1559. list[k].IsRed = true
  1560. }
  1561. }
  1562. resp.List = list
  1563. resp.Paging = page
  1564. br.Ret = 200
  1565. br.Success = true
  1566. br.Msg = "获取成功"
  1567. br.Data = resp
  1568. }
  1569. // @Title 获取本周研究汇总详情
  1570. // @Description 获取本周研究汇总详情接口
  1571. // @Param ArticleId query int true "报告ID"
  1572. // @Success 200 {object} models.ResearchSummaryLetailResp
  1573. // @router /researchSummary/detail [get]
  1574. func (this *ReportController) ResearchDetail() {
  1575. br := new(models.BaseResponse).Init()
  1576. defer func() {
  1577. this.Data["json"] = br
  1578. this.ServeJSON()
  1579. }()
  1580. user := this.User
  1581. if user == nil {
  1582. br.Msg = "请重新登录"
  1583. br.Ret = 408
  1584. return
  1585. }
  1586. //uid := user.UserId
  1587. articleId, _ := this.GetInt("ArticleId")
  1588. if articleId < 0 {
  1589. br.Msg = "参数错误"
  1590. br.ErrMsg = "参数错误"
  1591. return
  1592. }
  1593. resp := new(models.ResearchSummaryLetailResp)
  1594. //判断用户权限
  1595. hasPermission, err := services.GetUserhasPermission(user)
  1596. if err != nil {
  1597. br.Msg = "获取信息失败"
  1598. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1599. }
  1600. detail, err := models.GetCygxResearchSummaryInfoById(articleId)
  1601. if err != nil {
  1602. br.Msg = "获取信息失败"
  1603. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1604. return
  1605. }
  1606. PermissionNameMap, err := services.GetPermissionNameMap()
  1607. if err != nil {
  1608. br.Msg = "获取失败"
  1609. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1610. return
  1611. }
  1612. PermissionIcoMap, err := services.GetPermissionNameIcoMap()
  1613. if err != nil {
  1614. br.Msg = "获取失败"
  1615. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1616. return
  1617. }
  1618. //未设置全部可见的只能给弘则内部查看
  1619. if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
  1620. resp.IsShow = true
  1621. }
  1622. resp.HasPermission = hasPermission
  1623. if hasPermission != 1 || !resp.IsShow {
  1624. br.Ret = 200
  1625. br.Success = true
  1626. br.Msg = "获取成功"
  1627. br.Data = resp
  1628. return
  1629. }
  1630. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1631. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1632. listFirst, err := models.GetResearchSummarylogListFirst(articleId)
  1633. if err != nil {
  1634. br.Msg = "获取失败"
  1635. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1636. return
  1637. }
  1638. listArticleType, err := models.GetCygxArticleTypeList()
  1639. if err != nil {
  1640. br.Msg = "获取失败"
  1641. br.ErrMsg = "获取文章类型数据失败,Err:" + err.Error()
  1642. return
  1643. }
  1644. for k, v := range listFirst {
  1645. listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
  1646. if err != nil && err.Error() != utils.ErrNoRow() {
  1647. br.Msg = "获取信息失败"
  1648. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1649. return
  1650. }
  1651. for k2, v2 := range listSecond {
  1652. v2.PermissionName = PermissionNameMap[v2.ChartPermissionId]
  1653. v2.IcoLink = PermissionIcoMap[v2.ChartPermissionId]
  1654. listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
  1655. if err != nil && err.Error() != utils.ErrNoRow() {
  1656. br.Msg = "获取信息失败"
  1657. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1658. return
  1659. }
  1660. for _, vType := range listArticleType {
  1661. if v2.ChartPermissionId == vType.YanxPermissionId {
  1662. listSecond[k2].IcoLink = vType.IcoLinkM
  1663. listSecond[k2].PermissionName = vType.YanxPermissionName
  1664. }
  1665. }
  1666. if len(listThird) > 0 {
  1667. for k3, v3 := range listThird {
  1668. if v3.VideoUrl != "" {
  1669. listThird[k3].IsHaveVideo = true
  1670. }
  1671. if v3.ReportLink == "0" {
  1672. listThird[k3].ReportLink = ""
  1673. }
  1674. }
  1675. listSecond[k2].List = listThird
  1676. }
  1677. }
  1678. if len(listSecond) > 0 {
  1679. listFirst[k].List = listSecond
  1680. }
  1681. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1682. if v.Type == "SDBG" {
  1683. listFirst[k].ListName = "深度报告"
  1684. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211027/le8AcRjDz0MhA72bVDiaf3d5ALSe.png"
  1685. } else if v.Type == "BZCHJH" {
  1686. listFirst[k].ListName = "本周晨会精华"
  1687. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
  1688. } else if v.Type == "CYDYJY" {
  1689. listFirst[k].ListName = "产业调研纪要"
  1690. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1691. } else if v.Type == "SSGS" {
  1692. listFirst[k].ListName = "上市公司调研纪要篇"
  1693. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1694. } else if v.Type == "SJDP" {
  1695. listFirst[k].ListName = "市场QA汇总"
  1696. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
  1697. } else if v.Type == "YANX" {
  1698. listFirst[k].ListName = "买方研选"
  1699. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1700. }
  1701. }
  1702. //go services.AddCygxReportHistoryRecord(user, articleId, "bzyjhz")
  1703. go services.ResearchSummaryHistoryUserRmind(user, articleId) // 本周研究汇总用户阅读操作操作行为,模板消息推送
  1704. resp.List = listFirst
  1705. resp.Detail = detail
  1706. br.Ret = 200
  1707. br.Success = true
  1708. br.Msg = "获取成功"
  1709. br.Data = resp
  1710. }
  1711. // @Title 上周纪要汇总内容详情
  1712. // @Description 获取上周纪要汇总内容详情接口
  1713. // @Param ArticleId query int true "报告ID"
  1714. // @Success 200 {object} models.MinutesSummaryLetailResp
  1715. // @router /minutesSummary/detail [get]
  1716. func (this *ReportController) MinutesDetail() {
  1717. br := new(models.BaseResponse).Init()
  1718. defer func() {
  1719. this.Data["json"] = br
  1720. this.ServeJSON()
  1721. }()
  1722. user := this.User
  1723. if user == nil {
  1724. br.Msg = "请重新登录"
  1725. br.Ret = 408
  1726. return
  1727. }
  1728. articleId, _ := this.GetInt("ArticleId")
  1729. if articleId < 0 {
  1730. br.Msg = "参数错误"
  1731. br.ErrMsg = "参数错误"
  1732. return
  1733. }
  1734. resp := new(models.MinutesSummaryLetailRespV4)
  1735. //判断用户权限
  1736. hasPermission, err := services.GetUserhasPermission(user)
  1737. if err != nil {
  1738. br.Msg = "获取信息失败"
  1739. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1740. }
  1741. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1742. if err != nil {
  1743. br.Msg = "获取信息失败"
  1744. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1745. return
  1746. }
  1747. PermissionNameMap, err := services.GetPermissionNameMap()
  1748. if err != nil {
  1749. br.Msg = "获取失败"
  1750. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1751. return
  1752. }
  1753. PermissionIcoMap, err := services.GetPermissionNameIcoMap()
  1754. if err != nil {
  1755. br.Msg = "获取失败"
  1756. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1757. return
  1758. }
  1759. //未设置全部可见的只能给弘则内部查看
  1760. if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
  1761. resp.IsShow = true
  1762. }
  1763. resp.HasPermission = hasPermission
  1764. if hasPermission != 1 || !resp.IsShow {
  1765. br.Ret = 200
  1766. br.Success = true
  1767. br.Msg = "获取成功"
  1768. br.Data = resp
  1769. return
  1770. }
  1771. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1772. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1773. listFirst, err := models.GetMinutesSummarylogListAllV4(articleId)
  1774. if err != nil {
  1775. br.Msg = "获取失败"
  1776. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1777. return
  1778. }
  1779. for k, v := range listFirst {
  1780. listSecond, err := models.GetMinutesSummarylogSonListSecond(articleId, v.Type)
  1781. if err != nil && err.Error() != utils.ErrNoRow() {
  1782. br.Msg = "获取信息失败"
  1783. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1784. return
  1785. }
  1786. for k2, v2 := range listSecond {
  1787. v2.PermissionName = PermissionNameMap[v2.ChartPermissionId]
  1788. v2.IcoLink = PermissionIcoMap[v2.ChartPermissionId]
  1789. listThird, err := models.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
  1790. if err != nil && err.Error() != utils.ErrNoRow() {
  1791. br.Msg = "获取信息失败"
  1792. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1793. return
  1794. }
  1795. if len(listThird) > 0 {
  1796. for k3, v3 := range listThird {
  1797. if v3.VideoUrl != "" {
  1798. listThird[k3].IsHaveVideo = true
  1799. }
  1800. if v3.ReportLink == "0" {
  1801. listThird[k3].ReportLink = ""
  1802. }
  1803. }
  1804. listSecond[k2].List = listThird
  1805. }
  1806. }
  1807. if len(listSecond) > 0 {
  1808. listFirst[k].List = listSecond
  1809. }
  1810. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1811. if v.Type == "CYDYJY" {
  1812. listFirst[k].ListName = "产业调研纪要"
  1813. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1814. } else if v.Type == "SSGS" {
  1815. listFirst[k].ListName = "上市公司调研纪要篇"
  1816. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1817. } else if v.Type == "YANX" {
  1818. listFirst[k].ListName = "买方研选纪要"
  1819. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1820. }
  1821. }
  1822. //go services.AddCygxReportHistoryRecord(user, articleId, "szjyhz")
  1823. go services.MinutesSummaryHistoryUserRmind(user, articleId) // 上周纪要汇总用户阅读,给销售发消息提醒
  1824. resp.List = listFirst
  1825. resp.Detail = detail
  1826. br.Ret = 200
  1827. br.Success = true
  1828. br.Msg = "获取成功"
  1829. br.Data = resp
  1830. }
  1831. // @Title 记录用户浏览音频回放接口
  1832. // @Description 记录用户浏览音频回放接口
  1833. // @Param request body models.ArticleIdReq true "type json string"
  1834. // @Success Ret=200 操作成功
  1835. // @router /voiceHistory/add [post]
  1836. func (this *ReportController) ResearchSummaryVoiceHistoryAdd() {
  1837. br := new(models.BaseResponse).Init()
  1838. defer func() {
  1839. this.Data["json"] = br
  1840. this.ServeJSON()
  1841. }()
  1842. user := this.User
  1843. if user == nil {
  1844. br.Msg = "请登录"
  1845. br.ErrMsg = "请登录,用户信息为空"
  1846. br.Ret = 408
  1847. return
  1848. }
  1849. uid := user.UserId
  1850. var req models.ArticleIdReq
  1851. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1852. if err != nil {
  1853. br.Msg = "参数解析异常!"
  1854. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1855. return
  1856. }
  1857. articleId := req.ArticleId
  1858. playSeconds := req.PlaySeconds
  1859. reportType := req.ReportType
  1860. //本周研究汇总
  1861. if reportType == 2 {
  1862. articleInfo, errInfo := models.GetCygxResearchSummaryInfoById(articleId)
  1863. if articleInfo == nil {
  1864. br.Msg = "操作失败"
  1865. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  1866. return
  1867. }
  1868. if errInfo != nil {
  1869. br.Msg = "操作失败"
  1870. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1871. return
  1872. }
  1873. var sellerName string
  1874. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1875. if err != nil {
  1876. br.Msg = "报名失败!"
  1877. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1878. return
  1879. }
  1880. item := models.CygxResearchSummaryVoiceHistory{
  1881. ArticleId: articleId,
  1882. UserId: uid,
  1883. CreateTime: time.Now(),
  1884. Mobile: user.Mobile,
  1885. Email: user.Email,
  1886. CompanyId: user.CompanyId,
  1887. CompanyName: user.CompanyName,
  1888. RealName: user.RealName,
  1889. SellerName: sellerName,
  1890. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  1891. ModifyTime: time.Now(),
  1892. RegisterPlatform: utils.REGISTER_PLATFORM,
  1893. }
  1894. if playSeconds != 0 {
  1895. lastItem, err := models.GetLastCygxResearchSummaryVoiceHistory(articleId, user.UserId)
  1896. if err != nil {
  1897. br.Msg = "操作失败"
  1898. br.ErrMsg = "操作失败,GetLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  1899. return
  1900. }
  1901. err = models.UpdateLastCygxResearchSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  1902. if err != nil {
  1903. br.Msg = "更新失败"
  1904. br.ErrMsg = "更新失败,UpdateLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  1905. return
  1906. }
  1907. } else {
  1908. err = models.AddCygxResearchSummaryVoiceHistory(&item)
  1909. if err != nil {
  1910. br.Msg = "操作失败"
  1911. br.ErrMsg = "操作失败,Err:" + err.Error()
  1912. return
  1913. }
  1914. err = models.UpdateResearchSummaryVoiceCounts(articleId)
  1915. if err != nil {
  1916. br.Msg = "更新失败"
  1917. br.ErrMsg = "更新失败,Err:" + err.Error()
  1918. return
  1919. }
  1920. }
  1921. } else if reportType == 3 {
  1922. articleInfo, errInfo := models.GetCygxMinutesSummaryInfoById(articleId)
  1923. if articleInfo == nil {
  1924. br.Msg = "操作失败"
  1925. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  1926. return
  1927. }
  1928. if errInfo != nil {
  1929. br.Msg = "操作失败"
  1930. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1931. return
  1932. }
  1933. var sellerName string
  1934. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1935. if err != nil {
  1936. br.Msg = "报名失败!"
  1937. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1938. return
  1939. }
  1940. item := models.CygxMinutesSummaryVoiceHistory{
  1941. ArticleId: articleId,
  1942. UserId: uid,
  1943. CreateTime: time.Now(),
  1944. Mobile: user.Mobile,
  1945. Email: user.Email,
  1946. CompanyId: user.CompanyId,
  1947. CompanyName: user.CompanyName,
  1948. RealName: user.RealName,
  1949. SellerName: sellerName,
  1950. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  1951. ModifyTime: time.Now(),
  1952. RegisterPlatform: utils.REGISTER_PLATFORM,
  1953. }
  1954. if playSeconds != 0 {
  1955. lastItem, err := models.GetLastCygxMinutesSummaryVoiceHistory(articleId, user.UserId)
  1956. if err != nil {
  1957. br.Msg = "操作失败"
  1958. br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
  1959. return
  1960. }
  1961. err = models.UpdateLastCygxMinutesSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  1962. if err != nil {
  1963. br.Msg = "更新失败"
  1964. br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
  1965. return
  1966. }
  1967. } else {
  1968. err = models.AddCygxMinutesSummaryVoiceHistory(&item)
  1969. if err != nil {
  1970. br.Msg = "操作失败"
  1971. br.ErrMsg = "操作失败,Err:" + err.Error()
  1972. return
  1973. }
  1974. err = models.UpdateMinutesSummaryVoiceCounts(articleId)
  1975. if err != nil {
  1976. br.Msg = "更新失败"
  1977. br.ErrMsg = "更新失败,Err:" + err.Error()
  1978. return
  1979. }
  1980. }
  1981. }
  1982. br.Ret = 200
  1983. br.Success = true
  1984. br.Msg = "操作成功"
  1985. return
  1986. }
  1987. // @Title 根据行业分类获取行业文章列表
  1988. // @Description 根据行业分类获取行业文章列表接口
  1989. // @Param PageSize query int true "每页数据条数"
  1990. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1991. // @Param CategoryId query int true "分类ID"
  1992. // @Param IndustrialManagementId query int false "产业ID"
  1993. // @Success 200 {object} models.TacticsListResp
  1994. // @router /tactics/list [get]
  1995. func (this *MobileReportController) TacticsList() {
  1996. br := new(models.BaseResponse).Init()
  1997. defer func() {
  1998. this.Data["json"] = br
  1999. this.ServeJSON()
  2000. }()
  2001. user := this.User
  2002. if user == nil {
  2003. br.Msg = "请重新登录"
  2004. br.Ret = 408
  2005. return
  2006. }
  2007. //uid := user.UserId
  2008. pageSize, _ := this.GetInt("PageSize")
  2009. currentIndex, _ := this.GetInt("CurrentIndex")
  2010. categoryId, _ := this.GetInt("CategoryId")
  2011. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  2012. var startSize int
  2013. if pageSize <= 0 {
  2014. pageSize = utils.PageSize20
  2015. }
  2016. if currentIndex <= 0 {
  2017. currentIndex = 1
  2018. }
  2019. startSize = paging.StartIndex(currentIndex, pageSize)
  2020. //var condition string
  2021. //var pars []interface{}
  2022. var total int
  2023. var err error
  2024. resp := new(models.TacticsListResp)
  2025. page := paging.GetPaging(currentIndex, pageSize, total)
  2026. list := make([]*models.ArticleListResp, 0)
  2027. if categoryId == utils.TIME_CATEGORYID {
  2028. list, total, err = models.GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize)
  2029. if err != nil {
  2030. br.Msg = "获取信息失败"
  2031. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  2032. return
  2033. }
  2034. } else {
  2035. if categoryId == utils.ACTEGORY_ID_AI_QY {
  2036. listArticle := make([]*models.HomeArticle, 0)
  2037. listArticle, total, err = services.GetAiQianYanArtilceList(startSize, pageSize)
  2038. if err != nil {
  2039. br.Msg = "获取信息失败"
  2040. br.Msg = "GetAiQianYanArtilceList,Err:" + err.Error()
  2041. return
  2042. }
  2043. for _, v := range listArticle {
  2044. list = append(list, &models.ArticleListResp{
  2045. ArticleId: v.ArticleId,
  2046. Title: v.Title,
  2047. CategoryId: v.CategoryId,
  2048. Annotation: v.Annotation,
  2049. Abstract: v.Abstract,
  2050. Body: v.Body,
  2051. PublishDate: v.PublishDate,
  2052. Resource: 1,
  2053. })
  2054. }
  2055. } else {
  2056. list, total, err = models.GetReportAndproductIndustrylListimg(categoryId, user.UserId, startSize, pageSize)
  2057. if err != nil {
  2058. br.Msg = "获取信息失败"
  2059. br.Msg = "GetHomeList,Err:" + err.Error()
  2060. return
  2061. }
  2062. }
  2063. articleIdMap, err := services.GetUserArticleHistoryRecord(user)
  2064. if err != nil {
  2065. br.Msg = "获取信息失败"
  2066. br.Msg = "获取帖子数据失败,Err:" + err.Error()
  2067. return
  2068. }
  2069. for k, v := range list {
  2070. //list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  2071. if !articleIdMap[v.ArticleId] && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  2072. list[k].IsRed = true
  2073. }
  2074. }
  2075. if categoryId > 0 {
  2076. detail, errCategory := models.GetCygxReportMappingCygxByCategoryId(categoryId)
  2077. if errCategory != nil {
  2078. br.Msg = "获取信息失败"
  2079. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  2080. return
  2081. }
  2082. resp.MatchTypeName = detail.MatchTypeName
  2083. }
  2084. //resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  2085. }
  2086. listPublic, err := services.HandleArticleCategoryImg(list, user)
  2087. if err != nil {
  2088. br.Msg = "获取失败"
  2089. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  2090. return
  2091. }
  2092. var articleIds []int
  2093. var productInteriorIs []int
  2094. for _, v := range listPublic {
  2095. if v.Resource == 1 {
  2096. articleIds = append(articleIds, v.ArticleId)
  2097. }
  2098. if v.Resource == 2 {
  2099. productInteriorIs = append(productInteriorIs, v.ArticleId)
  2100. }
  2101. }
  2102. articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
  2103. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
  2104. articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
  2105. productInteriorMapPv := services.GetCygxProductInteriorHistoryListPvMap(productInteriorIs) //产品内测Pv
  2106. listResp := make([]*models.HomeArticle, 0)
  2107. for _, v := range listPublic {
  2108. item := new(models.HomeArticle)
  2109. item.ArticleId = v.ArticleId
  2110. item.ReportId = v.ReportId
  2111. item.Title = v.Title
  2112. item.Annotation = v.Annotation
  2113. item.Abstract = v.Abstract
  2114. item.ImgUrlPc = v.ImgUrlPc
  2115. item.PublishDate = v.PublishDate
  2116. item.Resource = v.Resource
  2117. if v.Resource == 1 {
  2118. item.Pv = articleMapPv[v.ArticleId]
  2119. item.IsCollect = articleCollectMap[v.ArticleId]
  2120. item.CollectNum = articleCollectNumMap[v.ArticleId]
  2121. }
  2122. if v.Resource == 2 {
  2123. item.Pv = productInteriorMapPv[v.ArticleId]
  2124. }
  2125. if v.ReportId > 0 {
  2126. item.Resource = 3
  2127. }
  2128. listResp = append(listResp, item)
  2129. }
  2130. if len(listResp) == 0 {
  2131. listResp = make([]*models.HomeArticle, 0)
  2132. }
  2133. page = paging.GetPaging(currentIndex, pageSize, total)
  2134. resp.List = listResp
  2135. resp.Paging = page
  2136. br.Ret = 200
  2137. br.Success = true
  2138. br.Msg = "获取成功"
  2139. br.Data = resp
  2140. }