home.go 20 KB

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