report.go 78 KB

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