report.go 65 KB

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