report.go 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hongze_web_mfyx/models"
  6. "hongze/hongze_web_mfyx/services"
  7. "hongze/hongze_web_mfyx/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. mapchaptIdAndArticleId := make(map[int]int) // 晨会精华ID与跳转文章ID的映射关系
  1287. mapchaptIdListSubject := make(map[int][]*models.CygxIndustrialSubject) // 晨会精华ID与标的列表的映射关系
  1288. for _, v := range list {
  1289. if v.Resource == 3 {
  1290. meetingreviewchaptIds = append(meetingreviewchaptIds, v.Id)
  1291. }
  1292. }
  1293. if len(meetingreviewchaptIds) > 0 {
  1294. listMeet, err := services.GetCygxMorningMeetingReviewChapterListByIds(meetingreviewchaptIds)
  1295. if err != nil {
  1296. br.Msg = "获取失败"
  1297. br.ErrMsg = "GetCygxMorningMeetingReviewChapterListByIds,Err:" + err.Error()
  1298. }
  1299. for _, v := range listMeet {
  1300. mapchaptIdAndArticleId[v.Id] = v.LinkArticleId
  1301. mapchaptIdListSubject[v.Id] = v.ListSubject
  1302. }
  1303. }
  1304. //查询用户今天是否看过时间线
  1305. //count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
  1306. //if err != nil {
  1307. // br.Msg = "查询浏览记录数量失败"
  1308. // br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
  1309. // return
  1310. //}
  1311. //var recordItem *models.CygxPageHistoryRecord
  1312. //if count > 1 {
  1313. // recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
  1314. // if err != nil {
  1315. // br.Msg = "查询浏览记录失败"
  1316. // br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
  1317. // return
  1318. // }
  1319. //}
  1320. for k, v := range list {
  1321. if v.SubCategoryName != "时间线" && v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  1322. list[k].IsRed = true
  1323. }
  1324. //timeLineRed := false
  1325. //if count < 2 && v.SubCategoryName == "时间线" {
  1326. // timeLineRed = true
  1327. //} else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(v.PublishDate)) {
  1328. // timeLineRed = true
  1329. //}
  1330. //if v.SubCategoryName == "时间线" && timeLineRed {
  1331. list[k].IsRed = true
  1332. //}
  1333. if v.VideoUrl != "" {
  1334. list[k].IsHaveVideo = true
  1335. }
  1336. v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
  1337. if v.Resource == 3 {
  1338. v.LinkArticleId = mapchaptIdAndArticleId[v.Id]
  1339. v.ListSubject = mapchaptIdListSubject[v.Id]
  1340. }
  1341. }
  1342. //添加我的日程访问记录
  1343. item := new(models.CygxPageHistoryRecord)
  1344. item.UserId = user.UserId
  1345. item.CreateTime = time.Now()
  1346. item.CompanyId = user.CompanyId
  1347. item.CompanyName = user.CompanyName
  1348. item.Router = utils.TIME_LINE_ROUTE + strconv.Itoa(industrialManagementId)
  1349. go models.AddCygxPageHistoryRecord(item)
  1350. if len(list) == 0 {
  1351. list = make([]*models.TimeLineReportItem, 0)
  1352. }
  1353. page = paging.GetPaging(currentIndex, pageSize, total)
  1354. resp.List = list
  1355. resp.Paging = page
  1356. br.Ret = 200
  1357. br.Success = true
  1358. br.Msg = "获取成功"
  1359. br.Data = resp
  1360. }
  1361. // @Title 文章留言接口
  1362. // @Description 文章留言接口
  1363. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  1364. // @Success 200 {object} models.TacticsListResp
  1365. // @router /commentAdd [post]
  1366. func (this *ReportController) CommentAdd() {
  1367. br := new(models.BaseResponse).Init()
  1368. defer func() {
  1369. this.Data["json"] = br
  1370. this.ServeJSON()
  1371. }()
  1372. user := this.User
  1373. if user == nil {
  1374. br.Msg = "请重新登录"
  1375. br.Ret = 408
  1376. return
  1377. }
  1378. var req models.AddCygxArticleCommentReq
  1379. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1380. if err != nil {
  1381. br.Msg = "参数解析异常!"
  1382. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1383. return
  1384. }
  1385. if req.ArticleId <= 0 {
  1386. br.Msg = "文章不存在"
  1387. br.ErrMsg = "文章不存在,文章ID错误"
  1388. return
  1389. }
  1390. if req.Content == "" {
  1391. br.Msg = "建议内容不可为空"
  1392. return
  1393. }
  1394. content := req.Content
  1395. if content == "" {
  1396. br.Msg = "留言内容不能为空!"
  1397. return
  1398. }
  1399. //itemToken, err := services.WxGetToken()
  1400. //if err != nil {
  1401. // br.Msg = "GetWxAccessToken Err:" + err.Error()
  1402. // return
  1403. //}
  1404. //if itemToken.AccessToken == "" {
  1405. // br.Msg = "accessToken is empty"
  1406. // return
  1407. //}
  1408. //commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  1409. //if err != nil {
  1410. // br.Msg = "内容校验失败!"
  1411. // br.ErrMsg = "内容校验失败,Err:" + err.Error()
  1412. // return
  1413. //}
  1414. //if commerr.ErrCode != 0 {
  1415. // br.Msg = "内容违规,请重新提交!"
  1416. // br.ErrMsg = "内容违规,Err:" + commerr.ErrMSG
  1417. // return
  1418. //}
  1419. articleId := req.ArticleId
  1420. articleInfo, errInfo := models.GetArticleDetailById(articleId)
  1421. if articleInfo == nil {
  1422. br.Msg = "操作失败"
  1423. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  1424. return
  1425. }
  1426. if errInfo != nil {
  1427. br.Msg = "操作失败"
  1428. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1429. return
  1430. }
  1431. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  1432. if err != nil {
  1433. br.Msg = "提交失败!"
  1434. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1435. return
  1436. }
  1437. if companyDetail == nil {
  1438. br.Msg = "提交失败!"
  1439. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  1440. return
  1441. }
  1442. item := models.CygxArticleComment{
  1443. UserId: user.UserId,
  1444. RealName: user.RealName,
  1445. ArticleId: req.ArticleId,
  1446. CreateTime: time.Now(),
  1447. Mobile: user.Mobile,
  1448. Email: user.Email,
  1449. CompanyId: user.CompanyId,
  1450. CompanyName: companyDetail.CompanyName,
  1451. Content: content,
  1452. Title: articleInfo.Title,
  1453. }
  1454. msgId, err := models.AddArticleComment(&item)
  1455. if err != nil {
  1456. br.Msg = "提交失败"
  1457. br.ErrMsg = "提交留言失败,Err:" + err.Error()
  1458. return
  1459. }
  1460. go services.SendCommentWxTemplateMsg(req, user, articleInfo, int(msgId))
  1461. go services.SendCommentWxCategoryTemplateMsg(req, user, articleInfo, int(msgId))
  1462. br.Ret = 200
  1463. br.Success = true
  1464. br.Msg = "提交成功"
  1465. }
  1466. // @Title 报告精选、本周研究汇总、上周纪要汇总列表
  1467. // @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
  1468. // @Param PageSize query int true "每页数据条数"
  1469. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1470. // @Param ReportType string query true "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
  1471. // @Success 200 {object} models.CygxReportSelectionListPublicRep
  1472. // @router /reportList/byType [get]
  1473. func (this *ReportController) ReportListByType() {
  1474. br := new(models.BaseResponse).Init()
  1475. defer func() {
  1476. this.Data["json"] = br
  1477. this.ServeJSON()
  1478. }()
  1479. user := this.User
  1480. if user == nil {
  1481. br.Msg = "请重新登录"
  1482. br.Ret = 408
  1483. return
  1484. }
  1485. uid := user.UserId
  1486. pageSize, _ := this.GetInt("PageSize")
  1487. currentIndex, _ := this.GetInt("CurrentIndex")
  1488. reportType := this.GetString("ReportType")
  1489. var condition string
  1490. var startSize int
  1491. if pageSize <= 0 {
  1492. pageSize = utils.PageSize20
  1493. }
  1494. if currentIndex <= 0 {
  1495. currentIndex = 1
  1496. }
  1497. startSize = paging.StartIndex(currentIndex, pageSize)
  1498. var pars []interface{}
  1499. var total int
  1500. resp := new(models.CygxReportSelectionListPublicRep)
  1501. page := paging.GetPaging(currentIndex, pageSize, total)
  1502. var tbdb string
  1503. var readSql string
  1504. var reportTypeStr string
  1505. if reportType == "1" {
  1506. tbdb = "cygx_report_selection"
  1507. reportTypeStr = "bgjx"
  1508. } else if reportType == "2" {
  1509. tbdb = "cygx_research_summary"
  1510. reportTypeStr = "bzyjhz"
  1511. } else if reportType == "3" {
  1512. tbdb = "cygx_minutes_summary"
  1513. reportTypeStr = "szjyhz"
  1514. } else {
  1515. br.Msg = "请选择报告类型"
  1516. return
  1517. }
  1518. condition = ` AND publish_status = 1 `
  1519. if user.CompanyId != utils.HZ_COMPANY_ID {
  1520. condition += ` AND visible_range = 1 `
  1521. }
  1522. total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
  1523. if err != nil {
  1524. br.Msg = "获取信息失败"
  1525. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1526. return
  1527. }
  1528. //研究汇总--报告精选 只显示最新一期,往期都隐藏
  1529. if reportType == "1" {
  1530. startSize = 0
  1531. pageSize = 1
  1532. total = 1
  1533. }
  1534. 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`
  1535. page = paging.GetPaging(currentIndex, pageSize, total)
  1536. list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
  1537. if err != nil {
  1538. br.Msg = "获取失败"
  1539. br.ErrMsg = "获取失败,Err:" + err.Error()
  1540. return
  1541. }
  1542. for k, v := range list {
  1543. if reportType == "1" {
  1544. list[k].Abstract = v.UpdateDescription
  1545. }
  1546. list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
  1547. if v.ReadNum == 0 {
  1548. list[k].IsRed = true
  1549. }
  1550. }
  1551. resp.List = list
  1552. resp.Paging = page
  1553. br.Ret = 200
  1554. br.Success = true
  1555. br.Msg = "获取成功"
  1556. br.Data = resp
  1557. }
  1558. // @Title 获取本周研究汇总详情
  1559. // @Description 获取本周研究汇总详情接口
  1560. // @Param ArticleId query int true "报告ID"
  1561. // @Success 200 {object} models.ResearchSummaryLetailResp
  1562. // @router /researchSummary/detail [get]
  1563. func (this *ReportController) ResearchDetail() {
  1564. br := new(models.BaseResponse).Init()
  1565. defer func() {
  1566. this.Data["json"] = br
  1567. this.ServeJSON()
  1568. }()
  1569. user := this.User
  1570. if user == nil {
  1571. br.Msg = "请重新登录"
  1572. br.Ret = 408
  1573. return
  1574. }
  1575. //uid := user.UserId
  1576. articleId, _ := this.GetInt("ArticleId")
  1577. if articleId < 0 {
  1578. br.Msg = "参数错误"
  1579. br.ErrMsg = "参数错误"
  1580. return
  1581. }
  1582. resp := new(models.ResearchSummaryLetailResp)
  1583. //判断用户权限
  1584. hasPermission, err := services.GetUserhasPermission(user)
  1585. if err != nil {
  1586. br.Msg = "获取信息失败"
  1587. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1588. }
  1589. detail, err := models.GetCygxResearchSummaryInfoById(articleId)
  1590. if err != nil {
  1591. br.Msg = "获取信息失败"
  1592. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1593. return
  1594. }
  1595. PermissionNameMap, err := services.GetPermissionNameMap()
  1596. if err != nil {
  1597. br.Msg = "获取失败"
  1598. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1599. return
  1600. }
  1601. PermissionIcoMap, err := services.GetPermissionNameIcoMap()
  1602. if err != nil {
  1603. br.Msg = "获取失败"
  1604. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1605. return
  1606. }
  1607. //未设置全部可见的只能给弘则内部查看
  1608. if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
  1609. resp.IsShow = true
  1610. }
  1611. resp.HasPermission = hasPermission
  1612. if hasPermission != 1 || !resp.IsShow {
  1613. br.Ret = 200
  1614. br.Success = true
  1615. br.Msg = "获取成功"
  1616. br.Data = resp
  1617. return
  1618. }
  1619. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1620. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1621. listFirst, err := models.GetResearchSummarylogListFirst(articleId)
  1622. if err != nil {
  1623. br.Msg = "获取失败"
  1624. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1625. return
  1626. }
  1627. listArticleType, err := models.GetCygxArticleTypeList()
  1628. if err != nil {
  1629. br.Msg = "获取失败"
  1630. br.ErrMsg = "获取文章类型数据失败,Err:" + err.Error()
  1631. return
  1632. }
  1633. for k, v := range listFirst {
  1634. listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
  1635. if err != nil && err.Error() != utils.ErrNoRow() {
  1636. br.Msg = "获取信息失败"
  1637. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1638. return
  1639. }
  1640. for k2, v2 := range listSecond {
  1641. v2.PermissionName = PermissionNameMap[v2.ChartPermissionId]
  1642. v2.IcoLink = PermissionIcoMap[v2.ChartPermissionId]
  1643. listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
  1644. if err != nil && err.Error() != utils.ErrNoRow() {
  1645. br.Msg = "获取信息失败"
  1646. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1647. return
  1648. }
  1649. for _, vType := range listArticleType {
  1650. if v2.ChartPermissionId == vType.YanxPermissionId {
  1651. listSecond[k2].IcoLink = vType.IcoLinkM
  1652. listSecond[k2].PermissionName = vType.YanxPermissionName
  1653. }
  1654. }
  1655. if len(listThird) > 0 {
  1656. for k3, v3 := range listThird {
  1657. if v3.VideoUrl != "" {
  1658. listThird[k3].IsHaveVideo = true
  1659. }
  1660. if v3.ReportLink == "0" {
  1661. listThird[k3].ReportLink = ""
  1662. }
  1663. }
  1664. listSecond[k2].List = listThird
  1665. }
  1666. }
  1667. if len(listSecond) > 0 {
  1668. listFirst[k].List = listSecond
  1669. }
  1670. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1671. if v.Type == "SDBG" {
  1672. listFirst[k].ListName = "深度报告"
  1673. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211027/le8AcRjDz0MhA72bVDiaf3d5ALSe.png"
  1674. } else if v.Type == "BZCHJH" {
  1675. listFirst[k].ListName = "本周晨会精华"
  1676. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
  1677. } else if v.Type == "CYDYJY" {
  1678. listFirst[k].ListName = "产业调研纪要"
  1679. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1680. } else if v.Type == "SSGS" {
  1681. listFirst[k].ListName = "上市公司调研纪要篇"
  1682. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1683. } else if v.Type == "SJDP" {
  1684. listFirst[k].ListName = "市场QA汇总"
  1685. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
  1686. } else if v.Type == "YANX" {
  1687. listFirst[k].ListName = "买方研选"
  1688. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1689. }
  1690. }
  1691. //go services.AddCygxReportHistoryRecord(user, articleId, "bzyjhz")
  1692. go services.ResearchSummaryHistoryUserRmind(user, articleId) // 本周研究汇总用户阅读操作操作行为,模板消息推送
  1693. go services.SendWxCategoryMsgInteractive(user, "阅读报告", articleId, detail.Title) // 本周研究汇总用户阅读操作操作行为,模板消息推送
  1694. resp.List = listFirst
  1695. resp.Detail = detail
  1696. br.Ret = 200
  1697. br.Success = true
  1698. br.Msg = "获取成功"
  1699. br.Data = resp
  1700. }
  1701. // @Title 上周纪要汇总内容详情
  1702. // @Description 获取上周纪要汇总内容详情接口
  1703. // @Param ArticleId query int true "报告ID"
  1704. // @Success 200 {object} models.MinutesSummaryLetailResp
  1705. // @router /minutesSummary/detail [get]
  1706. func (this *ReportController) MinutesDetail() {
  1707. br := new(models.BaseResponse).Init()
  1708. defer func() {
  1709. this.Data["json"] = br
  1710. this.ServeJSON()
  1711. }()
  1712. user := this.User
  1713. if user == nil {
  1714. br.Msg = "请重新登录"
  1715. br.Ret = 408
  1716. return
  1717. }
  1718. articleId, _ := this.GetInt("ArticleId")
  1719. if articleId < 0 {
  1720. br.Msg = "参数错误"
  1721. br.ErrMsg = "参数错误"
  1722. return
  1723. }
  1724. resp := new(models.MinutesSummaryLetailRespV4)
  1725. //判断用户权限
  1726. hasPermission, err := services.GetUserhasPermission(user)
  1727. if err != nil {
  1728. br.Msg = "获取信息失败"
  1729. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1730. }
  1731. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1732. if err != nil {
  1733. br.Msg = "获取信息失败"
  1734. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1735. return
  1736. }
  1737. PermissionNameMap, err := services.GetPermissionNameMap()
  1738. if err != nil {
  1739. br.Msg = "获取失败"
  1740. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1741. return
  1742. }
  1743. PermissionIcoMap, err := services.GetPermissionNameIcoMap()
  1744. if err != nil {
  1745. br.Msg = "获取失败"
  1746. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1747. return
  1748. }
  1749. //未设置全部可见的只能给弘则内部查看
  1750. if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
  1751. resp.IsShow = true
  1752. }
  1753. resp.HasPermission = hasPermission
  1754. if hasPermission != 1 || !resp.IsShow {
  1755. br.Ret = 200
  1756. br.Success = true
  1757. br.Msg = "获取成功"
  1758. br.Data = resp
  1759. return
  1760. }
  1761. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1762. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1763. listFirst, err := models.GetMinutesSummarylogListAllV4(articleId)
  1764. if err != nil {
  1765. br.Msg = "获取失败"
  1766. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1767. return
  1768. }
  1769. for k, v := range listFirst {
  1770. listSecond, err := models.GetMinutesSummarylogSonListSecond(articleId, v.Type)
  1771. if err != nil && err.Error() != utils.ErrNoRow() {
  1772. br.Msg = "获取信息失败"
  1773. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1774. return
  1775. }
  1776. for k2, v2 := range listSecond {
  1777. v2.PermissionName = PermissionNameMap[v2.ChartPermissionId]
  1778. v2.IcoLink = PermissionIcoMap[v2.ChartPermissionId]
  1779. listThird, err := models.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
  1780. if err != nil && err.Error() != utils.ErrNoRow() {
  1781. br.Msg = "获取信息失败"
  1782. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1783. return
  1784. }
  1785. if len(listThird) > 0 {
  1786. for k3, v3 := range listThird {
  1787. if v3.VideoUrl != "" {
  1788. listThird[k3].IsHaveVideo = true
  1789. }
  1790. if v3.ReportLink == "0" {
  1791. listThird[k3].ReportLink = ""
  1792. }
  1793. }
  1794. listSecond[k2].List = listThird
  1795. }
  1796. }
  1797. if len(listSecond) > 0 {
  1798. listFirst[k].List = listSecond
  1799. }
  1800. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1801. if v.Type == "CYDYJY" {
  1802. listFirst[k].ListName = "产业调研纪要"
  1803. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1804. } else if v.Type == "SSGS" {
  1805. listFirst[k].ListName = "上市公司调研纪要篇"
  1806. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1807. } else if v.Type == "YANX" {
  1808. listFirst[k].ListName = "买方研选纪要"
  1809. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1810. }
  1811. }
  1812. //go services.AddCygxReportHistoryRecord(user, articleId, "szjyhz")
  1813. go services.MinutesSummaryHistoryUserRmind(user, articleId) // 上周纪要汇总用户阅读,给销售发消息提醒
  1814. go services.SendWxCategoryMsgInteractive(user, "阅读报告", articleId, detail.Title) //上周纪要汇总用户阅读,模板消息推送
  1815. resp.List = listFirst
  1816. resp.Detail = detail
  1817. br.Ret = 200
  1818. br.Success = true
  1819. br.Msg = "获取成功"
  1820. br.Data = resp
  1821. }
  1822. // @Title 记录用户浏览音频回放接口
  1823. // @Description 记录用户浏览音频回放接口
  1824. // @Param request body models.ArticleIdReq true "type json string"
  1825. // @Success Ret=200 操作成功
  1826. // @router /voiceHistory/add [post]
  1827. func (this *ReportController) ResearchSummaryVoiceHistoryAdd() {
  1828. br := new(models.BaseResponse).Init()
  1829. defer func() {
  1830. this.Data["json"] = br
  1831. this.ServeJSON()
  1832. }()
  1833. user := this.User
  1834. if user == nil {
  1835. br.Msg = "请登录"
  1836. br.ErrMsg = "请登录,用户信息为空"
  1837. br.Ret = 408
  1838. return
  1839. }
  1840. uid := user.UserId
  1841. var req models.ArticleIdReq
  1842. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1843. if err != nil {
  1844. br.Msg = "参数解析异常!"
  1845. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1846. return
  1847. }
  1848. articleId := req.ArticleId
  1849. playSeconds := req.PlaySeconds
  1850. reportType := req.ReportType
  1851. //本周研究汇总
  1852. if reportType == 2 {
  1853. articleInfo, errInfo := models.GetCygxResearchSummaryInfoById(articleId)
  1854. if articleInfo == nil {
  1855. br.Msg = "操作失败"
  1856. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  1857. return
  1858. }
  1859. if errInfo != nil {
  1860. br.Msg = "操作失败"
  1861. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1862. return
  1863. }
  1864. var sellerName string
  1865. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1866. if err != nil {
  1867. br.Msg = "报名失败!"
  1868. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1869. return
  1870. }
  1871. item := models.CygxResearchSummaryVoiceHistory{
  1872. ArticleId: articleId,
  1873. UserId: uid,
  1874. CreateTime: time.Now(),
  1875. Mobile: user.Mobile,
  1876. Email: user.Email,
  1877. CompanyId: user.CompanyId,
  1878. CompanyName: user.CompanyName,
  1879. RealName: user.RealName,
  1880. SellerName: sellerName,
  1881. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  1882. ModifyTime: time.Now(),
  1883. RegisterPlatform: utils.REGISTER_PLATFORM,
  1884. }
  1885. if playSeconds != 0 {
  1886. lastItem, err := models.GetLastCygxResearchSummaryVoiceHistory(articleId, user.UserId)
  1887. if err != nil {
  1888. br.Msg = "操作失败"
  1889. br.ErrMsg = "操作失败,GetLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  1890. return
  1891. }
  1892. err = models.UpdateLastCygxResearchSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  1893. if err != nil {
  1894. br.Msg = "更新失败"
  1895. br.ErrMsg = "更新失败,UpdateLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  1896. return
  1897. }
  1898. } else {
  1899. err = models.AddCygxResearchSummaryVoiceHistory(&item)
  1900. if err != nil {
  1901. br.Msg = "操作失败"
  1902. br.ErrMsg = "操作失败,Err:" + err.Error()
  1903. return
  1904. }
  1905. err = models.UpdateResearchSummaryVoiceCounts(articleId)
  1906. if err != nil {
  1907. br.Msg = "更新失败"
  1908. br.ErrMsg = "更新失败,Err:" + err.Error()
  1909. return
  1910. }
  1911. }
  1912. } else if reportType == 3 {
  1913. articleInfo, errInfo := models.GetCygxMinutesSummaryInfoById(articleId)
  1914. if articleInfo == nil {
  1915. br.Msg = "操作失败"
  1916. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  1917. return
  1918. }
  1919. if errInfo != nil {
  1920. br.Msg = "操作失败"
  1921. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1922. return
  1923. }
  1924. var sellerName string
  1925. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1926. if err != nil {
  1927. br.Msg = "报名失败!"
  1928. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1929. return
  1930. }
  1931. item := models.CygxMinutesSummaryVoiceHistory{
  1932. ArticleId: articleId,
  1933. UserId: uid,
  1934. CreateTime: time.Now(),
  1935. Mobile: user.Mobile,
  1936. Email: user.Email,
  1937. CompanyId: user.CompanyId,
  1938. CompanyName: user.CompanyName,
  1939. RealName: user.RealName,
  1940. SellerName: sellerName,
  1941. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  1942. ModifyTime: time.Now(),
  1943. RegisterPlatform: utils.REGISTER_PLATFORM,
  1944. }
  1945. if playSeconds != 0 {
  1946. lastItem, err := models.GetLastCygxMinutesSummaryVoiceHistory(articleId, user.UserId)
  1947. if err != nil {
  1948. br.Msg = "操作失败"
  1949. br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
  1950. return
  1951. }
  1952. err = models.UpdateLastCygxMinutesSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  1953. if err != nil {
  1954. br.Msg = "更新失败"
  1955. br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
  1956. return
  1957. }
  1958. } else {
  1959. err = models.AddCygxMinutesSummaryVoiceHistory(&item)
  1960. if err != nil {
  1961. br.Msg = "操作失败"
  1962. br.ErrMsg = "操作失败,Err:" + err.Error()
  1963. return
  1964. }
  1965. err = models.UpdateMinutesSummaryVoiceCounts(articleId)
  1966. if err != nil {
  1967. br.Msg = "更新失败"
  1968. br.ErrMsg = "更新失败,Err:" + err.Error()
  1969. return
  1970. }
  1971. }
  1972. }
  1973. br.Ret = 200
  1974. br.Success = true
  1975. br.Msg = "操作成功"
  1976. return
  1977. }
  1978. // @Title 根据行业分类获取行业文章列表
  1979. // @Description 根据行业分类获取行业文章列表接口
  1980. // @Param PageSize query int true "每页数据条数"
  1981. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1982. // @Param CategoryId query int true "分类ID"
  1983. // @Param IndustrialManagementId query int false "产业ID"
  1984. // @Success 200 {object} models.TacticsListResp
  1985. // @router /tactics/list [get]
  1986. func (this *MobileReportController) TacticsList() {
  1987. br := new(models.BaseResponse).Init()
  1988. defer func() {
  1989. this.Data["json"] = br
  1990. this.ServeJSON()
  1991. }()
  1992. user := this.User
  1993. if user == nil {
  1994. br.Msg = "请重新登录"
  1995. br.Ret = 408
  1996. return
  1997. }
  1998. //uid := user.UserId
  1999. pageSize, _ := this.GetInt("PageSize")
  2000. currentIndex, _ := this.GetInt("CurrentIndex")
  2001. categoryId, _ := this.GetInt("CategoryId")
  2002. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  2003. var startSize int
  2004. if pageSize <= 0 {
  2005. pageSize = utils.PageSize20
  2006. }
  2007. if currentIndex <= 0 {
  2008. currentIndex = 1
  2009. }
  2010. startSize = paging.StartIndex(currentIndex, pageSize)
  2011. //var condition string
  2012. //var pars []interface{}
  2013. var total int
  2014. var err error
  2015. resp := new(models.TacticsListResp)
  2016. page := paging.GetPaging(currentIndex, pageSize, total)
  2017. list := make([]*models.ArticleListResp, 0)
  2018. if categoryId == utils.TIME_CATEGORYID {
  2019. list, total, err = models.GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize)
  2020. if err != nil {
  2021. br.Msg = "获取信息失败"
  2022. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  2023. return
  2024. }
  2025. } else {
  2026. if categoryId == utils.ACTEGORY_ID_AI_QY {
  2027. listArticle := make([]*models.HomeArticle, 0)
  2028. listArticle, total, err = services.GetAiQianYanArtilceList(startSize, pageSize)
  2029. if err != nil {
  2030. br.Msg = "获取信息失败"
  2031. br.Msg = "GetAiQianYanArtilceList,Err:" + err.Error()
  2032. return
  2033. }
  2034. for _, v := range listArticle {
  2035. list = append(list, &models.ArticleListResp{
  2036. ArticleId: v.ArticleId,
  2037. Title: v.Title,
  2038. CategoryId: v.CategoryId,
  2039. Annotation: v.Annotation,
  2040. Abstract: v.Abstract,
  2041. Body: v.Body,
  2042. PublishDate: v.PublishDate,
  2043. Resource: 1,
  2044. })
  2045. }
  2046. } else {
  2047. list, total, err = models.GetReportAndproductIndustrylListimg(categoryId, user.UserId, startSize, pageSize)
  2048. if err != nil {
  2049. br.Msg = "获取信息失败"
  2050. br.Msg = "GetHomeList,Err:" + err.Error()
  2051. return
  2052. }
  2053. }
  2054. articleIdMap, err := services.GetUserArticleHistoryRecord(user)
  2055. if err != nil {
  2056. br.Msg = "获取信息失败"
  2057. br.Msg = "获取帖子数据失败,Err:" + err.Error()
  2058. return
  2059. }
  2060. for k, v := range list {
  2061. //list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  2062. if !articleIdMap[v.ArticleId] && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  2063. list[k].IsRed = true
  2064. }
  2065. }
  2066. if categoryId > 0 {
  2067. detail, errCategory := models.GetCygxReportMappingCygxByCategoryId(categoryId)
  2068. if errCategory != nil {
  2069. br.Msg = "获取信息失败"
  2070. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  2071. return
  2072. }
  2073. resp.MatchTypeName = detail.MatchTypeName
  2074. }
  2075. //resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  2076. }
  2077. listPublic, err := services.HandleArticleCategoryImg(list, user)
  2078. if err != nil {
  2079. br.Msg = "获取失败"
  2080. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  2081. return
  2082. }
  2083. var articleIds []int
  2084. var productInteriorIs []int
  2085. for _, v := range listPublic {
  2086. if v.Resource == 1 {
  2087. articleIds = append(articleIds, v.ArticleId)
  2088. }
  2089. if v.Resource == 2 {
  2090. productInteriorIs = append(productInteriorIs, v.ArticleId)
  2091. }
  2092. }
  2093. articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
  2094. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
  2095. articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
  2096. productInteriorMapPv := services.GetCygxProductInteriorHistoryListPvMap(productInteriorIs) //产品内测Pv
  2097. listResp := make([]*models.HomeArticle, 0)
  2098. for _, v := range listPublic {
  2099. item := new(models.HomeArticle)
  2100. item.ArticleId = v.ArticleId
  2101. item.Title = v.Title
  2102. item.Annotation = v.Annotation
  2103. item.Abstract = v.Abstract
  2104. item.ImgUrlPc = v.ImgUrlPc
  2105. item.PublishDate = v.PublishDate
  2106. item.Resource = v.Resource
  2107. if v.Resource == 1 {
  2108. item.Pv = articleMapPv[v.ArticleId]
  2109. item.IsCollect = articleCollectMap[v.ArticleId]
  2110. item.CollectNum = articleCollectNumMap[v.ArticleId]
  2111. }
  2112. if v.Resource == 2 {
  2113. item.Pv = productInteriorMapPv[v.ArticleId]
  2114. }
  2115. //listResp = append(listResp, &models.HomeArticle{
  2116. // ArticleId: v.ArticleId,
  2117. // Title: v.Title,
  2118. // Annotation: "核心观点:" + v.Annotation,
  2119. // Abstract: v.Abstract,
  2120. // ImgUrlPc: v.ImgUrlPc,
  2121. // PublishDate: v.PublishDate,
  2122. // Resource: v.Resource,
  2123. // Pv: articleMapPv[v.ArticleId],
  2124. // IsCollect: articleCollectMap[v.ArticleId],
  2125. // CollectNum: articleCollectNumMap[v.ArticleId],
  2126. //})
  2127. listResp = append(listResp, item)
  2128. }
  2129. if len(listResp) == 0 {
  2130. listResp = make([]*models.HomeArticle, 0)
  2131. }
  2132. page = paging.GetPaging(currentIndex, pageSize, total)
  2133. resp.List = listResp
  2134. resp.Paging = page
  2135. br.Ret = 200
  2136. br.Success = true
  2137. br.Msg = "获取成功"
  2138. br.Data = resp
  2139. }