report.go 75 KB

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