report.go 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497
  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. if v.ReportId > 0 {
  884. item.Resource = 3
  885. item.ReportId = v.ReportId
  886. }
  887. resp.ListHz = append(resp.ListHz, &item)
  888. }
  889. for _, v := range listYx {
  890. item := models.ArticleResearchResp{
  891. ArticleId: v.ArticleId,
  892. ArticleTypeId: v.ArticleTypeId,
  893. Title: v.Title,
  894. PublishDate: v.PublishDate,
  895. DepartmentId: v.DepartmentId,
  896. NickName: v.NickName,
  897. IsCollect: v.IsCollect,
  898. Pv: v.Pv,
  899. CollectNum: v.CollectNum,
  900. Abstract: v.Abstract,
  901. Annotation: v.Annotation,
  902. ImgUrlPc: v.ImgUrlPc,
  903. ArticleTypeName: nameMap[v.ArticleTypeId],
  904. ButtonStyle: styleMap[v.ArticleTypeId],
  905. List: v.List,
  906. }
  907. resp.ListYx = append(resp.ListYx, &item)
  908. }
  909. } else {
  910. if keyWord != "" {
  911. if articleType == 1 {
  912. 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 + `) `
  913. total, err = models.GetReoprtSearchCountHz(condition)
  914. } else {
  915. 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 + `) `
  916. total, err = models.GetReoprtSearchCountYx(condition)
  917. }
  918. conditionYxSpecial = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.content LIKE '%` + keyWord + `%') `
  919. }
  920. if err != nil {
  921. br.Msg = "获取信息失败"
  922. br.Msg = "获取总数失败,Err:" + err.Error()
  923. return
  924. }
  925. var list []*models.ArticleListResp
  926. //list := new([]models.ArticleResearchResp)
  927. if articleType == 1 {
  928. list, err = models.GetArticleResearchListHz(condition, pars, startSize, pageSize, user.UserId)
  929. } else {
  930. total, list, err = models.GetArticleResearchAndYxSpecialList(condition, conditionYxSpecial, pars, startSize, pageSize, user.UserId, true)
  931. }
  932. if err != nil {
  933. br.Msg = "获取信息失败"
  934. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  935. return
  936. }
  937. //return
  938. list, err = services.HandleArticleCategoryImg(list, user)
  939. if err != nil {
  940. br.Msg = "获取信息失败"
  941. br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
  942. return
  943. }
  944. for _, v := range list {
  945. item := models.ArticleResearchResp{
  946. ArticleId: v.ArticleId,
  947. ArticleTypeId: v.ArticleTypeId,
  948. Title: v.Title,
  949. PublishDate: v.PublishDate,
  950. DepartmentId: v.DepartmentId,
  951. NickName: v.NickName,
  952. IsCollect: v.IsCollect,
  953. Pv: v.Pv,
  954. CollectNum: v.CollectNum,
  955. Abstract: v.Abstract,
  956. Annotation: v.Annotation,
  957. ImgUrlPc: v.ImgUrlPc,
  958. ArticleTypeName: nameMap[v.ArticleTypeId],
  959. ButtonStyle: styleMap[v.ArticleTypeId],
  960. List: v.List,
  961. }
  962. if v.ReportId > 0 {
  963. item.Resource = 3
  964. item.ReportId = v.ReportId
  965. }
  966. if v.IsSpecial == 1 {
  967. //去除图片标签
  968. item.Annotation = utils.ArticleRemoveImgUrl(item.Annotation)
  969. item.IsSpecial = true
  970. item.ImgUrlPc = utils.CYGX_YANXUAN_SPECIAL_IMG_PC
  971. if v.CompanyTags != "" {
  972. item.CompanyTags = strings.Split(v.CompanyTags, ",")
  973. } else {
  974. item.CompanyTags = []string{}
  975. }
  976. if v.IndustryTags != "" {
  977. item.IndustryTags = strings.Split(v.IndustryTags, ",")
  978. } else {
  979. item.IndustryTags = []string{}
  980. }
  981. item.ArticleTypeName = utils.CYGX_YANXUAN_SPECIAL
  982. if v.SpecialType == 1 {
  983. item.Title = "【笔记】" + item.Title
  984. } else if v.SpecialType == 2 {
  985. item.Title = "【观点】" + item.Title
  986. }
  987. if v.MyCollectNum > 0 {
  988. item.IsCollect = true
  989. }
  990. }
  991. if articleType == 1 {
  992. resp.ListHz = append(resp.ListHz, &item)
  993. } else {
  994. resp.ListYx = append(resp.ListYx, &item)
  995. }
  996. }
  997. }
  998. if keyWord != "" {
  999. //go services.AddUserSearchLog(user, keyWord, 5)
  1000. }
  1001. if len(resp.ListHz) == 0 {
  1002. resp.ListHz = make([]*models.ArticleResearchResp, 0)
  1003. }
  1004. if len(resp.ListYx) == 0 {
  1005. resp.ListYx = make([]*models.ArticleResearchResp, 0)
  1006. }
  1007. page := paging.GetPaging(currentIndex, pageSize, total)
  1008. resp.Paging = page
  1009. br.Ret = 200
  1010. br.Success = true
  1011. br.Msg = "获取成功"
  1012. br.Data = resp
  1013. }
  1014. // @Title 资源包搜索
  1015. // @Description 资源包搜索接口
  1016. // @Param KeyWord query string true "搜索关键词"
  1017. // @Success 200 {object} models.SearchResourceResp
  1018. // @router /searchResource [get]
  1019. func (this *MobileReportController) SearchResource() {
  1020. br := new(models.BaseResponse).Init()
  1021. defer func() {
  1022. this.Data["json"] = br
  1023. this.ServeJSON()
  1024. }()
  1025. user := this.User
  1026. if user == nil {
  1027. br.Msg = "请重新登录"
  1028. br.Ret = 408
  1029. return
  1030. }
  1031. uid := user.UserId
  1032. fllowList, err := models.GetUserFllowIndustrialList(uid)
  1033. if err != nil {
  1034. br.Msg = "获取失败"
  1035. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  1036. return
  1037. }
  1038. fllowMap := make(map[int]int)
  1039. if len(fllowList) > 0 {
  1040. for _, v := range fllowList {
  1041. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  1042. }
  1043. }
  1044. keyWord := this.GetString("KeyWord")
  1045. var condition string
  1046. articleTypeIds, err := services.GetYanXuanArticleTypeIds()
  1047. if err != nil {
  1048. br.Msg = "获取信息失败"
  1049. br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
  1050. return
  1051. }
  1052. if articleTypeIds == "" {
  1053. br.Msg = "获取信息失败"
  1054. br.ErrMsg = "研选分类ID不能为空"
  1055. return
  1056. }
  1057. 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 + `%' ) `
  1058. listHz, err := models.GetSearchResourceList(condition)
  1059. if err != nil {
  1060. br.Msg = "获取信息失败"
  1061. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1062. return
  1063. }
  1064. 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 + `%' ) `
  1065. listYx, err := models.GetSearchResourceList(condition)
  1066. if err != nil {
  1067. br.Msg = "获取信息失败"
  1068. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1069. return
  1070. }
  1071. if len(listYx) > 0 {
  1072. listYx, err = services.HandleIndustryList(listYx, user, "Yx")
  1073. if err != nil {
  1074. br.Msg = "获取信息失败"
  1075. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1076. return
  1077. }
  1078. }
  1079. if len(listHz) > 0 {
  1080. listHz, err = services.HandleIndustryList(listHz, user, "Hz")
  1081. if err != nil {
  1082. br.Msg = "获取信息失败"
  1083. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1084. return
  1085. }
  1086. }
  1087. if keyWord != "" {
  1088. //go services.AddUserSearchLog(user, keyWord, 4)
  1089. }
  1090. resp := new(models.SearchResourceResp)
  1091. if len(listHz) == 0 {
  1092. listHz = make([]*models.IndustrialManagement, 0)
  1093. }
  1094. if len(listYx) == 0 {
  1095. listYx = make([]*models.IndustrialManagement, 0)
  1096. }
  1097. resp.ListHz = listHz
  1098. resp.ListYx = listYx
  1099. br.Ret = 200
  1100. br.Success = true
  1101. br.Msg = "获取成功"
  1102. br.Data = resp
  1103. }
  1104. // @Title 报告搜索、资源包搜索接口
  1105. // @Description 报告搜索、资源包搜索接口接口
  1106. // @Param KeyWord query string true "搜索关键词"
  1107. // @Param PageSize query int true "每页数据条数"
  1108. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1109. // @Param SearchType query int true "1:综合,2:全部"
  1110. // @Success 200 {object} models.SearchReportAndResourceResp
  1111. // @router /searchReportAndResource [get]
  1112. func (this *MobileReportController) SearchReportAndResource() {
  1113. br := new(models.BaseResponse).Init()
  1114. defer func() {
  1115. this.Data["json"] = br
  1116. this.ServeJSON()
  1117. }()
  1118. user := this.User
  1119. if user == nil {
  1120. br.Msg = "请重新登录"
  1121. br.Ret = 408
  1122. return
  1123. }
  1124. //uid := user.UserId
  1125. keyWord := this.GetString("KeyWord")
  1126. pageSize, _ := this.GetInt("PageSize")
  1127. currentIndex, _ := this.GetInt("CurrentIndex")
  1128. searchType, _ := this.GetInt("SearchType")
  1129. var total int
  1130. var startSize int
  1131. if pageSize <= 0 {
  1132. pageSize = utils.PageSize20
  1133. }
  1134. if currentIndex <= 0 {
  1135. currentIndex = 1
  1136. }
  1137. startSize = paging.StartIndex(currentIndex, pageSize)
  1138. page := paging.GetPaging(currentIndex, pageSize, total)
  1139. var condition string
  1140. var conditionSql string
  1141. //匹配报告标题、
  1142. condition = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
  1143. conditionSql = ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + condition + ` OR ( article_type = 'lyjh' ` + condition + ` ) `
  1144. total, err := models.GetReoprtSearchCount(conditionSql)
  1145. if err != nil {
  1146. br.Msg = "获取信息失败"
  1147. br.Msg = "获取总数失败,Err:" + err.Error()
  1148. return
  1149. }
  1150. if searchType == 1 {
  1151. pageSize = utils.PageSize5
  1152. }
  1153. ListHzReport, err := services.GetReoprtSearchListHz(conditionSql, user.UserId, startSize, pageSize)
  1154. if err != nil {
  1155. br.Msg = "获取失败"
  1156. br.ErrMsg = "获取失败,GetReoprtSearchListHz Err:" + err.Error()
  1157. return
  1158. }
  1159. if len(ListHzReport) == 0 {
  1160. ListHzReport = make([]*models.ArticleCollectionResp, 0)
  1161. }
  1162. var conditionOr string
  1163. conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  1164. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  1165. listHzResource, err := services.GetSearchResourceListHz(condition, user)
  1166. if err != nil {
  1167. br.Msg = "获取信息失败"
  1168. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1169. return
  1170. }
  1171. resp := new(models.SearchReportAndResourceResp)
  1172. if len(listHzResource) == 0 {
  1173. listHzResource = make([]*models.IndustrialManagement, 0)
  1174. }
  1175. if keyWord != "" {
  1176. //go services.AddUserSearchLog(user, keyWord, 5)
  1177. }
  1178. page = paging.GetPaging(currentIndex, pageSize, total)
  1179. resp.Paging = page
  1180. resp.ListHzResource = listHzResource
  1181. resp.ListHzReport = ListHzReport
  1182. br.Ret = 200
  1183. br.Success = true
  1184. br.Msg = "获取成功"
  1185. br.Data = resp
  1186. }
  1187. // @Title 公司速览
  1188. // @Description 公司速览接口
  1189. // @Param ChartPermissionId query int false "分类ID"
  1190. // @Success 200 {object} models.ArticleDataLogoListResp
  1191. // @router /companyList [get]
  1192. func (this *ReportCommonController) CompanyList() {
  1193. br := new(models.BaseResponse).Init()
  1194. defer func() {
  1195. this.Data["json"] = br
  1196. this.ServeJSON()
  1197. }()
  1198. var condition string
  1199. var pars []interface{}
  1200. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  1201. if chartPermissionId > 1 {
  1202. categoryId, err := models.GetCategoryId(chartPermissionId)
  1203. if err != nil && err.Error() != utils.ErrNoRow() {
  1204. br.Msg = "获取信息失败"
  1205. br.ErrMsg = "获取分类权限信息失败,Err:" + err.Error()
  1206. return
  1207. }
  1208. if categoryId != "" {
  1209. condition += ` AND a.category_id IN (` + categoryId + `)`
  1210. }
  1211. }
  1212. condition += ` AND a.type_name = '综述报告' ORDER BY a.modify_time_by_cl DESC `
  1213. list, err := models.CygxArticleDataList(condition, pars)
  1214. if err != nil {
  1215. br.Msg = "获取失败"
  1216. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  1217. return
  1218. }
  1219. listLogo := make([]*models.ArticleDataLogoResp, 0)
  1220. for i := range list {
  1221. v := list[i]
  1222. comapnyList := services.HandleArticleStock(v.Stock)
  1223. if len(comapnyList) > 1 {
  1224. for kC, vC := range comapnyList {
  1225. sliceCovers := strings.Split(v.Cover, "{|}")
  1226. cover := v.Cover
  1227. if len(sliceCovers) == len(comapnyList) {
  1228. cover = sliceCovers[kC]
  1229. }
  1230. listLogo = append(listLogo, &models.ArticleDataLogoResp{
  1231. ArticleId: v.ArticleId,
  1232. Cover: cover,
  1233. ComapnyList: services.HandleArticleStock(vC.ComapnyName),
  1234. })
  1235. }
  1236. } else {
  1237. listLogo = append(listLogo, &models.ArticleDataLogoResp{
  1238. ArticleId: v.ArticleId,
  1239. Cover: v.Cover,
  1240. ComapnyList: services.HandleArticleStock(v.Stock),
  1241. })
  1242. }
  1243. }
  1244. resp := new(models.ArticleDataLogoListResp)
  1245. resp.List = listLogo
  1246. br.Ret = 200
  1247. br.Success = true
  1248. br.Msg = "获取成功"
  1249. br.Data = resp
  1250. }
  1251. // @Title 时间线
  1252. // @Description 时间线接口
  1253. // @Param PageSize query int true "每页数据条数"
  1254. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1255. // @Param IndustrialManagementId query int false "产业ID"
  1256. // @Success 200 {object} models.TacticsListResp
  1257. // @router /timeline [get]
  1258. func (this *MobileReportController) Timeline() {
  1259. br := new(models.BaseResponse).Init()
  1260. defer func() {
  1261. this.Data["json"] = br
  1262. this.ServeJSON()
  1263. }()
  1264. user := this.User
  1265. if user == nil {
  1266. br.Msg = "请重新登录"
  1267. br.Ret = 408
  1268. return
  1269. }
  1270. pageSize, _ := this.GetInt("PageSize")
  1271. currentIndex, _ := this.GetInt("CurrentIndex")
  1272. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  1273. var startSize int
  1274. if pageSize <= 0 {
  1275. pageSize = utils.PageSize20
  1276. }
  1277. if currentIndex <= 0 {
  1278. currentIndex = 1
  1279. }
  1280. startSize = paging.StartIndex(currentIndex, pageSize)
  1281. var total int
  1282. resp := new(models.TacticsListTimeResp)
  1283. page := paging.GetPaging(currentIndex, pageSize, total)
  1284. list := make([]*models.TimeLineReportItem, 0)
  1285. var err error
  1286. list, total, err = models.GetTimeLineReportIndustrialListTime(user.UserId, industrialManagementId, startSize, pageSize)
  1287. if err != nil {
  1288. br.Msg = "获取信息失败"
  1289. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  1290. return
  1291. }
  1292. //处理晨会精华关联的标的,以及要跳转的文章ID
  1293. var meetingreviewchaptIds []int
  1294. var articleIds []int
  1295. mapchaptIdAndArticleId := make(map[int]int) // 晨会精华ID与跳转文章ID的映射关系
  1296. mapchaptIdListSubject := make(map[int][]*models.CygxIndustrialSubject) // 晨会精华ID与标的列表的映射关系
  1297. mapArticleIdListSubject := make(map[int][]*models.CygxIndustrialSubject) // 报告ID与标的列表的映射关系
  1298. for _, v := range list {
  1299. if v.Resource == 3 {
  1300. meetingreviewchaptIds = append(meetingreviewchaptIds, v.Id)
  1301. }
  1302. if v.Resource == 1 {
  1303. articleIds = append(articleIds, v.ArticleId)
  1304. }
  1305. }
  1306. if len(meetingreviewchaptIds) > 0 {
  1307. listMeet, err := services.GetCygxMorningMeetingReviewChapterListByIds(meetingreviewchaptIds)
  1308. if err != nil {
  1309. br.Msg = "获取失败"
  1310. br.ErrMsg = "GetCygxMorningMeetingReviewChapterListByIds,Err:" + err.Error()
  1311. }
  1312. for _, v := range listMeet {
  1313. mapchaptIdAndArticleId[v.Id] = v.LinkArticleId
  1314. mapchaptIdListSubject[v.Id] = v.ListSubject
  1315. }
  1316. }
  1317. if len(articleIds) > 0 {
  1318. mapArticleIdListSubject = services.GetArticleGroupSubjectMapByIndustrialManagementId(articleIds, industrialManagementId)
  1319. }
  1320. //查询用户今天是否看过时间线
  1321. //count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
  1322. //if err != nil {
  1323. // br.Msg = "查询浏览记录数量失败"
  1324. // br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
  1325. // return
  1326. //}
  1327. //var recordItem *models.CygxPageHistoryRecord
  1328. //if count > 1 {
  1329. // recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
  1330. // if err != nil {
  1331. // br.Msg = "查询浏览记录失败"
  1332. // br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
  1333. // return
  1334. // }
  1335. //}
  1336. for k, v := range list {
  1337. if v.SubCategoryName != "时间线" && v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  1338. list[k].IsRed = true
  1339. }
  1340. //timeLineRed := false
  1341. //if count < 2 && v.SubCategoryName == "时间线" {
  1342. // timeLineRed = true
  1343. //} else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(v.PublishDate)) {
  1344. // timeLineRed = true
  1345. //}
  1346. //if v.SubCategoryName == "时间线" && timeLineRed {
  1347. list[k].IsRed = true
  1348. //}
  1349. if v.VideoUrl != "" {
  1350. list[k].IsHaveVideo = true
  1351. }
  1352. v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
  1353. if v.Resource == 3 {
  1354. v.LinkArticleId = mapchaptIdAndArticleId[v.Id]
  1355. v.ListSubject = mapchaptIdListSubject[v.Id]
  1356. }
  1357. if v.Resource == 1 {
  1358. v.ListSubject = mapArticleIdListSubject[v.Id]
  1359. }
  1360. }
  1361. //添加我的日程访问记录
  1362. item := new(models.CygxPageHistoryRecord)
  1363. item.UserId = user.UserId
  1364. item.CreateTime = time.Now()
  1365. item.CompanyId = user.CompanyId
  1366. item.CompanyName = user.CompanyName
  1367. item.Router = utils.TIME_LINE_ROUTE + strconv.Itoa(industrialManagementId)
  1368. go models.AddCygxPageHistoryRecord(item)
  1369. if len(list) == 0 {
  1370. list = make([]*models.TimeLineReportItem, 0)
  1371. }
  1372. go services.AddCygxTimelineLog(user, industrialManagementId)
  1373. page = paging.GetPaging(currentIndex, pageSize, total)
  1374. resp.List = list
  1375. resp.Paging = page
  1376. br.Ret = 200
  1377. br.Success = true
  1378. br.Msg = "获取成功"
  1379. br.Data = resp
  1380. }
  1381. // @Title 文章留言接口
  1382. // @Description 文章留言接口
  1383. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  1384. // @Success 200 {object} models.TacticsListResp
  1385. // @router /commentAdd [post]
  1386. func (this *ReportController) CommentAdd() {
  1387. br := new(models.BaseResponse).Init()
  1388. defer func() {
  1389. this.Data["json"] = br
  1390. this.ServeJSON()
  1391. }()
  1392. user := this.User
  1393. if user == nil {
  1394. br.Msg = "请重新登录"
  1395. br.Ret = 408
  1396. return
  1397. }
  1398. var req models.AddCygxArticleCommentReq
  1399. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1400. if err != nil {
  1401. br.Msg = "参数解析异常!"
  1402. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1403. return
  1404. }
  1405. if req.ArticleId <= 0 {
  1406. br.Msg = "文章不存在"
  1407. br.ErrMsg = "文章不存在,文章ID错误"
  1408. return
  1409. }
  1410. if req.Content == "" {
  1411. br.Msg = "建议内容不可为空"
  1412. return
  1413. }
  1414. content := req.Content
  1415. if content == "" {
  1416. br.Msg = "留言内容不能为空!"
  1417. return
  1418. }
  1419. //itemToken, err := services.WxGetToken()
  1420. //if err != nil {
  1421. // br.Msg = "GetWxAccessToken Err:" + err.Error()
  1422. // return
  1423. //}
  1424. //if itemToken.AccessToken == "" {
  1425. // br.Msg = "accessToken is empty"
  1426. // return
  1427. //}
  1428. //commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  1429. //if err != nil {
  1430. // br.Msg = "内容校验失败!"
  1431. // br.ErrMsg = "内容校验失败,Err:" + err.Error()
  1432. // return
  1433. //}
  1434. //if commerr.ErrCode != 0 {
  1435. // br.Msg = "内容违规,请重新提交!"
  1436. // br.ErrMsg = "内容违规,Err:" + commerr.ErrMSG
  1437. // return
  1438. //}
  1439. articleId := req.ArticleId
  1440. articleInfo, errInfo := models.GetArticleDetailById(articleId)
  1441. if articleInfo == nil {
  1442. br.Msg = "操作失败"
  1443. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  1444. return
  1445. }
  1446. if errInfo != nil {
  1447. br.Msg = "操作失败"
  1448. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1449. return
  1450. }
  1451. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  1452. if err != nil {
  1453. br.Msg = "提交失败!"
  1454. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1455. return
  1456. }
  1457. if companyDetail == nil {
  1458. br.Msg = "提交失败!"
  1459. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  1460. return
  1461. }
  1462. item := models.CygxArticleComment{
  1463. UserId: user.UserId,
  1464. ArticleId: req.ArticleId,
  1465. CreateTime: time.Now(),
  1466. Mobile: user.Mobile,
  1467. Email: user.Email,
  1468. CompanyId: user.CompanyId,
  1469. CompanyName: companyDetail.CompanyName,
  1470. Content: content,
  1471. Title: articleInfo.Title,
  1472. }
  1473. msgId, err := models.AddArticleComment(&item)
  1474. if err != nil {
  1475. br.Msg = "提交失败"
  1476. br.ErrMsg = "提交留言失败,Err:" + err.Error()
  1477. return
  1478. }
  1479. go services.SendCommentWxTemplateMsg(req, user, articleInfo, int(msgId))
  1480. go services.SendCommentWxTemplateMsgByYxCategory(req, user, articleInfo, int(msgId)) // 发送用户留言提醒(研选公众号类目模版消息)
  1481. br.Ret = 200
  1482. br.Success = true
  1483. br.Msg = "提交成功"
  1484. }
  1485. // @Title 报告精选、本周研究汇总、上周纪要汇总列表
  1486. // @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
  1487. // @Param PageSize query int true "每页数据条数"
  1488. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1489. // @Param ReportType string query true "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
  1490. // @Success 200 {object} models.CygxReportSelectionListPublicRep
  1491. // @router /reportList/byType [get]
  1492. func (this *ReportController) ReportListByType() {
  1493. br := new(models.BaseResponse).Init()
  1494. defer func() {
  1495. this.Data["json"] = br
  1496. this.ServeJSON()
  1497. }()
  1498. user := this.User
  1499. if user == nil {
  1500. br.Msg = "请重新登录"
  1501. br.Ret = 408
  1502. return
  1503. }
  1504. uid := user.UserId
  1505. pageSize, _ := this.GetInt("PageSize")
  1506. currentIndex, _ := this.GetInt("CurrentIndex")
  1507. reportType := this.GetString("ReportType")
  1508. var condition string
  1509. var startSize int
  1510. if pageSize <= 0 {
  1511. pageSize = utils.PageSize20
  1512. }
  1513. if currentIndex <= 0 {
  1514. currentIndex = 1
  1515. }
  1516. startSize = paging.StartIndex(currentIndex, pageSize)
  1517. var pars []interface{}
  1518. var total int
  1519. resp := new(models.CygxReportSelectionListPublicRep)
  1520. page := paging.GetPaging(currentIndex, pageSize, total)
  1521. var tbdb string
  1522. var readSql string
  1523. var reportTypeStr string
  1524. if reportType == "1" {
  1525. tbdb = "cygx_report_selection"
  1526. reportTypeStr = "bgjx"
  1527. } else if reportType == "2" {
  1528. tbdb = "cygx_research_summary"
  1529. reportTypeStr = "bzyjhz"
  1530. } else if reportType == "3" {
  1531. tbdb = "cygx_minutes_summary"
  1532. reportTypeStr = "szjyhz"
  1533. } else {
  1534. br.Msg = "请选择报告类型"
  1535. return
  1536. }
  1537. condition = ` AND publish_status = 1 `
  1538. if user.CompanyId != utils.HZ_COMPANY_ID {
  1539. condition += ` AND visible_range = 1 `
  1540. }
  1541. total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
  1542. if err != nil {
  1543. br.Msg = "获取信息失败"
  1544. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1545. return
  1546. }
  1547. //研究汇总--报告精选 只显示最新一期,往期都隐藏
  1548. if reportType == "1" {
  1549. startSize = 0
  1550. pageSize = 1
  1551. total = 1
  1552. }
  1553. 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`
  1554. page = paging.GetPaging(currentIndex, pageSize, total)
  1555. list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
  1556. if err != nil {
  1557. br.Msg = "获取失败"
  1558. br.ErrMsg = "获取失败,Err:" + err.Error()
  1559. return
  1560. }
  1561. for k, v := range list {
  1562. if reportType == "1" {
  1563. list[k].Abstract = v.UpdateDescription
  1564. }
  1565. list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
  1566. if v.ReadNum == 0 {
  1567. list[k].IsRed = true
  1568. }
  1569. }
  1570. resp.List = list
  1571. resp.Paging = page
  1572. br.Ret = 200
  1573. br.Success = true
  1574. br.Msg = "获取成功"
  1575. br.Data = resp
  1576. }
  1577. // @Title 获取本周研究汇总详情
  1578. // @Description 获取本周研究汇总详情接口
  1579. // @Param ArticleId query int true "报告ID"
  1580. // @Success 200 {object} models.ResearchSummaryLetailResp
  1581. // @router /researchSummary/detail [get]
  1582. func (this *ReportController) ResearchDetail() {
  1583. br := new(models.BaseResponse).Init()
  1584. defer func() {
  1585. this.Data["json"] = br
  1586. this.ServeJSON()
  1587. }()
  1588. user := this.User
  1589. if user == nil {
  1590. br.Msg = "请重新登录"
  1591. br.Ret = 408
  1592. return
  1593. }
  1594. //uid := user.UserId
  1595. articleId, _ := this.GetInt("ArticleId")
  1596. if articleId < 0 {
  1597. br.Msg = "参数错误"
  1598. br.ErrMsg = "参数错误"
  1599. return
  1600. }
  1601. resp := new(models.ResearchSummaryLetailResp)
  1602. //判断用户权限
  1603. hasPermission, err := services.GetUserhasPermission(user)
  1604. if err != nil {
  1605. br.Msg = "获取信息失败"
  1606. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1607. }
  1608. detail, err := models.GetCygxResearchSummaryInfoById(articleId)
  1609. if err != nil {
  1610. br.Msg = "获取信息失败"
  1611. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1612. return
  1613. }
  1614. PermissionNameMap, err := services.GetPermissionNameMap()
  1615. if err != nil {
  1616. br.Msg = "获取失败"
  1617. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1618. return
  1619. }
  1620. PermissionIcoMap, err := services.GetPermissionNameIcoMap()
  1621. if err != nil {
  1622. br.Msg = "获取失败"
  1623. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1624. return
  1625. }
  1626. //未设置全部可见的只能给弘则内部查看
  1627. if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
  1628. resp.IsShow = true
  1629. }
  1630. resp.HasPermission = hasPermission
  1631. if hasPermission != 1 || !resp.IsShow {
  1632. br.Ret = 200
  1633. br.Success = true
  1634. br.Msg = "获取成功"
  1635. br.Data = resp
  1636. return
  1637. }
  1638. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1639. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1640. listFirst, err := models.GetResearchSummarylogListFirst(articleId)
  1641. if err != nil {
  1642. br.Msg = "获取失败"
  1643. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1644. return
  1645. }
  1646. listArticleType, err := models.GetCygxArticleTypeList()
  1647. if err != nil {
  1648. br.Msg = "获取失败"
  1649. br.ErrMsg = "获取文章类型数据失败,Err:" + err.Error()
  1650. return
  1651. }
  1652. for k, v := range listFirst {
  1653. listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
  1654. if err != nil && err.Error() != utils.ErrNoRow() {
  1655. br.Msg = "获取信息失败"
  1656. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1657. return
  1658. }
  1659. for k2, v2 := range listSecond {
  1660. v2.PermissionName = PermissionNameMap[v2.ChartPermissionId]
  1661. v2.IcoLink = PermissionIcoMap[v2.ChartPermissionId]
  1662. listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
  1663. if err != nil && err.Error() != utils.ErrNoRow() {
  1664. br.Msg = "获取信息失败"
  1665. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1666. return
  1667. }
  1668. for _, vType := range listArticleType {
  1669. if v2.ChartPermissionId == vType.YanxPermissionId {
  1670. listSecond[k2].IcoLink = vType.IcoLinkM
  1671. listSecond[k2].PermissionName = vType.YanxPermissionName
  1672. }
  1673. }
  1674. if len(listThird) > 0 {
  1675. for k3, v3 := range listThird {
  1676. if v3.VideoUrl != "" {
  1677. listThird[k3].IsHaveVideo = true
  1678. }
  1679. if v3.ReportLink == "0" {
  1680. listThird[k3].ReportLink = ""
  1681. }
  1682. }
  1683. listSecond[k2].List = listThird
  1684. }
  1685. }
  1686. if len(listSecond) > 0 {
  1687. listFirst[k].List = listSecond
  1688. }
  1689. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1690. if v.Type == "SDBG" {
  1691. listFirst[k].ListName = "深度报告"
  1692. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211027/le8AcRjDz0MhA72bVDiaf3d5ALSe.png"
  1693. } else if v.Type == "BZCHJH" {
  1694. listFirst[k].ListName = "本周晨会精华"
  1695. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
  1696. } else if v.Type == "CYDYJY" {
  1697. listFirst[k].ListName = "产业调研纪要"
  1698. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1699. } else if v.Type == "SSGS" {
  1700. listFirst[k].ListName = "上市公司调研纪要篇"
  1701. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1702. } else if v.Type == "SJDP" {
  1703. listFirst[k].ListName = "市场QA汇总"
  1704. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
  1705. } else if v.Type == "YANX" {
  1706. listFirst[k].ListName = "买方研选"
  1707. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1708. }
  1709. }
  1710. //go services.AddCygxReportHistoryRecord(user, articleId, "bzyjhz")
  1711. go services.ResearchSummaryHistoryUserRmind(user, articleId) // 本周研究汇总用户阅读操作操作行为,模板消息推送
  1712. resp.List = listFirst
  1713. resp.Detail = detail
  1714. br.Ret = 200
  1715. br.Success = true
  1716. br.Msg = "获取成功"
  1717. br.Data = resp
  1718. }
  1719. // @Title 上周纪要汇总内容详情
  1720. // @Description 获取上周纪要汇总内容详情接口
  1721. // @Param ArticleId query int true "报告ID"
  1722. // @Success 200 {object} models.MinutesSummaryLetailResp
  1723. // @router /minutesSummary/detail [get]
  1724. func (this *ReportController) MinutesDetail() {
  1725. br := new(models.BaseResponse).Init()
  1726. defer func() {
  1727. this.Data["json"] = br
  1728. this.ServeJSON()
  1729. }()
  1730. user := this.User
  1731. if user == nil {
  1732. br.Msg = "请重新登录"
  1733. br.Ret = 408
  1734. return
  1735. }
  1736. articleId, _ := this.GetInt("ArticleId")
  1737. if articleId < 0 {
  1738. br.Msg = "参数错误"
  1739. br.ErrMsg = "参数错误"
  1740. return
  1741. }
  1742. resp := new(models.MinutesSummaryLetailRespV4)
  1743. //判断用户权限
  1744. hasPermission, err := services.GetUserhasPermission(user)
  1745. if err != nil {
  1746. br.Msg = "获取信息失败"
  1747. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1748. }
  1749. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1750. if err != nil {
  1751. br.Msg = "获取信息失败"
  1752. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1753. return
  1754. }
  1755. PermissionNameMap, err := services.GetPermissionNameMap()
  1756. if err != nil {
  1757. br.Msg = "获取失败"
  1758. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1759. return
  1760. }
  1761. PermissionIcoMap, err := services.GetPermissionNameIcoMap()
  1762. if err != nil {
  1763. br.Msg = "获取失败"
  1764. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1765. return
  1766. }
  1767. //未设置全部可见的只能给弘则内部查看
  1768. if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
  1769. resp.IsShow = true
  1770. }
  1771. resp.HasPermission = hasPermission
  1772. if hasPermission != 1 || !resp.IsShow {
  1773. br.Ret = 200
  1774. br.Success = true
  1775. br.Msg = "获取成功"
  1776. br.Data = resp
  1777. return
  1778. }
  1779. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1780. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1781. listFirst, err := models.GetMinutesSummarylogListAllV4(articleId)
  1782. if err != nil {
  1783. br.Msg = "获取失败"
  1784. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1785. return
  1786. }
  1787. for k, v := range listFirst {
  1788. listSecond, err := models.GetMinutesSummarylogSonListSecond(articleId, v.Type)
  1789. if err != nil && err.Error() != utils.ErrNoRow() {
  1790. br.Msg = "获取信息失败"
  1791. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1792. return
  1793. }
  1794. for k2, v2 := range listSecond {
  1795. v2.PermissionName = PermissionNameMap[v2.ChartPermissionId]
  1796. v2.IcoLink = PermissionIcoMap[v2.ChartPermissionId]
  1797. listThird, err := models.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
  1798. if err != nil && err.Error() != utils.ErrNoRow() {
  1799. br.Msg = "获取信息失败"
  1800. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1801. return
  1802. }
  1803. if len(listThird) > 0 {
  1804. for k3, v3 := range listThird {
  1805. if v3.VideoUrl != "" {
  1806. listThird[k3].IsHaveVideo = true
  1807. }
  1808. if v3.ReportLink == "0" {
  1809. listThird[k3].ReportLink = ""
  1810. }
  1811. }
  1812. listSecond[k2].List = listThird
  1813. }
  1814. }
  1815. if len(listSecond) > 0 {
  1816. listFirst[k].List = listSecond
  1817. }
  1818. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1819. if v.Type == "CYDYJY" {
  1820. listFirst[k].ListName = "产业调研纪要"
  1821. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1822. } else if v.Type == "SSGS" {
  1823. listFirst[k].ListName = "上市公司调研纪要篇"
  1824. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1825. } else if v.Type == "YANX" {
  1826. listFirst[k].ListName = "买方研选纪要"
  1827. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1828. }
  1829. }
  1830. //go services.AddCygxReportHistoryRecord(user, articleId, "szjyhz")
  1831. go services.MinutesSummaryHistoryUserRmind(user, articleId) // 上周纪要汇总用户阅读,给销售发消息提醒
  1832. resp.List = listFirst
  1833. resp.Detail = detail
  1834. br.Ret = 200
  1835. br.Success = true
  1836. br.Msg = "获取成功"
  1837. br.Data = resp
  1838. }
  1839. // @Title 记录用户浏览音频回放接口
  1840. // @Description 记录用户浏览音频回放接口
  1841. // @Param request body models.ArticleIdReq true "type json string"
  1842. // @Success Ret=200 操作成功
  1843. // @router /voiceHistory/add [post]
  1844. func (this *ReportController) ResearchSummaryVoiceHistoryAdd() {
  1845. br := new(models.BaseResponse).Init()
  1846. defer func() {
  1847. this.Data["json"] = br
  1848. this.ServeJSON()
  1849. }()
  1850. user := this.User
  1851. if user == nil {
  1852. br.Msg = "请登录"
  1853. br.ErrMsg = "请登录,用户信息为空"
  1854. br.Ret = 408
  1855. return
  1856. }
  1857. uid := user.UserId
  1858. var req models.ArticleIdReq
  1859. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1860. if err != nil {
  1861. br.Msg = "参数解析异常!"
  1862. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1863. return
  1864. }
  1865. articleId := req.ArticleId
  1866. playSeconds := req.PlaySeconds
  1867. reportType := req.ReportType
  1868. //本周研究汇总
  1869. if reportType == 2 {
  1870. articleInfo, errInfo := models.GetCygxResearchSummaryInfoById(articleId)
  1871. if articleInfo == nil {
  1872. br.Msg = "操作失败"
  1873. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  1874. return
  1875. }
  1876. if errInfo != nil {
  1877. br.Msg = "操作失败"
  1878. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1879. return
  1880. }
  1881. var sellerName string
  1882. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1883. if err != nil {
  1884. br.Msg = "报名失败!"
  1885. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1886. return
  1887. }
  1888. item := models.CygxResearchSummaryVoiceHistory{
  1889. ArticleId: articleId,
  1890. UserId: uid,
  1891. CreateTime: time.Now(),
  1892. Mobile: user.Mobile,
  1893. Email: user.Email,
  1894. CompanyId: user.CompanyId,
  1895. CompanyName: user.CompanyName,
  1896. RealName: user.RealName,
  1897. SellerName: sellerName,
  1898. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  1899. ModifyTime: time.Now(),
  1900. RegisterPlatform: utils.REGISTER_PLATFORM,
  1901. }
  1902. if playSeconds != 0 {
  1903. lastItem, err := models.GetLastCygxResearchSummaryVoiceHistory(articleId, user.UserId)
  1904. if err != nil {
  1905. br.Msg = "操作失败"
  1906. br.ErrMsg = "操作失败,GetLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  1907. return
  1908. }
  1909. err = models.UpdateLastCygxResearchSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  1910. if err != nil {
  1911. br.Msg = "更新失败"
  1912. br.ErrMsg = "更新失败,UpdateLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  1913. return
  1914. }
  1915. } else {
  1916. err = models.AddCygxResearchSummaryVoiceHistory(&item)
  1917. if err != nil {
  1918. br.Msg = "操作失败"
  1919. br.ErrMsg = "操作失败,Err:" + err.Error()
  1920. return
  1921. }
  1922. err = models.UpdateResearchSummaryVoiceCounts(articleId)
  1923. if err != nil {
  1924. br.Msg = "更新失败"
  1925. br.ErrMsg = "更新失败,Err:" + err.Error()
  1926. return
  1927. }
  1928. }
  1929. } else if reportType == 3 {
  1930. articleInfo, errInfo := models.GetCygxMinutesSummaryInfoById(articleId)
  1931. if articleInfo == nil {
  1932. br.Msg = "操作失败"
  1933. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  1934. return
  1935. }
  1936. if errInfo != nil {
  1937. br.Msg = "操作失败"
  1938. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1939. return
  1940. }
  1941. var sellerName string
  1942. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1943. if err != nil {
  1944. br.Msg = "报名失败!"
  1945. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1946. return
  1947. }
  1948. item := models.CygxMinutesSummaryVoiceHistory{
  1949. ArticleId: articleId,
  1950. UserId: uid,
  1951. CreateTime: time.Now(),
  1952. Mobile: user.Mobile,
  1953. Email: user.Email,
  1954. CompanyId: user.CompanyId,
  1955. CompanyName: user.CompanyName,
  1956. RealName: user.RealName,
  1957. SellerName: sellerName,
  1958. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  1959. ModifyTime: time.Now(),
  1960. RegisterPlatform: utils.REGISTER_PLATFORM,
  1961. }
  1962. if playSeconds != 0 {
  1963. lastItem, err := models.GetLastCygxMinutesSummaryVoiceHistory(articleId, user.UserId)
  1964. if err != nil {
  1965. br.Msg = "操作失败"
  1966. br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
  1967. return
  1968. }
  1969. err = models.UpdateLastCygxMinutesSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  1970. if err != nil {
  1971. br.Msg = "更新失败"
  1972. br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
  1973. return
  1974. }
  1975. } else {
  1976. err = models.AddCygxMinutesSummaryVoiceHistory(&item)
  1977. if err != nil {
  1978. br.Msg = "操作失败"
  1979. br.ErrMsg = "操作失败,Err:" + err.Error()
  1980. return
  1981. }
  1982. err = models.UpdateMinutesSummaryVoiceCounts(articleId)
  1983. if err != nil {
  1984. br.Msg = "更新失败"
  1985. br.ErrMsg = "更新失败,Err:" + err.Error()
  1986. return
  1987. }
  1988. }
  1989. }
  1990. br.Ret = 200
  1991. br.Success = true
  1992. br.Msg = "操作成功"
  1993. return
  1994. }
  1995. // @Title 根据行业分类获取行业文章列表
  1996. // @Description 根据行业分类获取行业文章列表接口
  1997. // @Param PageSize query int true "每页数据条数"
  1998. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1999. // @Param CategoryId query int true "分类ID"
  2000. // @Param IndustrialManagementId query int false "产业ID"
  2001. // @Success 200 {object} models.TacticsListResp
  2002. // @router /tactics/list [get]
  2003. func (this *MobileReportController) TacticsList() {
  2004. br := new(models.BaseResponse).Init()
  2005. defer func() {
  2006. this.Data["json"] = br
  2007. this.ServeJSON()
  2008. }()
  2009. user := this.User
  2010. if user == nil {
  2011. br.Msg = "请重新登录"
  2012. br.Ret = 408
  2013. return
  2014. }
  2015. //uid := user.UserId
  2016. pageSize, _ := this.GetInt("PageSize")
  2017. currentIndex, _ := this.GetInt("CurrentIndex")
  2018. categoryId, _ := this.GetInt("CategoryId")
  2019. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  2020. var startSize int
  2021. if pageSize <= 0 {
  2022. pageSize = utils.PageSize20
  2023. }
  2024. if currentIndex <= 0 {
  2025. currentIndex = 1
  2026. }
  2027. startSize = paging.StartIndex(currentIndex, pageSize)
  2028. //var condition string
  2029. //var pars []interface{}
  2030. var total int
  2031. var err error
  2032. resp := new(models.TacticsListResp)
  2033. page := paging.GetPaging(currentIndex, pageSize, total)
  2034. list := make([]*models.ArticleListResp, 0)
  2035. if categoryId == utils.TIME_CATEGORYID {
  2036. list, total, err = models.GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize)
  2037. if err != nil {
  2038. br.Msg = "获取信息失败"
  2039. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  2040. return
  2041. }
  2042. } else {
  2043. if categoryId == utils.ACTEGORY_ID_AI_QY {
  2044. listArticle := make([]*models.HomeArticle, 0)
  2045. listArticle, total, err = services.GetAiQianYanArtilceList(startSize, pageSize)
  2046. if err != nil {
  2047. br.Msg = "获取信息失败"
  2048. br.Msg = "GetAiQianYanArtilceList,Err:" + err.Error()
  2049. return
  2050. }
  2051. for _, v := range listArticle {
  2052. list = append(list, &models.ArticleListResp{
  2053. ArticleId: v.ArticleId,
  2054. Title: v.Title,
  2055. CategoryId: v.CategoryId,
  2056. Annotation: v.Annotation,
  2057. Abstract: v.Abstract,
  2058. Body: v.Body,
  2059. PublishDate: v.PublishDate,
  2060. Resource: 1,
  2061. })
  2062. }
  2063. } else {
  2064. list, total, err = models.GetReportAndproductIndustrylListimg(categoryId, user.UserId, startSize, pageSize)
  2065. if err != nil {
  2066. br.Msg = "获取信息失败"
  2067. br.Msg = "GetHomeList,Err:" + err.Error()
  2068. return
  2069. }
  2070. }
  2071. articleIdMap, err := services.GetUserArticleHistoryRecord(user)
  2072. if err != nil {
  2073. br.Msg = "获取信息失败"
  2074. br.Msg = "获取帖子数据失败,Err:" + err.Error()
  2075. return
  2076. }
  2077. for k, v := range list {
  2078. //list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  2079. if !articleIdMap[v.ArticleId] && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  2080. list[k].IsRed = true
  2081. }
  2082. }
  2083. if categoryId > 0 {
  2084. detail, errCategory := models.GetCygxReportMappingCygxByCategoryId(categoryId)
  2085. if errCategory != nil {
  2086. br.Msg = "获取信息失败"
  2087. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  2088. return
  2089. }
  2090. resp.MatchTypeName = detail.MatchTypeName
  2091. }
  2092. //resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  2093. }
  2094. listPublic, err := services.HandleArticleCategoryImg(list, user)
  2095. if err != nil {
  2096. br.Msg = "获取失败"
  2097. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  2098. return
  2099. }
  2100. var articleIds []int
  2101. var productInteriorIs []int
  2102. for _, v := range listPublic {
  2103. if v.Resource == 1 {
  2104. articleIds = append(articleIds, v.ArticleId)
  2105. }
  2106. if v.Resource == 2 {
  2107. productInteriorIs = append(productInteriorIs, v.ArticleId)
  2108. }
  2109. }
  2110. articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
  2111. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
  2112. articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
  2113. productInteriorMapPv := services.GetCygxProductInteriorHistoryListPvMap(productInteriorIs) //产品内测Pv
  2114. listResp := make([]*models.HomeArticle, 0)
  2115. for _, v := range listPublic {
  2116. item := new(models.HomeArticle)
  2117. item.ArticleId = v.ArticleId
  2118. item.ReportId = v.ReportId
  2119. item.Title = v.Title
  2120. item.Annotation = v.Annotation
  2121. item.Abstract = v.Abstract
  2122. item.ImgUrlPc = v.ImgUrlPc
  2123. item.PublishDate = v.PublishDate
  2124. item.Resource = v.Resource
  2125. if v.Resource == 1 {
  2126. item.Pv = articleMapPv[v.ArticleId]
  2127. item.IsCollect = articleCollectMap[v.ArticleId]
  2128. item.CollectNum = articleCollectNumMap[v.ArticleId]
  2129. }
  2130. if v.Resource == 2 {
  2131. item.Pv = productInteriorMapPv[v.ArticleId]
  2132. }
  2133. if v.ReportId > 0 {
  2134. item.Resource = 3
  2135. }
  2136. listResp = append(listResp, item)
  2137. }
  2138. if len(listResp) == 0 {
  2139. listResp = make([]*models.HomeArticle, 0)
  2140. }
  2141. page = paging.GetPaging(currentIndex, pageSize, total)
  2142. resp.List = listResp
  2143. resp.Paging = page
  2144. br.Ret = 200
  2145. br.Success = true
  2146. br.Msg = "获取成功"
  2147. br.Data = resp
  2148. }
  2149. // @Title 周期行业报告分类列表接口
  2150. // @Description 周期获取行业报告分类列表接口
  2151. // @Success 200 {object} models.TradeReportMappingResp
  2152. // @router /zhouqi_tradeList [get]
  2153. func (this *MobileReportController) ZouqiTradeList() {
  2154. br := new(models.BaseResponse).Init()
  2155. defer func() {
  2156. this.Data["json"] = br
  2157. this.ServeJSON()
  2158. }()
  2159. user := this.User
  2160. if user == nil {
  2161. br.Msg = "请重新登录"
  2162. br.Ret = 408
  2163. return
  2164. }
  2165. listCategory, err := models.GetCygxZhouqiArticleMapFirst()
  2166. if err != nil {
  2167. br.Msg = "获取信息失败"
  2168. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2169. return
  2170. }
  2171. fllowMap := services.GetXzsChooseCategoryZhouqiMapByMobile(user.Mobile)
  2172. resp := new(models.TradeReportMappingResp)
  2173. var list []*models.TradeReportMapping
  2174. if len(listCategory) == 0 {
  2175. list = make([]*models.TradeReportMapping, 0)
  2176. } else {
  2177. for _, v := range listCategory {
  2178. item := new(models.TradeReportMapping)
  2179. item.CategoryId = v.CategoryId
  2180. item.MatchTypeName = v.MatchTypeName
  2181. item.UpdateTime = utils.TimeRemoveHms(v.ArticleUpdateTime)
  2182. item.IsFollow = fllowMap[item.CategoryId]
  2183. item.ListArticle = make([]*models.HomeArticle, 0)
  2184. list = append(list, item)
  2185. }
  2186. }
  2187. resp.List = list
  2188. br.Ret = 200
  2189. br.Success = true
  2190. br.Msg = "获取成功"
  2191. br.Data = resp
  2192. }
  2193. // @Title 周期根据行业分类获取行业文章列表
  2194. // @Description 周期根据行业分类获取行业文章列表接口
  2195. // @Param PageSize query int true "每页数据条数"
  2196. // @Param CurrentIndex query int true "当前页页码,从1开始"
  2197. // @Param CategoryId query int true "分类ID"
  2198. // @Success 200 {object} models.TacticsListResp
  2199. // @router /tactics/zhouqi_list [get]
  2200. func (this *MobileReportController) ZhouqiTacticsList() {
  2201. br := new(models.BaseResponse).Init()
  2202. defer func() {
  2203. this.Data["json"] = br
  2204. this.ServeJSON()
  2205. }()
  2206. user := this.User
  2207. if user == nil {
  2208. br.Msg = "请重新登录"
  2209. br.Ret = 408
  2210. return
  2211. }
  2212. //uid := user.UserId
  2213. pageSize, _ := this.GetInt("PageSize")
  2214. currentIndex, _ := this.GetInt("CurrentIndex")
  2215. categoryId, _ := this.GetInt("CategoryId")
  2216. var startSize int
  2217. if pageSize <= 0 {
  2218. pageSize = utils.PageSize20
  2219. }
  2220. if currentIndex <= 0 {
  2221. currentIndex = 1
  2222. }
  2223. startSize = paging.StartIndex(currentIndex, pageSize)
  2224. detail, err := models.GetCygxZhouqiArticleMapInfoById(categoryId)
  2225. if err != nil {
  2226. br.Msg = "获取信息失败"
  2227. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2228. return
  2229. }
  2230. var total int
  2231. //var err error
  2232. resp := new(models.TacticsListResp)
  2233. page := paging.GetPaging(currentIndex, pageSize, total)
  2234. list := make([]*models.ArticleListResp, 0)
  2235. listCategory, err := models.GetCygxZhouqiArticleMapByParentId(categoryId)
  2236. if err != nil {
  2237. br.Msg = "获取信息失败"
  2238. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  2239. return
  2240. }
  2241. var matchTypeName = []string{}
  2242. var seriesName = []string{}
  2243. for _, v := range listCategory {
  2244. if v.MatchTypeName != "" {
  2245. matchTypeName = append(matchTypeName, v.MatchTypeName)
  2246. }
  2247. if v.SeriesName != "" {
  2248. seriesName = append(seriesName, v.SeriesName)
  2249. }
  2250. }
  2251. var conditionOr string
  2252. if detail.FiccReportId != "" {
  2253. conditionOr = " OR art.report_id IN (" + detail.FiccReportId + ")" // 手动配置报告展示逻辑处理
  2254. }
  2255. if len(seriesName) > 0 {
  2256. conditionOr += " OR series_name IN ('" + strings.Join(seriesName, "','") + "') "
  2257. }
  2258. var condition string
  2259. //var pars []interface{}
  2260. //if len(seriesName) == 0 {
  2261. // condition = " AND field_name IN ('" + strings.Join(matchTypeName, "','") + "')"
  2262. //} else {
  2263. // condition = " AND ( field_name IN ('" + strings.Join(matchTypeName, "','") + "') OR series_name IN ('" + strings.Join(seriesName, "','") + "') )"
  2264. //}
  2265. condition = " AND ( field_name IN ('" + strings.Join(matchTypeName, "','") + "') " + conditionOr + " ) "
  2266. list, total, err = models.GetReportAndproductIndustrylListimgZhouqi(condition, startSize, pageSize)
  2267. if err != nil {
  2268. br.Msg = "获取信息失败"
  2269. br.Msg = "GetHomeList,Err:" + err.Error()
  2270. return
  2271. }
  2272. listPublic, err := services.HandleArticleCategoryImg(list, user)
  2273. if err != nil {
  2274. br.Msg = "获取失败"
  2275. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  2276. return
  2277. }
  2278. var articleIds []int
  2279. var productInteriorIs []int
  2280. for _, v := range listPublic {
  2281. if v.Resource == 1 {
  2282. articleIds = append(articleIds, v.ArticleId)
  2283. }
  2284. if v.Resource == 2 {
  2285. productInteriorIs = append(productInteriorIs, v.ArticleId)
  2286. }
  2287. }
  2288. articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
  2289. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
  2290. articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
  2291. productInteriorMapPv := services.GetCygxProductInteriorHistoryListPvMap(productInteriorIs) //产品内测Pv
  2292. listResp := make([]*models.HomeArticle, 0)
  2293. for _, v := range listPublic {
  2294. item := new(models.HomeArticle)
  2295. item.ArticleId = v.ArticleId
  2296. item.ReportId = v.ReportId
  2297. item.Title = v.Title
  2298. item.Annotation = v.Annotation
  2299. item.Abstract = v.Abstract
  2300. item.ImgUrlPc = v.ImgUrlPc
  2301. item.PublishDate = v.PublishDate
  2302. item.Resource = v.Resource
  2303. if v.Resource == 1 {
  2304. item.Pv = articleMapPv[v.ArticleId]
  2305. item.IsCollect = articleCollectMap[v.ArticleId]
  2306. item.CollectNum = articleCollectNumMap[v.ArticleId]
  2307. }
  2308. if v.Resource == 2 {
  2309. item.Pv = productInteriorMapPv[v.ArticleId]
  2310. }
  2311. if v.ReportId > 0 {
  2312. item.Resource = 3
  2313. }
  2314. listResp = append(listResp, item)
  2315. }
  2316. if len(listResp) == 0 {
  2317. listResp = make([]*models.HomeArticle, 0)
  2318. }
  2319. page = paging.GetPaging(currentIndex, pageSize, total)
  2320. resp.List = listResp
  2321. resp.Paging = page
  2322. br.Ret = 200
  2323. br.Success = true
  2324. br.Msg = "获取成功"
  2325. br.Data = resp
  2326. }
  2327. // @Title 周期行业关注/取消关注
  2328. // @Description 周期行业关注/取消关注 接口
  2329. // @Param request body models.CygxCategoryFllowRep true "type json string"
  2330. // @Success 200
  2331. // @router /category/zhouqi_fllow [post]
  2332. func (this *ReportController) CategoryZhouqiFllow() {
  2333. br := new(models.BaseResponse).Init()
  2334. defer func() {
  2335. this.Data["json"] = br
  2336. this.ServeJSON()
  2337. }()
  2338. user := this.User
  2339. if user == nil {
  2340. br.Msg = "请重新登录"
  2341. br.Ret = 408
  2342. return
  2343. }
  2344. uid := user.UserId
  2345. var req models.CygxCategoryFllowRep
  2346. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  2347. if err != nil {
  2348. br.Msg = "参数解析异常!"
  2349. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  2350. return
  2351. }
  2352. categoryId := req.CategoryId
  2353. count, err := models.GetCountCategoryFllowZhouqi(categoryId, user.Mobile)
  2354. if err != nil {
  2355. br.Msg = "获取数据失败!"
  2356. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  2357. return
  2358. }
  2359. resp := new(models.CygxIndustryFllowResp)
  2360. if count == 0 {
  2361. item := new(models.CygxXzsChooseCategoryZhouqi)
  2362. item.CategoryId = categoryId
  2363. item.UserId = uid
  2364. item.Email = user.Email
  2365. item.Mobile = user.Mobile
  2366. item.RealName = user.RealName
  2367. item.CompanyId = user.CompanyId
  2368. item.CompanyName = user.CompanyName
  2369. item.CreateTime = time.Now()
  2370. item.ModifyTime = time.Now()
  2371. _, err = models.AddCygxCategoryFllowZhouqi(item)
  2372. if err != nil {
  2373. br.Msg = "操作失败"
  2374. br.ErrMsg = "操作失败,Err:" + err.Error()
  2375. return
  2376. }
  2377. resp.Status = 1
  2378. br.Msg = "关注成功"
  2379. } else {
  2380. err = models.RemoveCygxCategoryFllowZhouqi(user.Mobile, categoryId)
  2381. if err != nil {
  2382. br.Msg = "操作失败"
  2383. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  2384. return
  2385. }
  2386. resp.Status = 2
  2387. br.Msg = "已取消关注"
  2388. }
  2389. br.Ret = 200
  2390. br.Success = true
  2391. br.Data = resp
  2392. }