report.go 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "hongze/hongze_clpt/models"
  7. "hongze/hongze_clpt/services"
  8. "hongze/hongze_clpt/utils"
  9. "strconv"
  10. "strings"
  11. "time"
  12. )
  13. // 报告
  14. type ReportController struct {
  15. BaseAuthController
  16. }
  17. type ReportCommonController struct {
  18. BaseCommonController
  19. }
  20. type MobileReportController struct {
  21. BaseAuthMobileController
  22. }
  23. // @Title 行业报告分类列表接口
  24. // @Description 获取行业报告分类列表接口
  25. // @Param ChartPermissionId query int true "分类ID"
  26. // @Success 200 {object} models.TradeReportMappingResp
  27. // @router /tradeList [get]
  28. func (this *MobileReportController) TradeList() {
  29. br := new(models.BaseResponse).Init()
  30. defer func() {
  31. this.Data["json"] = br
  32. this.ServeJSON()
  33. }()
  34. user := this.User
  35. if user == nil {
  36. br.Msg = "请重新登录"
  37. br.Ret = 408
  38. return
  39. }
  40. fmt.Println(user)
  41. uid := user.UserId
  42. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  43. if ChartPermissionId < 1 {
  44. br.Msg = "请输入分类ID"
  45. return
  46. }
  47. //var result []*models.SearchItem
  48. var list []*models.TradeReportMapping
  49. var err error
  50. mapCategory := make(map[int]int)
  51. if ChartPermissionId == utils.CE_LUE_ID {
  52. listTrade, errTrade := models.GetReportMappingStrategyHomeAll()
  53. list = listTrade
  54. err = errTrade
  55. if user.Mobile != "" {
  56. //策略的处理
  57. categoryList, err := models.GetCygxXzsChooseCategoryList(user.Mobile)
  58. if err != nil && err.Error() != utils.ErrNoRow() {
  59. br.Msg = "获取信息失败"
  60. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  61. return
  62. }
  63. for _, v := range categoryList {
  64. mapCategory[v.CategoryId] = v.CategoryId
  65. }
  66. }
  67. } else {
  68. listTrade, errTrade := models.GetTradeAll(ChartPermissionId)
  69. err = errTrade
  70. list = listTrade
  71. }
  72. if err != nil {
  73. br.Msg = "获取信息失败"
  74. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  75. return
  76. }
  77. for k, v := range list {
  78. var condition string
  79. var pars []interface{}
  80. //categoryIdSet, errCategory := models.GetdetailByCategoryIdSet(v.CategoryId)
  81. //if errCategory != nil {
  82. // br.Msg = "获取信息失败"
  83. // br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(v.CategoryId)
  84. // return
  85. //}
  86. //if categoryIdSet != "" {
  87. // condition = ` AND a.category_id IN(` + categoryIdSet + `)`
  88. //} else {
  89. // condition = ` AND a.category_id IN(` + strconv.Itoa(v.CategoryId) + `)`
  90. //}
  91. if v.PolymerizationId != "" {
  92. condition = ` AND a.category_id IN(` + v.PolymerizationId + `)`
  93. } else {
  94. condition = ` AND a.category_id IN(` + strconv.Itoa(v.CategoryId) + `)`
  95. }
  96. if ChartPermissionId != utils.CE_LUE_ID {
  97. var pageSize int
  98. //if ChartPermissionId == utils.KE_JI_ID {
  99. // pageSize = 12
  100. //} else {
  101. // pageSize = 3
  102. //}
  103. pageSize = 3
  104. listArticle, err := models.GetHomeList(condition, pars, 0, pageSize)
  105. if err != nil {
  106. br.Msg = "获取信息失败"
  107. br.Msg = "GetHomeList,Err:" + err.Error()
  108. return
  109. }
  110. if len(listArticle) > 0 {
  111. list[k].UpdateTime = utils.StrTimeToTime(listArticle[0].PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
  112. count, err := models.CheckThisCategoryNewArticleIsRead(uid, v.CategoryId)
  113. if err != nil {
  114. br.Msg = "获取信息失败"
  115. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  116. return
  117. }
  118. if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.UpdateTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.UpdateTime)) {
  119. list[k].IsRed = true
  120. }
  121. }
  122. list[k].ListArticle = listArticle
  123. } else {
  124. if mapCategory[v.CategoryId] > 0 {
  125. list[k].IsFollow = true
  126. }
  127. list[k].ListArticle = make([]*models.HomeArticle, 0)
  128. }
  129. }
  130. resp := new(models.TradeReportMappingResp)
  131. if len(list) == 0 {
  132. list = make([]*models.TradeReportMapping, 0)
  133. }
  134. resp.List = list
  135. br.Ret = 200
  136. br.Success = true
  137. br.Msg = "获取成功"
  138. br.Data = resp
  139. }
  140. // @Title 产业报告分类列表接口
  141. // @Description 获取产业报告分类列表接口
  142. // @Param ChartPermissionId query int true "分类ID"
  143. // @Param DeepCover query int false "是否选择深度覆盖,1是,0否 不填默认为0"
  144. // @Param RecommendFocus query int false "是否选择推荐关注,1是,0否 不填默认为0"
  145. // @Param PageSize query int true "每页数据条数"
  146. // @Param CurrentIndex query int true "当前页页码,从1开始"
  147. // @Param IsBillboard query bool false "是否属于榜单 是true 否 false"
  148. // @Success 200 {object} models.IndustrialManagementList
  149. // @router /industryList [get]
  150. func (this *MobileReportController) IndustryList() {
  151. br := new(models.BaseResponse).Init()
  152. defer func() {
  153. this.Data["json"] = br
  154. this.ServeJSON()
  155. }()
  156. user := this.User
  157. if user == nil {
  158. br.Msg = "请重新登录"
  159. br.Ret = 408
  160. return
  161. }
  162. uid := user.UserId
  163. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  164. orderColumn := this.GetString("OrderColumn")
  165. orderColumnNew := this.GetString("OrderColumn")
  166. isNewLabel := this.GetString("IsNewLabel")
  167. isDeepLabel := this.GetString("IsDeepLabel")
  168. pageSize, _ := this.GetInt("PageSize")
  169. currentIndex, _ := this.GetInt("CurrentIndex")
  170. deepCover, _ := this.GetInt("DeepCover")
  171. recommendFocus, _ := this.GetInt("RecommendFocus")
  172. isBillboard, _ := this.GetBool("IsBillboard", false)
  173. var orderSrt string
  174. var condition string
  175. var startSize int
  176. resp := new(models.IndustrialManagementList)
  177. if pageSize <= 0 {
  178. pageSize = utils.PageSize20
  179. }
  180. if currentIndex <= 0 {
  181. currentIndex = 1
  182. }
  183. startSize = paging.StartIndex(currentIndex, pageSize)
  184. if ChartPermissionId > 0 {
  185. condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
  186. }
  187. // 获取近一个月产业报告阅读次数最多的产业
  188. var topCond string
  189. var topPars []interface{}
  190. topReadIndustryId := 0
  191. if ChartPermissionId > 0 {
  192. topCond += ` AND chart_permission_id = ?`
  193. topPars = append(topPars, ChartPermissionId)
  194. }
  195. topReadIndustry, e := models.GetTopOneMonthArtReadNumIndustry(topCond, topPars)
  196. if e != nil && e.Error() != utils.ErrNoRow() {
  197. br.Msg = "获取信息失败"
  198. br.ErrMsg = "获取近一个月报告阅读次数最多的产业失败, Err: " + e.Error()
  199. return
  200. }
  201. if topReadIndustry != nil {
  202. topReadIndustryId = topReadIndustry.IndustrialManagementId
  203. }
  204. // 深度覆盖
  205. if deepCover == 1 {
  206. // 查询深标签产业报告数
  207. var deepCondition string
  208. var deepPars []interface{}
  209. deepCondition += ` AND man.is_deep_label = 1`
  210. if ChartPermissionId > 0 {
  211. deepCondition += ` AND man.chart_permission_id = ?`
  212. deepPars = append(deepPars, ChartPermissionId)
  213. }
  214. industryCountList, e := models.GetIndustryArtCountByCondition(deepCondition, deepPars)
  215. if e != nil {
  216. br.Msg = "获取信息失败"
  217. br.ErrMsg = "获取深标签产业报告数失败, Err: " + e.Error()
  218. return
  219. }
  220. deepIdArr := make([]string, 0)
  221. for i := range industryCountList {
  222. if industryCountList[i].ArtNum > 10 {
  223. deepIdArr = append(deepIdArr, strconv.Itoa(industryCountList[i].IndustrialManagementId))
  224. }
  225. }
  226. deepIds := strings.Join(deepIdArr, ",")
  227. if deepIds != "" {
  228. condition = `AND man.industrial_management_id IN (` + deepIds + `)`
  229. }
  230. }
  231. // 推荐关注
  232. if recommendFocus == 1 {
  233. condition += ` AND man.recommended_index >= 80`
  234. }
  235. var list []*models.IndustrialManagement
  236. total, err := models.GetIndustrialManagementAllCount(condition)
  237. if err != nil {
  238. br.Msg = "获取信息失败"
  239. br.ErrMsg = "获取数量失败,Err:" + err.Error()
  240. return
  241. }
  242. if orderColumn == "" {
  243. orderColumn = "NewTime"
  244. }
  245. if orderColumn == "NewTime" {
  246. orderSrt = "update_time DESC"
  247. } else {
  248. orderSrt = "man.recommended_index DESC,update_time DESC"
  249. }
  250. if isBillboard {
  251. // 查询有已归类行业报告的行业IDs
  252. activeIndustryIds, e := models.GetActiveArticleIndustryIds()
  253. if e != nil {
  254. br.Msg = "获取失败"
  255. br.ErrMsg = "获取已归类行业失败, Err:" + e.Error()
  256. return
  257. }
  258. activeIndustryLen := len(activeIndustryIds)
  259. //topNum := pageSize
  260. condition = ""
  261. var parsBd []interface{}
  262. if ChartPermissionId > 0 {
  263. condition += ` AND man.chart_permission_id = ? `
  264. parsBd = append(parsBd, ChartPermissionId)
  265. }
  266. if activeIndustryLen > 0 {
  267. condition += ` AND man.industrial_management_id IN (` + utils.GetOrmInReplace(activeIndustryLen) + `)`
  268. parsBd = append(parsBd, activeIndustryIds)
  269. }
  270. nowTime := time.Now().Local()
  271. startTime := nowTime.AddDate(0, -1, 0)
  272. endTime := nowTime.AddDate(0, 0, -1)
  273. condition += ` AND idf.create_time BETWEEN ? AND ?`
  274. parsBd = append(parsBd, startTime, endTime)
  275. list, e = models.GetTopIndustryFollowData(0, pageSize, condition, parsBd)
  276. if e != nil {
  277. br.Msg = "获取失败"
  278. br.ErrMsg = "获取关注度最高的产业数据失败, Err:" + e.Error()
  279. return
  280. }
  281. } else {
  282. list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize, isBillboard)
  283. if err != nil {
  284. br.Msg = "获取信息失败"
  285. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  286. return
  287. }
  288. }
  289. list, err = services.HandleIndustryList(list, user, "")
  290. if err != nil {
  291. br.Msg = "获取信息失败"
  292. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  293. return
  294. }
  295. industrialIdArr := make([]int, 0)
  296. for k, v := range list {
  297. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  298. if topReadIndustryId > 0 && list[k].IndustrialManagementId == topReadIndustryId {
  299. list[k].IsHot = true
  300. }
  301. }
  302. if orderColumnNew != "" {
  303. item := new(models.CygxReportIndustrialSeaarchHistory)
  304. item.UserId = user.UserId
  305. item.Mobile = user.Mobile
  306. item.CompanyId = user.CompanyId
  307. item.CompanyName = user.CompanyName
  308. item.CreateTime = time.Now()
  309. item.IsDeepLabel = isDeepLabel
  310. item.IsNewLabel = isNewLabel
  311. item.ChartPermissionId = ChartPermissionId
  312. if orderColumnNew == "NewTime" {
  313. item.OrderColumn = "0"
  314. } else {
  315. item.OrderColumn = "1"
  316. }
  317. go models.AddCygxReportIndustrialSeaarchHistory(item)
  318. }
  319. if len(list) == 0 {
  320. list = make([]*models.IndustrialManagement, 0)
  321. }
  322. page := paging.GetPaging(currentIndex, pageSize, total)
  323. if isBillboard {
  324. total = len(list)
  325. }
  326. resp.List = list
  327. resp.Paging = page
  328. br.Ret = 200
  329. br.Success = true
  330. br.Msg = "获取成功"
  331. br.Data = resp
  332. }
  333. // @Title 产业下所关联的文章分类列表
  334. // @Description 产业下所关联的文章分类列表接口
  335. // @Param IndustrialManagementId query int true "产业ID"
  336. // @Success 200 {object} models.IndustrialToArticleCategoryListRep
  337. // @router /toArticleCategoryList [get]
  338. func (this *MobileReportController) ArticleCategoryList() {
  339. br := new(models.BaseResponse).Init()
  340. defer func() {
  341. this.Data["json"] = br
  342. this.ServeJSON()
  343. }()
  344. user := this.User
  345. if user == nil {
  346. br.Msg = "请重新登录"
  347. br.Ret = 408
  348. return
  349. }
  350. uid := user.UserId
  351. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  352. if industrialManagementId < 1 {
  353. br.Msg = "请输入分类ID"
  354. return
  355. }
  356. detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  357. if err != nil {
  358. br.Msg = "获取信息失败"
  359. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  360. return
  361. }
  362. list, err := models.IndustrialToArticleCategory(industrialManagementId, detail.ChartPermissionId)
  363. if err != nil {
  364. br.Msg = "获取信息失败"
  365. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  366. return
  367. }
  368. for k, v := range list {
  369. recordCount, err := models.IndustrialUserRecordArticleCount(uid, industrialManagementId, v.CategoryId)
  370. if err != nil && err.Error() != utils.ErrNoRow() {
  371. br.Msg = "获取信息失败"
  372. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  373. return
  374. }
  375. Newdetail, err := models.GetNewIndustrialUserRecordArticle(industrialManagementId, v.CategoryId)
  376. if err != nil {
  377. br.Msg = "获取信息失败"
  378. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  379. return
  380. }
  381. if Newdetail != nil {
  382. if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
  383. list[k].IsRed = true
  384. }
  385. }
  386. }
  387. //标的列表
  388. industrialSubjectList, err := models.GetIndustrialSubjectAll(industrialManagementId)
  389. if err != nil {
  390. br.Msg = "获取信息失败"
  391. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  392. return
  393. }
  394. videoSimple, au, err := services.GetindustryVideo(user, industrialManagementId)
  395. if err != nil {
  396. br.Msg = "获取失败"
  397. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  398. return
  399. }
  400. timeLineItem := models.IndustrialToArticleCategoryRep{
  401. CategoryId: utils.TIME_CATEGORYID,
  402. MatchTypeName: "时间线",
  403. }
  404. timeLineIsRed, err := services.GetShowTimeLineIsRed(user, industrialManagementId)
  405. if err != nil {
  406. br.Msg = "获取失败"
  407. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  408. return
  409. }
  410. timeLineItem.IsRed = timeLineIsRed
  411. list = append([]*models.IndustrialToArticleCategoryRep{&timeLineItem}, list...)
  412. resp := new(models.IndustrialToArticleCategoryListRep)
  413. resp.List = list
  414. resp.ListSubject = industrialSubjectList
  415. resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
  416. resp.IndustryName = detail.IndustryName
  417. resp.IndustrialManagementId = industrialManagementId
  418. if videoSimple != nil && videoSimple.Id > 0 {
  419. resp.IndustryVideo = videoSimple
  420. }
  421. resp.AuthInfo = au
  422. br.Ret = 200
  423. br.Success = true
  424. br.Msg = "获取成功"
  425. br.Data = resp
  426. }
  427. // @Title 根据行业分类获取文章列表
  428. // @Description根据行业分类获取文章列表接口
  429. // @Param PageSize query int true "每页数据条数"
  430. // @Param CurrentIndex query int true "当前页页码,从1开始"
  431. // @Param CategoryId query int true "分类ID"
  432. // @Param IndustrialManagementId query int false "产业ID"
  433. // @Success 200 {object} models.TacticsListResp
  434. // @router /articleList/byCategoryId [get]
  435. func (this *MobileReportController) List() {
  436. br := new(models.BaseResponse).Init()
  437. defer func() {
  438. this.Data["json"] = br
  439. this.ServeJSON()
  440. }()
  441. user := this.User
  442. if user == nil {
  443. br.Msg = "请重新登录"
  444. br.Ret = 408
  445. return
  446. }
  447. //uid := user.UserId
  448. pageSize, _ := this.GetInt("PageSize")
  449. currentIndex, _ := this.GetInt("CurrentIndex")
  450. categoryId, _ := this.GetInt("CategoryId")
  451. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  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.HomeArticle, 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. //condition += ` AND category_id_two=? `
  523. //pars = append(pars, categoryId)
  524. //categoryIdSet, errCategory := models.GetdetailByCategoryIdSet(categoryId)
  525. //if errCategory != nil {
  526. // br.Msg = "获取信息失败"
  527. // br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  528. // return
  529. //}
  530. //fmt.Println(detail.PolymerizationId)
  531. if detail.PolymerizationId != "" {
  532. condition = ` AND category_id IN(` + detail.PolymerizationId + `)`
  533. } else {
  534. categoryIdSet, errCategory := models.GetdetailByCategoryIdSet(categoryId)
  535. if errCategory != nil {
  536. br.Msg = "获取信息失败"
  537. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  538. return
  539. }
  540. if categoryIdSet != "" {
  541. condition = ` AND category_id IN(` + categoryIdSet + `)`
  542. } else {
  543. condition = ` AND category_id IN(` + strconv.Itoa(categoryId) + `)`
  544. }
  545. //condition = ` AND category_id IN(` + strconv.Itoa(categoryId) + `)`
  546. //condition = ` AND match_type_name = '` + detail.MatchTypeName + `'`
  547. }
  548. if industrialManagementId > 0 {
  549. industrialManageentList, err := models.GetIndustrialArticleGroupManagementByIndustrialManagementId(industrialManagementId)
  550. if err != nil {
  551. br.Msg = "获取信息失败"
  552. br.Msg = "获取产业关联的文章ID失败,GetIndustrialArticleGroupManagementByIndustrialManagementIdErr:" + err.Error()
  553. return
  554. }
  555. articleIdList := make([]string, 0)
  556. for _, v := range industrialManageentList {
  557. articleIdList = append(articleIdList, strconv.Itoa(v.ArticleId))
  558. }
  559. condition += ` AND a.article_id IN ( ` + utils.GetOrmInReplace(len(articleIdList)) + ` ) `
  560. pars = append(pars, articleIdList)
  561. }
  562. total, err = models.GetHomeCount(condition, pars)
  563. if err != nil {
  564. br.Msg = "获取信息失败"
  565. br.Msg = "获取帖子总数失败,Err:" + err.Error()
  566. return
  567. }
  568. list, err = models.GetHomeList(condition, pars, startSize, pageSize)
  569. if err != nil {
  570. br.Msg = "获取信息失败"
  571. br.Msg = "获取帖子数据失败,Err:" + err.Error()
  572. return
  573. }
  574. for k, v := range list {
  575. list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  576. if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  577. list[k].IsRed = true
  578. }
  579. }
  580. if categoryId > 0 {
  581. detail, errCategory := models.GetdetailByCategoryId(categoryId)
  582. if errCategory != nil {
  583. br.Msg = "获取信息失败"
  584. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  585. return
  586. }
  587. resp.MatchTypeName = detail.MatchTypeName
  588. }
  589. resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  590. }
  591. lenList := len(list)
  592. for i := 0; i < lenList; i++ {
  593. item := list[i]
  594. list[i].Body = ""
  595. list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  596. list[i].Annotation, _ = services.GetReportContentTextSub(item.Annotation)
  597. list[i].PublishDate = utils.StrTimeToTime(item.PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
  598. //行业比较研究、资金流向,显示报告的摘要
  599. if resp.MatchTypeName == "行业比较研究" || resp.MatchTypeName == "资金流向" {
  600. list[i].Annotation = list[i].Abstract
  601. }
  602. }
  603. if len(list) == 0 {
  604. list = make([]*models.HomeArticle, 0)
  605. }
  606. page = paging.GetPaging(currentIndex, pageSize, total)
  607. resp.List = list
  608. resp.Paging = page
  609. br.Ret = 200
  610. br.Success = true
  611. br.Msg = "获取成功"
  612. br.Data = resp
  613. }
  614. // @Title 产业关注/取消关注
  615. // @Description 产业关注/取消关注 接口
  616. // @Param request body models.CygxIndustryFllowRep true "type json string"
  617. // @Success 200
  618. // @router /industrial/fllow [post]
  619. func (this *ReportController) IndustrialFllow() {
  620. br := new(models.BaseResponse).Init()
  621. defer func() {
  622. this.Data["json"] = br
  623. this.ServeJSON()
  624. }()
  625. user := this.User
  626. if user == nil {
  627. br.Msg = "请重新登录"
  628. br.Ret = 408
  629. return
  630. }
  631. uid := user.UserId
  632. var req models.CygxIndustryFllowRep
  633. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  634. if err != nil {
  635. br.Msg = "参数解析异常!"
  636. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  637. return
  638. }
  639. industrialManagementId := req.IndustrialManagementId
  640. var condition string
  641. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  642. if err != nil {
  643. br.Msg = "获取数据失败!"
  644. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  645. return
  646. }
  647. if countIndustrial == 0 {
  648. br.Msg = "产业不存在!"
  649. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  650. return
  651. }
  652. count, err := models.GetCountCygxIndustryFllow(industrialManagementId, user.UserId, condition)
  653. if err != nil {
  654. br.Msg = "获取数据失败!"
  655. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  656. return
  657. }
  658. resp := new(models.CygxIndustryFllowResp)
  659. if count == 0 {
  660. item := new(models.CygxIndustryFllow)
  661. item.IndustrialManagementId = industrialManagementId
  662. item.UserId = uid
  663. item.Email = user.Email
  664. item.Mobile = user.Mobile
  665. item.RealName = user.RealName
  666. item.CompanyId = user.CompanyId
  667. item.CompanyName = user.CompanyName
  668. item.Type = 1
  669. item.CreateTime = time.Now()
  670. item.ModifyTime = time.Now()
  671. _, err = models.AddCygxIndustryFllow(item)
  672. if err != nil {
  673. br.Msg = "操作失败"
  674. br.ErrMsg = "操作失败,Err:" + err.Error()
  675. return
  676. }
  677. resp.Status = 1
  678. br.Msg = "关注成功"
  679. } else {
  680. err = models.RemoveCygxIndustryFllow(uid, industrialManagementId)
  681. if err != nil {
  682. br.Msg = "操作失败"
  683. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  684. return
  685. }
  686. resp.Status = 2
  687. br.Msg = "已取消关注"
  688. }
  689. //处理是否关注全部赛道字段
  690. go services.IndustryFllowWithTrack(industrialManagementId, count, uid)
  691. br.Ret = 200
  692. br.Success = true
  693. br.Data = resp
  694. }
  695. // @Title 行业关注/取消关注
  696. // @Description 行业关注/取消关注 接口
  697. // @Param request body models.CygxCategoryFllowRep true "type json string"
  698. // @Success 200
  699. // @router /category/fllow [post]
  700. func (this *ReportController) CategoryFllow() {
  701. br := new(models.BaseResponse).Init()
  702. defer func() {
  703. this.Data["json"] = br
  704. this.ServeJSON()
  705. }()
  706. user := this.User
  707. if user == nil {
  708. br.Msg = "请重新登录"
  709. br.Ret = 408
  710. return
  711. }
  712. uid := user.UserId
  713. var req models.CygxCategoryFllowRep
  714. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  715. if err != nil {
  716. br.Msg = "参数解析异常!"
  717. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  718. return
  719. }
  720. categoryId := req.CategoryId
  721. var condition string
  722. countCategory, err := models.GetCategoryCount(categoryId)
  723. if err != nil {
  724. br.Msg = "获取数据失败!"
  725. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  726. return
  727. }
  728. if countCategory == 0 {
  729. br.Msg = "产业不存在!"
  730. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(categoryId)
  731. return
  732. }
  733. count, err := models.GetCountCategoryFllow(categoryId, user.Mobile, condition)
  734. if err != nil {
  735. br.Msg = "获取数据失败!"
  736. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  737. return
  738. }
  739. resp := new(models.CygxIndustryFllowResp)
  740. if count == 0 {
  741. item := new(models.CygxXzsChooseCategory)
  742. item.CategoryId = categoryId
  743. item.UserId = uid
  744. item.Email = user.Email
  745. item.Mobile = user.Mobile
  746. item.RealName = user.RealName
  747. item.CompanyId = user.CompanyId
  748. item.CompanyName = user.CompanyName
  749. item.CreateTime = time.Now()
  750. item.ModifyTime = time.Now()
  751. _, err = models.AddCygxCategoryFllow(item)
  752. if err != nil {
  753. br.Msg = "操作失败"
  754. br.ErrMsg = "操作失败,Err:" + err.Error()
  755. return
  756. }
  757. resp.Status = 1
  758. br.Msg = "关注成功"
  759. } else {
  760. err = models.RemoveCygxCategoryFllow(user.Mobile, categoryId)
  761. if err != nil {
  762. br.Msg = "操作失败"
  763. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  764. return
  765. }
  766. resp.Status = 2
  767. br.Msg = "已取消关注"
  768. }
  769. br.Ret = 200
  770. br.Success = true
  771. br.Data = resp
  772. }
  773. // @Title 报告搜索
  774. // @Description 报告搜索接口
  775. // @Param PageSize query int true "每页数据条数"
  776. // @Param CurrentIndex query int true "当前页页码,从1开始"
  777. // @Param KeyWord query string true "搜索关键词"
  778. // @Param ArticleType query int true "文章类型,1弘则报告、2研选 "
  779. // @Param IsAll query bool true "是否为综合 "
  780. // @Success 200 {object} models.ReoprtSearchResp
  781. // @router /searchReport [get]
  782. func (this *MobileReportController) SearchReport() {
  783. br := new(models.BaseResponse).Init()
  784. defer func() {
  785. this.Data["json"] = br
  786. this.ServeJSON()
  787. }()
  788. user := this.User
  789. if user == nil {
  790. br.Msg = "请重新登录"
  791. br.Ret = 408
  792. return
  793. }
  794. pageSize, _ := this.GetInt("PageSize")
  795. currentIndex, _ := this.GetInt("CurrentIndex")
  796. articleType, _ := this.GetInt("ArticleType", 1)
  797. keyWord := this.GetString("KeyWord")
  798. isAll, _ := this.GetBool("IsAll")
  799. var condition string
  800. var pars []interface{}
  801. //var conditionSql string
  802. var total int
  803. var startSize int
  804. if pageSize <= 0 {
  805. pageSize = utils.PageSize20
  806. }
  807. if isAll {
  808. pageSize = utils.PageSize5
  809. }
  810. if currentIndex <= 0 {
  811. currentIndex = 1
  812. }
  813. startSize = paging.StartIndex(currentIndex, pageSize)
  814. resp := new(models.ReoprtSearchResp)
  815. //匹配报告标题、
  816. articleTypeIds, err := services.GetYanXuanArticleTypeIds()
  817. if err != nil {
  818. br.Msg = "获取信息失败"
  819. br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
  820. return
  821. }
  822. if articleTypeIds == "" {
  823. br.Msg = "获取信息失败"
  824. br.ErrMsg = "研选分类ID不能为空"
  825. return
  826. }
  827. //处理对应的文章类型标签按钮
  828. nameMap, styleMap, err := services.GetArticleTypeMap()
  829. if err != nil {
  830. br.Msg = "获取信息失败"
  831. br.ErrMsg = "GetArticleTypeMap Err:" + err.Error()
  832. return
  833. }
  834. if isAll {
  835. total = utils.PageSize5
  836. 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 + `) `
  837. 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 + `) `
  838. listHz, err := models.GetArticleResearchListHz(conditionHz, pars, startSize, pageSize, user.UserId)
  839. if err != nil {
  840. br.Msg = "获取信息失败"
  841. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  842. return
  843. }
  844. listYx, err := models.GetArticleResearchList(conditionYx, pars, startSize, pageSize, user.UserId)
  845. if err != nil {
  846. br.Msg = "获取信息失败"
  847. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  848. return
  849. }
  850. listHz, err = services.HandleArticleCategoryImg(listHz, user)
  851. if err != nil {
  852. br.Msg = "获取信息失败"
  853. br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
  854. return
  855. }
  856. listYx, err = services.HandleArticleCategoryImg(listYx, user)
  857. if err != nil {
  858. br.Msg = "获取信息失败"
  859. br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
  860. return
  861. }
  862. for _, v := range listHz {
  863. item := models.ArticleResearchResp{
  864. ArticleId: v.ArticleId,
  865. ArticleTypeId: v.ArticleTypeId,
  866. Title: v.Title,
  867. PublishDate: v.PublishDate,
  868. DepartmentId: v.DepartmentId,
  869. NickName: v.NickName,
  870. IsCollect: v.IsCollect,
  871. Pv: v.Pv,
  872. CollectNum: v.CollectNum,
  873. Abstract: v.Abstract,
  874. Annotation: v.Annotation,
  875. ImgUrlPc: v.ImgUrlPc,
  876. ArticleTypeName: nameMap[v.ArticleTypeId],
  877. ButtonStyle: styleMap[v.ArticleTypeId],
  878. List: v.List,
  879. }
  880. resp.ListHz = append(resp.ListHz, &item)
  881. }
  882. for _, v := range listYx {
  883. item := models.ArticleResearchResp{
  884. ArticleId: v.ArticleId,
  885. ArticleTypeId: v.ArticleTypeId,
  886. Title: v.Title,
  887. PublishDate: v.PublishDate,
  888. DepartmentId: v.DepartmentId,
  889. NickName: v.NickName,
  890. IsCollect: v.IsCollect,
  891. Pv: v.Pv,
  892. CollectNum: v.CollectNum,
  893. Abstract: v.Abstract,
  894. Annotation: v.Annotation,
  895. ImgUrlPc: v.ImgUrlPc,
  896. ArticleTypeName: nameMap[v.ArticleTypeId],
  897. ButtonStyle: styleMap[v.ArticleTypeId],
  898. List: v.List,
  899. }
  900. resp.ListYx = append(resp.ListYx, &item)
  901. }
  902. } else {
  903. //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 `
  904. if articleType == 1 {
  905. 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 + `) `
  906. total, err = models.GetReoprtSearchCountHz(condition)
  907. } else {
  908. condition = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 AND a.article_type_id IN (` + articleTypeIds + `) `
  909. total, err = models.GetReoprtSearchCountYx(condition)
  910. }
  911. if err != nil {
  912. br.Msg = "获取信息失败"
  913. br.Msg = "获取总数失败,Err:" + err.Error()
  914. return
  915. }
  916. var list []*models.ArticleListResp
  917. //list := new([]models.ArticleResearchResp)
  918. if articleType == 1 {
  919. list, err = models.GetArticleResearchListHz(condition, pars, startSize, pageSize, user.UserId)
  920. } else {
  921. list, err = models.GetArticleResearchList(condition, pars, startSize, pageSize, user.UserId)
  922. }
  923. if err != nil {
  924. br.Msg = "获取信息失败"
  925. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  926. return
  927. }
  928. //return
  929. list, err = services.HandleArticleCategoryImg(list, user)
  930. if err != nil {
  931. br.Msg = "获取信息失败"
  932. br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
  933. return
  934. }
  935. for _, v := range list {
  936. item := models.ArticleResearchResp{
  937. ArticleId: v.ArticleId,
  938. ArticleTypeId: v.ArticleTypeId,
  939. Title: v.Title,
  940. PublishDate: v.PublishDate,
  941. DepartmentId: v.DepartmentId,
  942. NickName: v.NickName,
  943. IsCollect: v.IsCollect,
  944. Pv: v.Pv,
  945. CollectNum: v.CollectNum,
  946. Abstract: v.Abstract,
  947. Annotation: v.Annotation,
  948. ImgUrlPc: v.ImgUrlPc,
  949. ArticleTypeName: nameMap[v.ArticleTypeId],
  950. ButtonStyle: styleMap[v.ArticleTypeId],
  951. List: v.List,
  952. }
  953. if articleType == 1 {
  954. resp.ListHz = append(resp.ListHz, &item)
  955. } else {
  956. resp.ListYx = append(resp.ListYx, &item)
  957. }
  958. }
  959. }
  960. if keyWord != "" {
  961. go services.AddUserSearchLog(user, keyWord, 5)
  962. }
  963. if len(resp.ListHz) == 0 {
  964. resp.ListHz = make([]*models.ArticleResearchResp, 0)
  965. }
  966. if len(resp.ListYx) == 0 {
  967. resp.ListYx = make([]*models.ArticleResearchResp, 0)
  968. }
  969. page := paging.GetPaging(currentIndex, pageSize, total)
  970. resp.Paging = page
  971. br.Ret = 200
  972. br.Success = true
  973. br.Msg = "获取成功"
  974. br.Data = resp
  975. }
  976. // @Title 资源包搜索
  977. // @Description 资源包搜索接口
  978. // @Param KeyWord query string true "搜索关键词"
  979. // @Success 200 {object} models.SearchResourceResp
  980. // @router /searchResource [get]
  981. func (this *MobileReportController) SearchResource() {
  982. br := new(models.BaseResponse).Init()
  983. defer func() {
  984. this.Data["json"] = br
  985. this.ServeJSON()
  986. }()
  987. user := this.User
  988. if user == nil {
  989. br.Msg = "请重新登录"
  990. br.Ret = 408
  991. return
  992. }
  993. uid := user.UserId
  994. fllowList, err := models.GetUserFllowIndustrialList(uid)
  995. if err != nil {
  996. br.Msg = "获取失败"
  997. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  998. return
  999. }
  1000. fllowMap := make(map[int]int)
  1001. if len(fllowList) > 0 {
  1002. for _, v := range fllowList {
  1003. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  1004. }
  1005. }
  1006. keyWord := this.GetString("KeyWord")
  1007. var condition string
  1008. articleTypeIds, err := services.GetYanXuanArticleTypeIds()
  1009. if err != nil {
  1010. br.Msg = "获取信息失败"
  1011. br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
  1012. return
  1013. }
  1014. if articleTypeIds == "" {
  1015. br.Msg = "获取信息失败"
  1016. br.ErrMsg = "研选分类ID不能为空"
  1017. return
  1018. }
  1019. 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 + `%' ) `
  1020. listHz, err := models.GetSearchResourceList(condition)
  1021. if err != nil {
  1022. br.Msg = "获取信息失败"
  1023. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1024. return
  1025. }
  1026. 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 + `%' ) `
  1027. listYx, err := models.GetSearchResourceList(condition)
  1028. if err != nil {
  1029. br.Msg = "获取信息失败"
  1030. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1031. return
  1032. }
  1033. if len(listYx) > 0 {
  1034. listYx, err = services.HandleIndustryList(listYx, user, "Yx")
  1035. if err != nil {
  1036. br.Msg = "获取信息失败"
  1037. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1038. return
  1039. }
  1040. }
  1041. if len(listHz) > 0 {
  1042. listHz, err = services.HandleIndustryList(listHz, user, "Hz")
  1043. if err != nil {
  1044. br.Msg = "获取信息失败"
  1045. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1046. return
  1047. }
  1048. }
  1049. if keyWord != "" {
  1050. go services.AddUserSearchLog(user, keyWord, 4)
  1051. }
  1052. resp := new(models.SearchResourceResp)
  1053. if len(listHz) == 0 {
  1054. listHz = make([]*models.IndustrialManagement, 0)
  1055. }
  1056. if len(listYx) == 0 {
  1057. listYx = make([]*models.IndustrialManagement, 0)
  1058. }
  1059. resp.ListHz = listHz
  1060. resp.ListYx = listYx
  1061. br.Ret = 200
  1062. br.Success = true
  1063. br.Msg = "获取成功"
  1064. br.Data = resp
  1065. }
  1066. // @Title 报告搜索、资源包搜索接口
  1067. // @Description 报告搜索、资源包搜索接口接口
  1068. // @Param KeyWord query string true "搜索关键词"
  1069. // @Param PageSize query int true "每页数据条数"
  1070. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1071. // @Param SearchType query int true "1:综合,2:全部"
  1072. // @Success 200 {object} models.SearchReportAndResourceResp
  1073. // @router /searchReportAndResource [get]
  1074. func (this *MobileReportController) SearchReportAndResource() {
  1075. br := new(models.BaseResponse).Init()
  1076. defer func() {
  1077. this.Data["json"] = br
  1078. this.ServeJSON()
  1079. }()
  1080. user := this.User
  1081. if user == nil {
  1082. br.Msg = "请重新登录"
  1083. br.Ret = 408
  1084. return
  1085. }
  1086. //uid := user.UserId
  1087. keyWord := this.GetString("KeyWord")
  1088. pageSize, _ := this.GetInt("PageSize")
  1089. currentIndex, _ := this.GetInt("CurrentIndex")
  1090. searchType, _ := this.GetInt("SearchType")
  1091. var total int
  1092. var startSize int
  1093. if pageSize <= 0 {
  1094. pageSize = utils.PageSize20
  1095. }
  1096. if currentIndex <= 0 {
  1097. currentIndex = 1
  1098. }
  1099. startSize = paging.StartIndex(currentIndex, pageSize)
  1100. page := paging.GetPaging(currentIndex, pageSize, total)
  1101. var condition string
  1102. var conditionSql string
  1103. //匹配报告标题、
  1104. condition = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
  1105. conditionSql = ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + condition + ` OR ( article_type = 'lyjh' ` + condition + ` ) `
  1106. total, err := models.GetReoprtSearchCount(conditionSql)
  1107. if err != nil {
  1108. br.Msg = "获取信息失败"
  1109. br.Msg = "获取总数失败,Err:" + err.Error()
  1110. return
  1111. }
  1112. if searchType == 1 {
  1113. pageSize = utils.PageSize5
  1114. }
  1115. ListHzReport, err := services.GetReoprtSearchListHz(conditionSql, user.UserId, startSize, pageSize)
  1116. if err != nil {
  1117. br.Msg = "获取失败"
  1118. br.ErrMsg = "获取失败,GetReoprtSearchListHz Err:" + err.Error()
  1119. return
  1120. }
  1121. if len(ListHzReport) == 0 {
  1122. ListHzReport = make([]*models.ArticleCollectionResp, 0)
  1123. }
  1124. var conditionOr string
  1125. conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  1126. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  1127. listHzResource, err := services.GetSearchResourceListHz(condition, user)
  1128. if err != nil {
  1129. br.Msg = "获取信息失败"
  1130. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1131. return
  1132. }
  1133. resp := new(models.SearchReportAndResourceResp)
  1134. if len(listHzResource) == 0 {
  1135. listHzResource = make([]*models.IndustrialManagement, 0)
  1136. }
  1137. if keyWord != "" {
  1138. go services.AddUserSearchLog(user, keyWord, 5)
  1139. }
  1140. page = paging.GetPaging(currentIndex, pageSize, total)
  1141. resp.Paging = page
  1142. resp.ListHzResource = listHzResource
  1143. resp.ListHzReport = ListHzReport
  1144. br.Ret = 200
  1145. br.Success = true
  1146. br.Msg = "获取成功"
  1147. br.Data = resp
  1148. }
  1149. // @Title 公司速览
  1150. // @Description 公司速览接口
  1151. // @Param ChartPermissionId query int false "分类ID"
  1152. // @Success 200 {object} models.ArticleDataLogoListResp
  1153. // @router /companyList [get]
  1154. func (this *ReportCommonController) CompanyList() {
  1155. br := new(models.BaseResponse).Init()
  1156. defer func() {
  1157. this.Data["json"] = br
  1158. this.ServeJSON()
  1159. }()
  1160. var condition string
  1161. var pars []interface{}
  1162. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  1163. if chartPermissionId > 1 {
  1164. categoryId, err := models.GetCategoryId(chartPermissionId)
  1165. if err != nil && err.Error() != utils.ErrNoRow() {
  1166. br.Msg = "获取信息失败"
  1167. br.ErrMsg = "获取分类权限信息失败,Err:" + err.Error()
  1168. return
  1169. }
  1170. if categoryId != "" {
  1171. condition += ` AND a.category_id IN (` + categoryId + `)`
  1172. }
  1173. }
  1174. condition += ` AND a.type_name = '综述报告' ORDER BY a.modify_time_by_cl DESC `
  1175. list, err := models.CygxArticleDataList(condition, pars)
  1176. if err != nil {
  1177. br.Msg = "获取失败"
  1178. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  1179. return
  1180. }
  1181. listLogo := make([]*models.ArticleDataLogoResp, 0)
  1182. for i := range list {
  1183. v := list[i]
  1184. comapnyList := services.HandleArticleStock(v.Stock)
  1185. if len(comapnyList) > 1 {
  1186. for kC, vC := range comapnyList {
  1187. sliceCovers := strings.Split(v.Cover, "{|}")
  1188. cover := v.Cover
  1189. if len(sliceCovers) == len(comapnyList) {
  1190. cover = sliceCovers[kC]
  1191. }
  1192. listLogo = append(listLogo, &models.ArticleDataLogoResp{
  1193. ArticleId: v.ArticleId,
  1194. Cover: cover,
  1195. ComapnyList: services.HandleArticleStock(vC.ComapnyName),
  1196. })
  1197. }
  1198. } else {
  1199. listLogo = append(listLogo, &models.ArticleDataLogoResp{
  1200. ArticleId: v.ArticleId,
  1201. Cover: v.Cover,
  1202. ComapnyList: services.HandleArticleStock(v.Stock),
  1203. })
  1204. }
  1205. }
  1206. resp := new(models.ArticleDataLogoListResp)
  1207. resp.List = listLogo
  1208. br.Ret = 200
  1209. br.Success = true
  1210. br.Msg = "获取成功"
  1211. br.Data = resp
  1212. }
  1213. // @Title 时间线
  1214. // @Description 时间线接口
  1215. // @Param PageSize query int true "每页数据条数"
  1216. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1217. // @Param IndustrialManagementId query int false "产业ID"
  1218. // @Success 200 {object} models.TacticsListResp
  1219. // @router /timeline [get]
  1220. func (this *MobileReportController) Timeline() {
  1221. br := new(models.BaseResponse).Init()
  1222. defer func() {
  1223. this.Data["json"] = br
  1224. this.ServeJSON()
  1225. }()
  1226. user := this.User
  1227. if user == nil {
  1228. br.Msg = "请重新登录"
  1229. br.Ret = 408
  1230. return
  1231. }
  1232. pageSize, _ := this.GetInt("PageSize")
  1233. currentIndex, _ := this.GetInt("CurrentIndex")
  1234. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  1235. var startSize int
  1236. if pageSize <= 0 {
  1237. pageSize = utils.PageSize20
  1238. }
  1239. if currentIndex <= 0 {
  1240. currentIndex = 1
  1241. }
  1242. startSize = paging.StartIndex(currentIndex, pageSize)
  1243. var total int
  1244. resp := new(models.TacticsListTimeResp)
  1245. page := paging.GetPaging(currentIndex, pageSize, total)
  1246. list := make([]*models.TimeLineReportItem, 0)
  1247. var err error
  1248. list, total, err = models.GetTimeLineReportIndustrialListTime(user.UserId, industrialManagementId, startSize, pageSize)
  1249. if err != nil {
  1250. br.Msg = "获取信息失败"
  1251. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  1252. return
  1253. }
  1254. //查询用户今天是否看过时间线
  1255. count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
  1256. if err != nil {
  1257. br.Msg = "查询浏览记录数量失败"
  1258. br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
  1259. return
  1260. }
  1261. var recordItem *models.CygxPageHistoryRecord
  1262. if count > 1 {
  1263. recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
  1264. if err != nil {
  1265. br.Msg = "查询浏览记录失败"
  1266. br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
  1267. return
  1268. }
  1269. }
  1270. for k, v := range list {
  1271. if v.SubCategoryName != "时间线" && v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  1272. list[k].IsRed = true
  1273. }
  1274. timeLineRed := false
  1275. if count < 2 && v.SubCategoryName == "时间线" {
  1276. timeLineRed = true
  1277. } else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(v.PublishDate)) {
  1278. timeLineRed = true
  1279. }
  1280. if v.SubCategoryName == "时间线" && timeLineRed {
  1281. list[k].IsRed = true
  1282. }
  1283. if v.VideoUrl != "" {
  1284. list[k].IsHaveVideo = true
  1285. }
  1286. }
  1287. if len(list) == 0 {
  1288. list = make([]*models.TimeLineReportItem, 0)
  1289. }
  1290. page = paging.GetPaging(currentIndex, pageSize, total)
  1291. resp.List = list
  1292. resp.Paging = page
  1293. br.Ret = 200
  1294. br.Success = true
  1295. br.Msg = "获取成功"
  1296. br.Data = resp
  1297. }
  1298. // @Title 文章留言接口
  1299. // @Description 文章留言接口
  1300. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  1301. // @Success 200 {object} models.TacticsListResp
  1302. // @router /commentAdd [post]
  1303. func (this *ReportController) CommentAdd() {
  1304. br := new(models.BaseResponse).Init()
  1305. defer func() {
  1306. this.Data["json"] = br
  1307. this.ServeJSON()
  1308. }()
  1309. user := this.User
  1310. if user == nil {
  1311. br.Msg = "请重新登录"
  1312. br.Ret = 408
  1313. return
  1314. }
  1315. var req models.AddCygxArticleCommentReq
  1316. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1317. if err != nil {
  1318. br.Msg = "参数解析异常!"
  1319. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1320. return
  1321. }
  1322. if req.ArticleId <= 0 {
  1323. br.Msg = "文章不存在"
  1324. br.ErrMsg = "文章不存在,文章ID错误"
  1325. return
  1326. }
  1327. if req.Content == "" {
  1328. br.Msg = "建议内容不可为空"
  1329. return
  1330. }
  1331. content := req.Content
  1332. if content == "" {
  1333. br.Msg = "留言内容不能为空!"
  1334. return
  1335. }
  1336. //itemToken, err := services.WxGetToken()
  1337. //if err != nil {
  1338. // br.Msg = "GetWxAccessToken Err:" + err.Error()
  1339. // return
  1340. //}
  1341. //if itemToken.AccessToken == "" {
  1342. // br.Msg = "accessToken is empty"
  1343. // return
  1344. //}
  1345. //commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  1346. //if err != nil {
  1347. // br.Msg = "内容校验失败!"
  1348. // br.ErrMsg = "内容校验失败,Err:" + err.Error()
  1349. // return
  1350. //}
  1351. //if commerr.ErrCode != 0 {
  1352. // br.Msg = "内容违规,请重新提交!"
  1353. // br.ErrMsg = "内容违规,Err:" + commerr.ErrMSG
  1354. // return
  1355. //}
  1356. articleId := req.ArticleId
  1357. articleInfo, errInfo := models.GetArticleDetailById(articleId)
  1358. if articleInfo == nil {
  1359. br.Msg = "操作失败"
  1360. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  1361. return
  1362. }
  1363. if errInfo != nil {
  1364. br.Msg = "操作失败"
  1365. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1366. return
  1367. }
  1368. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  1369. if err != nil {
  1370. br.Msg = "提交失败!"
  1371. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1372. return
  1373. }
  1374. if companyDetail == nil {
  1375. br.Msg = "提交失败!"
  1376. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  1377. return
  1378. }
  1379. item := models.CygxArticleComment{
  1380. UserId: user.UserId,
  1381. ArticleId: req.ArticleId,
  1382. CreateTime: time.Now(),
  1383. Mobile: user.Mobile,
  1384. Email: user.Email,
  1385. CompanyId: user.CompanyId,
  1386. CompanyName: companyDetail.CompanyName,
  1387. Content: content,
  1388. Title: articleInfo.Title,
  1389. }
  1390. _, err = models.AddArticleComment(&item)
  1391. if err != nil {
  1392. br.Msg = "提交失败"
  1393. br.ErrMsg = "提交留言失败,Err:" + err.Error()
  1394. return
  1395. }
  1396. services.SendCommentWxTemplateMsg(req, user, articleInfo)
  1397. br.Ret = 200
  1398. br.Success = true
  1399. br.Msg = "提交成功"
  1400. }