home.go 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. package controllers
  2. import (
  3. "github.com/rdlucklib/rdluck_tools/paging"
  4. "hongze/hongze_clpt/models"
  5. "hongze/hongze_clpt/services"
  6. "hongze/hongze_clpt/utils"
  7. "strconv"
  8. "strings"
  9. "time"
  10. )
  11. type HomeController struct {
  12. BaseAuthController
  13. }
  14. type BaseHomeController struct {
  15. BaseCommonController
  16. }
  17. type MobileHomeController struct {
  18. BaseAuthMobileController
  19. }
  20. // @Title 首页列表接口
  21. // @Description 首页列表接口
  22. // @Param PageSize query int true "每页数据条数"
  23. // @Param CurrentIndex query int true "当前页页码,从1开始"
  24. // @Param ChartPermissionId query int true "品类id,最新传0"
  25. // @Param CtagId query int true "图表子类ID"
  26. // @Param ListType query int true "列表类型,1最新,2 纪要 ,3图表 默认1"
  27. // @Success 200 {object} models.HomeArtAndChartListResp
  28. // @router /list [get]
  29. func (this *MobileHomeController) List() {
  30. br := new(models.BaseResponse).Init()
  31. defer func() {
  32. this.Data["json"] = br
  33. this.ServeJSON()
  34. }()
  35. user := this.User
  36. if user == nil {
  37. br.Msg = "请登录"
  38. br.ErrMsg = "请登录,用户信息为空"
  39. br.Ret = 408
  40. return
  41. }
  42. pageSize, _ := this.GetInt("PageSize")
  43. currentIndex, _ := this.GetInt("CurrentIndex")
  44. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  45. ctagId, _ := this.GetInt("CtagId")
  46. listType, _ := this.GetInt("ListType")
  47. var startSize int
  48. if pageSize <= 0 {
  49. pageSize = utils.PageSize20
  50. }
  51. if currentIndex <= 0 {
  52. currentIndex = 1
  53. }
  54. if listType <= 0 {
  55. listType = 1
  56. }
  57. startSize = paging.StartIndex(currentIndex, pageSize)
  58. var condition string
  59. var pars []interface{}
  60. var total, chartTotal int
  61. resp := new(models.HomeArtAndChartListResp)
  62. page := paging.GetPaging(currentIndex, pageSize, total)
  63. var chartList []*models.HomeChartListResp
  64. var err error
  65. if listType == 1 {
  66. if currentIndex <= 2 {
  67. listCtagId := [10]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
  68. var chartIds string
  69. for _, v := range listCtagId {
  70. chartListTwo, err := models.GetChartList(`AND ctag_id = `+strconv.Itoa(v), pars, 0, 2)
  71. if err != nil {
  72. br.Msg = "获取信息失败"
  73. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  74. return
  75. }
  76. for _, vChart := range chartListTwo {
  77. chartIds += strconv.Itoa(vChart.ChartId) + ","
  78. }
  79. }
  80. chartIds = strings.TrimRight(chartIds, ",")
  81. condition += ` AND chart_id IN (` + chartIds + `) `
  82. chartList, err = models.GetChartList(condition, pars, startSize, pageSize)
  83. if err != nil {
  84. br.Msg = "获取信息失败"
  85. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  86. return
  87. }
  88. }
  89. } else if listType == 3 {
  90. if chartPermissionId > 0 {
  91. condition += ` AND a.ptag_id =? `
  92. pars = append(pars, chartPermissionId)
  93. }
  94. if ctagId > 0 {
  95. condition += ` AND a.ctag_id =? `
  96. pars = append(pars, ctagId)
  97. }
  98. chartList, err = models.GetChartList(condition, pars, startSize, pageSize)
  99. if err != nil {
  100. br.Msg = "获取信息失败"
  101. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  102. return
  103. }
  104. chartTotal, err = models.GetChartCount(condition, pars)
  105. if err != nil {
  106. br.Msg = "获取信息失败"
  107. br.Msg = "获取帖子总数失败,Err:" + err.Error()
  108. return
  109. }
  110. }
  111. for k, v := range chartList {
  112. if v.PtagName != "" {
  113. chartList[k].CtagNamePc = v.PtagName
  114. }
  115. if v.CtagName != "" {
  116. chartList[k].CtagNamePc += "," + v.CtagName
  117. }
  118. if v.PtagNameTwo != "" {
  119. chartList[k].CtagNamePc += "," + v.PtagNameTwo
  120. }
  121. if v.CtagNameTwo != "" {
  122. chartList[k].CtagNamePc += "," + v.CtagNameTwo
  123. }
  124. chartList[k].IsNeedJump = true
  125. chartList[k].Source = 2
  126. if v.PtagName != "" {
  127. labelItem := new(models.LabelList)
  128. labelItem.PtagName = v.PtagName
  129. labelItem.CtagName = v.CtagName
  130. chartList[k].LabelList = append(chartList[k].LabelList, labelItem)
  131. }
  132. if v.PtagNameTwo != "" {
  133. labelItemTwo := new(models.LabelList)
  134. labelItemTwo.PtagName = v.PtagNameTwo
  135. labelItemTwo.CtagName = v.CtagNameTwo
  136. chartList[k].LabelList = append(chartList[k].LabelList, labelItemTwo)
  137. }
  138. if len(chartList[k].LabelList) == 0 {
  139. chartList[k].LabelList = make([]*models.LabelList, 0)
  140. }
  141. }
  142. if len(chartList) == 0 {
  143. chartList = make([]*models.HomeChartListResp, 0)
  144. }
  145. resp.ChartList = chartList
  146. if listType != 3 {
  147. userType, _, err := services.GetUserType(user.CompanyId)
  148. if err != nil {
  149. br.Msg = "获取信息失败"
  150. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  151. return
  152. }
  153. condition = ` AND is_summary = 1 `
  154. if chartPermissionId > 0 {
  155. categoryId, err := models.GetCategoryIdHome(chartPermissionId)
  156. if err != nil && err.Error() != utils.ErrNoRow() {
  157. br.Msg = "获取信息失败"
  158. br.ErrMsg = "获取分类权限信息失败,Err:" + err.Error()
  159. return
  160. }
  161. categoryinfo, err := models.GetChartPermissionById(chartPermissionId)
  162. if err != nil {
  163. br.Msg = "获取信息失败"
  164. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  165. return
  166. }
  167. if userType == 1 && strings.Contains(categoryinfo.PermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  168. resp.Paging = page
  169. br.Ret = 200
  170. br.Success = true
  171. br.Msg = "获取成功"
  172. br.Data = resp
  173. return
  174. }
  175. page = paging.GetPaging(currentIndex, pageSize, total)
  176. if categoryId != "" {
  177. condition += ` AND category_id IN(` + categoryId + `)`
  178. //condition += ` OR ( category_name LIKE '%` + utils.CHART_PERMISSION_NAME_YANXUAN + `%' AND publish_status = 1 AND is_summary = 1 )`
  179. } else {
  180. condition += ` AND category_name LIKE '%` + utils.CHART_PERMISSION_NAME_YANXUAN + `%'`
  181. }
  182. }
  183. //永续客户无法查看研选分类的内容
  184. if userType == 1 {
  185. condition += ` AND category_name NOT LIKE '%` + utils.CHART_PERMISSION_NAME_YANXUAN + `%'`
  186. }
  187. total, err = models.GetHomeCount(condition, pars)
  188. if err != nil {
  189. br.Msg = "获取信息失败"
  190. br.Msg = "获取帖子总数失败,Err:" + err.Error()
  191. return
  192. }
  193. listPublic, err := models.GetHomeListPublic(condition, pars, startSize, pageSize)
  194. if err != nil {
  195. br.Msg = "获取信息失败"
  196. br.Msg = "获取帖子数据失败,Err:" + err.Error()
  197. return
  198. }
  199. listPublic, err = services.HandleArticleCategoryImg(listPublic, user)
  200. if err != nil {
  201. br.Msg = "获取失败"
  202. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  203. return
  204. }
  205. var articleIds []int
  206. for _, v := range listPublic {
  207. articleIds = append(articleIds, v.ArticleId)
  208. }
  209. articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
  210. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
  211. articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
  212. var list []*models.HomeArticle
  213. if len(listPublic) == 0 {
  214. list = make([]*models.HomeArticle, 0)
  215. } else {
  216. for _, v := range listPublic {
  217. list = append(list, &models.HomeArticle{
  218. ArticleId: v.ArticleId,
  219. Title: v.Title,
  220. Annotation: v.Annotation,
  221. Abstract: v.Abstract,
  222. ImgUrlPc: v.ImgUrlPc,
  223. PublishDate: v.PublishDate,
  224. IsResearch: v.IsResearch,
  225. Pv: articleMapPv[v.ArticleId],
  226. IsCollect: articleCollectMap[v.ArticleId],
  227. CollectNum: articleCollectNumMap[v.ArticleId],
  228. })
  229. }
  230. }
  231. resp.List = list
  232. }
  233. if chartTotal > total {
  234. total = chartTotal
  235. }
  236. page = paging.GetPaging(currentIndex, pageSize, total)
  237. resp.Paging = page
  238. br.Ret = 200
  239. br.Success = true
  240. br.Msg = "获取成功"
  241. br.Data = resp
  242. }
  243. // @Title 首页列表接口
  244. // @Description 首页列表接口
  245. // @Param TagIds query string true "标签选择"
  246. // @Param ChartPermissionId query int false "行业id"
  247. // @Param PageSize query int true "每页数据条数"
  248. // @Param CurrentIndex query int true "当前页页码,从1开始"
  249. // @Success 200 {object} models.HomeArtAndChartListResp
  250. // @router /new [get]
  251. func (this *MobileHomeController) NewList() {
  252. br := new(models.BaseResponse).Init()
  253. defer func() {
  254. this.Data["json"] = br
  255. this.ServeJSON()
  256. }()
  257. user := this.User
  258. if user == nil {
  259. br.Msg = "请登录"
  260. br.ErrMsg = "请登录,用户信息为空"
  261. br.Ret = 408
  262. return
  263. }
  264. //uid := user.UserId
  265. pageSize, _ := this.GetInt("PageSize")
  266. currentIndex, _ := this.GetInt("CurrentIndex")
  267. tagIds := this.GetString("TagIds")
  268. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  269. var startSize int
  270. if pageSize <= 0 {
  271. pageSize = utils.PageSize20
  272. }
  273. if currentIndex <= 0 {
  274. currentIndex = 1
  275. }
  276. startSize = paging.StartIndex(currentIndex, pageSize)
  277. var condition string
  278. var conditionInit string
  279. var pars []interface{}
  280. var total int
  281. var err error
  282. resp := new(models.HomeResourceDataListNewResp)
  283. //var articleTypes, activityTypes, industries, subjectNames string
  284. //articleTypeCondSlice := make([]string, 0)
  285. //activityTypesCondSlice := make([]string, 0)
  286. //industriesCondSlice := make([]string, 0)
  287. //subjectNamesSlice := make([]string, 0)
  288. //articleTypeSlice := make([]string, 0)
  289. //if tagIds != "" {
  290. // tags := strings.Split(tagIds, ",")
  291. // for _, tagIdStr := range tags {
  292. // tagId, err := strconv.Atoi(tagIdStr)
  293. // if err != nil {
  294. // br.Msg = "转换失败"
  295. // br.ErrMsg = "tagid转换失败,Err:" + err.Error()
  296. // return
  297. // }
  298. // tagInfo, err := models.GetCygxTagByTagId(tagId)
  299. // if err != nil && err.Error() != utils.ErrNoRow() {
  300. // br.Msg = "获取失败"
  301. // br.ErrMsg = "GetCygxTagByTagId,Err:" + err.Error()
  302. // return
  303. // }
  304. // // 只有AB或CD的情况
  305. // if (tagInfo.ActivityTypes == "" && tagInfo.ArticleTypes == "") || (tagInfo.Industries == "" && tagInfo.SubjectNames == "") {
  306. // if tagInfo.ActivityTypes != "" {
  307. // activityTypes += tagInfo.ActivityTypes + ","
  308. // }
  309. // if tagInfo.ArticleTypes != "" {
  310. // articleTypes += tagInfo.ArticleTypes + ","
  311. // }
  312. // if tagInfo.Industries != "" {
  313. // industries += tagInfo.Industries + ","
  314. // }
  315. // if tagInfo.SubjectNames != "" {
  316. // subjectNames += tagInfo.SubjectNames + ","
  317. // }
  318. // } else {
  319. // // ABCD都有的情况
  320. // // 每一个tag都单独处理
  321. // var articleType, activityType, industry, subjectName string
  322. //
  323. // if tagInfo.ActivityTypes != "" {
  324. // activityType = tagInfo.ActivityTypes
  325. // }
  326. // if tagInfo.ArticleTypes != "" {
  327. // articleType = tagInfo.ArticleTypes
  328. // }
  329. // if tagInfo.Industries != "" {
  330. // industry = tagInfo.Industries
  331. // }
  332. // if tagInfo.SubjectNames != "" {
  333. // subjectName = tagInfo.SubjectNames
  334. // }
  335. // articleTypeCond := ``
  336. // var articleTypeStr string
  337. // if articleType != "" {
  338. // articleTypeSlice := strings.Split(articleType, ",")
  339. // newArticleTypeSlice := make([]string, 0)
  340. // for _, s := range articleTypeSlice {
  341. // newArticleTypeSlice = append(newArticleTypeSlice, "'"+s+"'")
  342. // }
  343. // articleTypeStr = strings.Join(newArticleTypeSlice, ",")
  344. // articleTypeStr = strings.TrimRight(articleTypeStr, ",")
  345. // articleTypeCond += ` AND (art.sub_category_name In (` + articleTypeStr + `) OR (art.article_type_name In (` + articleTypeStr + `) AND art.article_type_name <> '路演精华' AND art.article_type_id <> 0 ) ) `
  346. // }
  347. // activityTypesCond := ``
  348. // if activityType != "" {
  349. // activityTypeSlice := strings.Split(activityType, ",")
  350. // newActivityTypeSlice := make([]string, 0)
  351. // for _, s := range activityTypeSlice {
  352. // newActivityTypeSlice = append(newActivityTypeSlice, "'"+s+"'")
  353. // }
  354. // activityTypeStr := strings.Join(newActivityTypeSlice, ",")
  355. // activityTypeStr = strings.TrimRight(activityTypeStr, ",")
  356. // activityTypesCond += ` AND act.activity_type_name In (` + activityTypeStr + `) `
  357. // }
  358. // industriesCond := ``
  359. // var industryStr string
  360. // if industry != "" {
  361. // industrieSlice := strings.Split(industry, ",")
  362. // newIndustrieSlice := make([]string, 0)
  363. // for _, s := range industrieSlice {
  364. // newIndustrieSlice = append(newIndustrieSlice, "'"+s+"'")
  365. // }
  366. // industryStr = strings.Join(newIndustrieSlice, ",")
  367. // industryStr = strings.TrimRight(industryStr, ",")
  368. // industriesCond += ` AND im.industry_name In (` + industryStr + `) `
  369. // }
  370. // subjectNamesCond := ``
  371. // var subjectNameStr string
  372. // if subjectName != "" {
  373. // subjectNameSlice := strings.Split(subjectName, ",")
  374. // newSubjectNameSlice := make([]string, 0)
  375. // for _, s := range subjectNameSlice {
  376. // newSubjectNameSlice = append(newSubjectNameSlice, "'"+s+"'")
  377. // }
  378. // subjectNameStr = strings.Join(newSubjectNameSlice, ",")
  379. // subjectNameStr = strings.TrimRight(subjectNameStr, ",")
  380. // subjectNamesCond += ` AND cis.subject_name In (` + subjectNameStr + `) `
  381. // }
  382. // articleTypeCondSlice = append(articleTypeCondSlice, articleTypeCond)
  383. // activityTypesCondSlice = append(activityTypesCondSlice, activityTypesCond)
  384. // industriesCondSlice = append(industriesCondSlice, industryStr)
  385. // subjectNamesSlice = append(subjectNamesSlice, subjectNameStr)
  386. // articleTypeSlice = append(articleTypeSlice, articleType)
  387. // }
  388. //
  389. // }
  390. //}
  391. //
  392. //// 先拿abdc都有的tag取合集的ids。。。
  393. //soloTagArticleIds, soloTagActivityIds, soloMmIds, err := models.GetCygxCygxArticleListByConditionSoloTag(articleTypeCondSlice, activityTypesCondSlice, industriesCondSlice, subjectNamesSlice, articleTypeSlice)
  394. //if err != nil && err.Error() != utils.ErrNoRow() {
  395. // br.Msg = "获取失败"
  396. // br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  397. // return
  398. //}
  399. //
  400. //articleTypes = strings.TrimRight(articleTypes, ",")
  401. //activityTypes = strings.TrimRight(activityTypes, ",")
  402. //industries = strings.TrimRight(industries, ",")
  403. //subjectNames = strings.TrimRight(subjectNames, ",")
  404. //
  405. //articleTypesCond := ``
  406. //var articleTypeStr string
  407. //if articleTypes != "" {
  408. // articleTypeSlice := strings.Split(articleTypes, ",")
  409. // newArticleTypeSlice := make([]string, 0)
  410. // for _, s := range articleTypeSlice {
  411. // newArticleTypeSlice = append(newArticleTypeSlice, "'"+s+"'")
  412. // }
  413. // articleTypeStr = strings.Join(newArticleTypeSlice, ",")
  414. // articleTypeStr = strings.TrimRight(articleTypeStr, ",")
  415. // articleTypesCond += ` AND (art.sub_category_name In (` + articleTypeStr + `) OR (art.article_type_name In (` + articleTypeStr + `) AND art.article_type_name <> '路演精华' AND art.article_type_id <> 0 ) ) `
  416. //}
  417. //activityTypesCond := ``
  418. //if activityTypes != "" {
  419. // activityTypeSlice := strings.Split(activityTypes, ",")
  420. // newActivityTypeSlice := make([]string, 0)
  421. // for _, s := range activityTypeSlice {
  422. // newActivityTypeSlice = append(newActivityTypeSlice, "'"+s+"'")
  423. // }
  424. // activityTypeStr := strings.Join(newActivityTypeSlice, ",")
  425. // activityTypeStr = strings.TrimRight(activityTypeStr, ",")
  426. // activityTypesCond += ` AND act.activity_type_name In (` + activityTypeStr + `) `
  427. //}
  428. //industriesCond := ``
  429. //var industryStr string
  430. //if industries != "" {
  431. // industrieSlice := strings.Split(industries, ",")
  432. // newIndustrieSlice := make([]string, 0)
  433. // for _, s := range industrieSlice {
  434. // newIndustrieSlice = append(newIndustrieSlice, "'"+s+"'")
  435. // }
  436. // industryStr = strings.Join(newIndustrieSlice, ",")
  437. // industryStr = strings.TrimRight(industryStr, ",")
  438. // industriesCond += ` AND im.industry_name In (` + industryStr + `) `
  439. //}
  440. //subjectNamesCond := ``
  441. //var subjectNameStr string
  442. //if subjectNames != "" {
  443. // subjectNameSlice := strings.Split(subjectNames, ",")
  444. // newSubjectNameSlice := make([]string, 0)
  445. // for _, s := range subjectNameSlice {
  446. // newSubjectNameSlice = append(newSubjectNameSlice, "'"+s+"'")
  447. // }
  448. // subjectNameStr = strings.Join(newSubjectNameSlice, ",")
  449. // subjectNameStr = strings.TrimRight(subjectNameStr, ",")
  450. // subjectNamesCond += ` AND cis.subject_name In (` + subjectNameStr + `) `
  451. //}
  452. //
  453. //var tagArticleIds, tagActivityIds, mmIds string
  454. //if articleTypesCond != "" || activityTypesCond != "" || industryStr != "" || subjectNameStr != "" {
  455. // tagArticleIds, tagActivityIds, mmIds, err = models.GetCygxCygxArticleListByCondition(articleTypesCond, activityTypesCond, industryStr, subjectNameStr, articleTypeStr)
  456. // if err != nil && err.Error() != utils.ErrNoRow() {
  457. // br.Msg = "获取失败"
  458. // br.ErrMsg = "获取单个标签ids失败,Err:" + err.Error()
  459. // return
  460. // }
  461. //}
  462. //
  463. //if soloTagArticleIds != "" {
  464. // if tagArticleIds != "" {
  465. // tagArticleIds += "," + soloTagArticleIds
  466. // } else {
  467. // tagArticleIds = soloTagArticleIds
  468. // }
  469. //}
  470. //if soloTagActivityIds != "" {
  471. // if tagActivityIds != "" {
  472. // tagActivityIds += "," + soloTagActivityIds
  473. // } else {
  474. // tagActivityIds = soloTagActivityIds
  475. // }
  476. //}
  477. //if soloMmIds != "" {
  478. // if mmIds != "" {
  479. // mmIds += "," + soloMmIds
  480. // } else {
  481. // mmIds = soloMmIds
  482. // }
  483. //}
  484. if tagIds != "" {
  485. conditionTagIdsInit, err := services.GetConditionInitByTagIds(tagIds)
  486. if err != nil {
  487. br.Msg = "获取失败"
  488. br.ErrMsg = "获取活动权限数据失败,GetConditionInitByTagIds Err:" + err.Error()
  489. return
  490. }
  491. conditionInit += conditionTagIdsInit
  492. }
  493. //行业筛选
  494. if chartPermissionId > 0 {
  495. conditionInit += " AND chart_permission_id = " + strconv.Itoa(chartPermissionId)
  496. }
  497. if tagIds == "" && chartPermissionId == 0 {
  498. //查询近一个月的数据
  499. conditionInit += " AND publish_date > '" + time.Now().AddDate(0, 0, -30).Format(utils.FormatDateTime) + "'"
  500. }
  501. //return
  502. //conditionInit += ` AND source IN ('newchart')`
  503. if user.CompanyId <= 1 {
  504. condition += " AND source IN ('roadshow','article') "
  505. startSize = 0
  506. pageSize = utils.PageSize5
  507. } else {
  508. condition += ` AND source NOT IN ('activity','activityspecial','newchart') ` + conditionInit
  509. //conditionActivity, err := services.GetActivityonditionList(user, "", "", "", "1,2,3", "", 0, 0, "", 0, 1)
  510. conditionActivity, err := services.ActivityConditioninitSql(user, "", 0)
  511. if err != nil && err.Error() != utils.ErrNoRow() {
  512. br.Msg = "获取失败"
  513. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  514. return
  515. }
  516. conditionActivity += ` AND art.publish_status = 1 `
  517. var conditionOrder string
  518. conditionOrder = ` ORDER BY art.activity_time DESC , art.active_state ASC `
  519. conditionActivity += conditionOrder
  520. actPageSize := 200
  521. if tagIds != "" {
  522. actPageSize = 2000
  523. }
  524. listActivity, err := models.GetActivityListHomeNew(conditionActivity, 0, actPageSize)
  525. if err != nil {
  526. br.Msg = "获取失败"
  527. br.ErrMsg = "获取可见活动数据失败,Err:" + err.Error()
  528. return
  529. }
  530. var activityIds []int
  531. for _, v := range listActivity {
  532. activityIds = append(activityIds, v.ActivityId)
  533. }
  534. lenActivityIds := len(activityIds)
  535. listActivitySpecial, _, err := services.GetActivitySpecialList(user, 1, 200, "", "", "")
  536. if err != nil {
  537. br.Msg = "获取失败"
  538. br.ErrMsg = "获取专项调研可见权限失败失败,Err:" + err.Error()
  539. return
  540. }
  541. var activityspecialIds []int
  542. for _, v := range listActivitySpecial {
  543. activityspecialIds = append(activityspecialIds, v.ActivityId)
  544. }
  545. lenActivityspecialIds := len(activityspecialIds)
  546. //if tagIds != "" {
  547. // if tagArticleIds != "" {
  548. // condition = ` AND ((source = 'article' AND source_id IN (` + tagArticleIds + `) ) `
  549. // if mmIds != "" {
  550. // condition += ` OR ( source = 'meetingreviewchapt' AND source_id IN (` + mmIds + `) ) `
  551. // }
  552. // if tagActivityIds != "" && lenActivityIds > 0 {
  553. // condition += ` OR (source = 'activity' AND source_id IN (` + tagActivityIds + `) AND source_id IN (` + utils.GetOrmInReplace(lenActivityIds) + `) )) `
  554. // pars = append(pars, activityIds)
  555. // } else {
  556. // // 无可见活动
  557. // condition += ` OR (source = 'activity' AND source_id IN (0))) `
  558. // }
  559. // } else if tagActivityIds != "" {
  560. // condition = ` AND ((source = 'article' AND source_id IN (0)) `
  561. // if mmIds != "" {
  562. // condition += ` OR ( source = 'meetingreviewchapt' AND source_id IN (` + mmIds + `) ) `
  563. // }
  564. // if tagActivityIds != "" && lenActivityIds > 0 {
  565. // condition += ` OR (source = 'activity' AND source_id IN (` + tagActivityIds + `) AND source_id IN (` + utils.GetOrmInReplace(lenActivityIds) + `))) `
  566. // pars = append(pars, activityIds)
  567. // } else {
  568. // // 无可见活动
  569. // condition += ` OR (source = 'activity' AND source_id IN (0))) `
  570. // }
  571. // } else if mmIds != "" {
  572. // condition = ` AND ( source = 'meetingreviewchapt' AND source_id IN (` + mmIds + `) ) `
  573. // } else {
  574. // condition += ` AND ((source = 'article' AND source_id IN (0)) OR (source = 'activity' AND source_id IN (0))) `
  575. // }
  576. //}
  577. //if lenActivityIds > 0 && tagIds == "" {
  578. if lenActivityIds > 0 {
  579. condition += ` OR ( source = 'activity' AND source_id IN (` + utils.GetOrmInReplace(lenActivityIds) + `) ` + conditionInit + ` ) `
  580. pars = append(pars, activityIds)
  581. }
  582. if lenActivityspecialIds > 0 {
  583. condition += ` OR ( source = 'activityspecial' AND source_id IN (` + utils.GetOrmInReplace(lenActivityspecialIds) + `) ` + conditionInit + ` ) `
  584. pars = append(pars, activityspecialIds)
  585. }
  586. }
  587. //return
  588. total, err = models.GetResourceDataCount(condition, pars)
  589. if err != nil {
  590. br.Msg = "获取失败"
  591. br.ErrMsg = "获取数据总数失败,Err:" + err.Error()
  592. return
  593. }
  594. //return
  595. if user.CompanyId <= 1 {
  596. total = utils.PageSize5
  597. }
  598. page := paging.GetPaging(currentIndex, pageSize, total)
  599. //Source string `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
  600. list, err := services.GetResourceDataList(condition, pars, startSize, pageSize, user)
  601. if err != nil {
  602. br.Msg = "获取失败"
  603. br.ErrMsg = "获取数据列表失败,Err:" + err.Error()
  604. return
  605. }
  606. if len(list) == 0 {
  607. list = make([]*models.CygxResourceDataNewResp, 0)
  608. }
  609. page = paging.GetPaging(currentIndex, pageSize, total)
  610. resp.Paging = page
  611. resp.List = list
  612. br.Ret = 200
  613. br.Success = true
  614. br.Msg = "获取成功"
  615. br.Data = resp
  616. }