activity.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. package yb
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "hongze/hz_crm_api/controllers"
  7. "hongze/hz_crm_api/models"
  8. "hongze/hz_crm_api/models/yb"
  9. "hongze/hz_crm_api/models/yb/request"
  10. ybResp "hongze/hz_crm_api/models/yb/response"
  11. ybService "hongze/hz_crm_api/services/yb"
  12. "hongze/hz_crm_api/utils"
  13. "strings"
  14. "time"
  15. )
  16. // ActivityController 研报活动模块
  17. type ActivityController struct {
  18. controllers.BaseAuthController
  19. }
  20. // List
  21. // @Title 获取活动列表
  22. // @Description 获取活动列表
  23. // @Param Keyword query string false "搜索关键字"
  24. // @Param ActivityTypeIds query string false "活动类别ids,多个用英文逗号分割"
  25. // @Param ActiveStatus query int8 false "活动进行状态,枚举值:1:未开始;2:进行中;3:已结束"
  26. // @Param PublishStatus query int8 false "活动发布状态,枚举值:-1:全部;0:未发布;1:已发布"
  27. // @Param StartDate query string false "活动开始日期,格式:2021-11-09"
  28. // @Param EndDate query string false "活动结束日期,格式:2021-11-10"
  29. // @Success 200 {object} []yb.ListResp
  30. // @router /activity/list [get]
  31. func (this *ActivityController) List() {
  32. br := new(models.BaseResponse).Init()
  33. defer func() {
  34. this.Data["json"] = br
  35. this.ServeJSON()
  36. }()
  37. sysUser := this.SysUser
  38. if sysUser == nil {
  39. br.Msg = "请登录"
  40. br.ErrMsg = "请登录,SysUser Is Empty"
  41. br.Ret = 408
  42. return
  43. }
  44. keyword := this.GetString("Keyword")
  45. activityTypeIds := this.GetString("ActivityTypeIds", "")
  46. activeStatus, _ := this.GetInt("ActiveStatus", 0)
  47. publishStatus, _ := this.GetInt("PublishStatus", 0)
  48. startDate := this.GetString("StartDate")
  49. endDate := this.GetString("EndDate")
  50. pageSize, _ := this.GetInt("PageSize")
  51. currentIndex, _ := this.GetInt("CurrentIndex")
  52. var startSize int
  53. if pageSize <= 0 {
  54. pageSize = utils.PageSize20
  55. }
  56. if currentIndex <= 0 {
  57. currentIndex = 1
  58. }
  59. startSize = paging.StartIndex(currentIndex, pageSize)
  60. condition := ""
  61. pars := make([]interface{}, 0)
  62. //关键字
  63. if keyword != "" {
  64. condition += ` AND activity_name LIKE '%` + keyword + `%' `
  65. }
  66. //活动类别ids
  67. if activityTypeIds != "" {
  68. condition += ` AND activity_type_id IN (` + activityTypeIds + `)`
  69. }
  70. //活动开始与否状态
  71. order := ""
  72. if activeStatus > 0 {
  73. nowTime := time.Now().Format(utils.FormatDateTime)
  74. //1:未开始;2:进行中;3:已结束"
  75. switch activeStatus {
  76. case 1:
  77. condition += ` AND start_time > ? `
  78. pars = append(pars, nowTime)
  79. case 2:
  80. condition += ` AND start_time <= ? and end_time >= ? `
  81. pars = append(pars, nowTime, nowTime)
  82. order = " start_time DESC"
  83. case 3:
  84. condition += ` AND end_time < ? `
  85. pars = append(pars, nowTime)
  86. order = " start_time DESC"
  87. }
  88. }
  89. //活动是否发布
  90. if publishStatus >= 0 {
  91. condition += ` AND publish_status = ? `
  92. pars = append(pars, publishStatus)
  93. }
  94. //活动时间
  95. if startDate != "" && endDate != "" {
  96. condition += ` AND start_time >= ? and end_time <= ?`
  97. pars = append(pars, startDate+" 00:00:00", endDate+" 23:59:59")
  98. }
  99. // 获取所有的分类
  100. total, list, err := yb.GetList(condition, order, pars, startSize, pageSize)
  101. if err != nil {
  102. br.Msg = "获取活动列表失败!"
  103. br.ErrMsg = "获取活动列表失败,Err:" + err.Error()
  104. return
  105. }
  106. if len(list) > 0 {
  107. activityIdList := make([]string, 0)
  108. for _, v := range list {
  109. activityIdList = append(activityIdList, fmt.Sprint(v.ActivityId))
  110. }
  111. //音频文件列表
  112. voiceList, tmpErr := yb.GetVoiceListByActivityIds(strings.Join(activityIdList, ","))
  113. if tmpErr != nil {
  114. br.Msg = "获取失败"
  115. br.ErrMsg = "获取音频失败,Err:" + tmpErr.Error()
  116. return
  117. }
  118. activityVoiceMap := make(map[int][]*yb.ActivityVoice)
  119. for _, voice := range voiceList {
  120. tmpVoiceList, ok := activityVoiceMap[voice.ActivityId]
  121. if !ok {
  122. tmpVoiceList = make([]*yb.ActivityVoice, 0)
  123. }
  124. activityVoiceMap[voice.ActivityId] = append(tmpVoiceList, voice)
  125. }
  126. //海报文件列表
  127. posterList, tmpErr := yb.GetPosterListByActivityIds(strings.Join(activityIdList, ","))
  128. if tmpErr != nil {
  129. br.Msg = "获取失败"
  130. br.ErrMsg = "获取海报失败,Err:" + tmpErr.Error()
  131. return
  132. }
  133. activityPosterMap := make(map[int][]*yb.ActivityPoster)
  134. for _, poster := range posterList {
  135. tmpPosterList, ok := activityPosterMap[poster.ActivityId]
  136. if !ok {
  137. tmpPosterList = make([]*yb.ActivityPoster, 0)
  138. }
  139. activityPosterMap[poster.ActivityId] = append(tmpPosterList, poster)
  140. }
  141. //权限文件列表
  142. permissionList, tmpErr := yb.GetPermissionListByActivityIds(strings.Join(activityIdList, ","))
  143. if tmpErr != nil {
  144. br.Msg = "获取失败"
  145. br.ErrMsg = "获取海报失败,Err:" + tmpErr.Error()
  146. return
  147. }
  148. activityPermissionMap := make(map[int][]*yb.ActivityPermission)
  149. for _, activityPermission := range permissionList {
  150. tmpPermissionList, ok := activityPermissionMap[activityPermission.ActivityId]
  151. if !ok {
  152. tmpPermissionList = make([]*yb.ActivityPermission, 0)
  153. }
  154. activityPermissionMap[activityPermission.ActivityId] = append(tmpPermissionList, activityPermission)
  155. }
  156. for _, activity := range list {
  157. // 音频文件
  158. if voiceList, ok := activityVoiceMap[activity.ActivityId]; ok {
  159. activity.VoiceList = voiceList
  160. }
  161. //海报文件
  162. if posterList, ok := activityPosterMap[activity.ActivityId]; ok {
  163. activity.PosterList = posterList
  164. }
  165. //权限列表
  166. if permissionList, ok := activityPermissionMap[activity.ActivityId]; ok {
  167. activity.PermissionList = permissionList
  168. }
  169. }
  170. }
  171. page := paging.GetPaging(currentIndex, pageSize, total)
  172. resp := ybResp.ListResp{
  173. List: list,
  174. Paging: page,
  175. }
  176. br.Ret = 200
  177. br.Success = true
  178. br.Msg = "获取成功"
  179. br.Data = resp
  180. }
  181. // Add
  182. // @Title 新增活动
  183. // @Description 新增活动接口
  184. // @Param request body request.AddActivityReq true "type json string"
  185. // @Success 200 {object} response.AddContractResp
  186. // @router /activity/add [post]
  187. func (this *ActivityController) Add() {
  188. br := new(models.BaseResponse).Init()
  189. defer func() {
  190. this.Data["json"] = br
  191. this.ServeJSON()
  192. }()
  193. sysUser := this.SysUser
  194. if sysUser == nil {
  195. br.Msg = "请登录"
  196. br.ErrMsg = "请登录,SysUser Is Empty"
  197. br.Ret = 408
  198. return
  199. }
  200. var req request.AddActivityReq
  201. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  202. if err != nil {
  203. br.Msg = "参数解析异常!"
  204. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  205. return
  206. }
  207. if req.ActivityTypeId <= 0 {
  208. br.Msg = "活动类型ID有误!"
  209. br.ErrMsg = "活动类型ID有误!"
  210. return
  211. }
  212. if req.ActivityName == "" {
  213. br.Msg = "活动标题不能为空!"
  214. br.ErrMsg = "活动标题不能为空!"
  215. return
  216. }
  217. if req.Speaker == "" {
  218. br.Msg = "活动主讲人不能为空!"
  219. br.ErrMsg = "活动主讲人不能为空!"
  220. return
  221. }
  222. startTime, err := time.ParseInLocation(utils.FormatDateTime, req.StartTime, time.Local)
  223. if err != nil {
  224. br.Msg = "活动开始日期转换失败!"
  225. br.ErrMsg = "活动开始日期转换失败,Err:" + err.Error()
  226. return
  227. }
  228. endTime, err := time.ParseInLocation(utils.FormatDateTime, req.EndTime, time.Local)
  229. if err != nil {
  230. br.Msg = "活动结束日期转换失败!"
  231. br.ErrMsg = "活动结束日期转换失败,Err:" + err.Error()
  232. return
  233. }
  234. /*now := time.Now()
  235. if now.After(startTime) {
  236. br.Msg = "活动时间不允许小于当前时间!"
  237. br.ErrMsg = "活动时间不允许小于当前时间!"
  238. return
  239. }*/
  240. if startTime.After(endTime) {
  241. br.Msg = "活动结束时间不允许小于开始时间!"
  242. br.ErrMsg = "活动结束时间不允许小于开始时间!"
  243. return
  244. }
  245. allowEndTime := startTime.Add(30 * time.Minute)
  246. if allowEndTime.After(endTime) {
  247. br.Msg = "活动结束时间至少要在开始时间半个小时之后!"
  248. br.ErrMsg = "活动结束时间至少要在开始时间半个小时之后!"
  249. return
  250. }
  251. activityInfo, err := ybService.AddActivity(req, sysUser.AdminId)
  252. if err != nil {
  253. br.Msg = "保存活动失败!"
  254. br.ErrMsg = "保存活动失败,Err:" + err.Error()
  255. return
  256. }
  257. msg := "添加成功"
  258. br.Ret = 200
  259. br.Success = true
  260. br.Msg = msg
  261. br.Data = ybResp.AddActivityResp{
  262. ActivityId: activityInfo.ActivityId,
  263. }
  264. }
  265. // Edit
  266. // @Title 编辑活动
  267. // @Description 编辑活动接口
  268. // @Param request body request.EditActivityReq true "type json string"
  269. // @Success 200 {object} 保存成功
  270. // @router /activity/edit [post]
  271. func (this *ActivityController) Edit() {
  272. br := new(models.BaseResponse).Init()
  273. defer func() {
  274. this.Data["json"] = br
  275. this.ServeJSON()
  276. }()
  277. sysUser := this.SysUser
  278. if sysUser == nil {
  279. br.Msg = "请登录"
  280. br.ErrMsg = "请登录,SysUser Is Empty"
  281. br.Ret = 408
  282. return
  283. }
  284. var req request.EditActivityReq
  285. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  286. if err != nil {
  287. br.Msg = "参数解析异常!"
  288. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  289. return
  290. }
  291. if req.ActivityId <= 0 {
  292. br.Msg = "活动ID异常!"
  293. br.ErrMsg = "活动ID异常"
  294. return
  295. }
  296. _, err, errMsg := ybService.EditActivity(req)
  297. if err != nil {
  298. br.Msg = "保存活动失败!" + errMsg
  299. br.ErrMsg = "保存活动失败,Err:" + err.Error()
  300. return
  301. }
  302. msg := "保存成功"
  303. br.Ret = 200
  304. br.Success = true
  305. br.Msg = msg
  306. }
  307. // Publish
  308. // @Title 发布活动
  309. // @Description 发布活动接口
  310. // @Param request body request.PublishActivityReq true "type json string"
  311. // @Success 200 {object} 发布成功
  312. // @router /activity/publish [post]
  313. func (this *ActivityController) Publish() {
  314. br := new(models.BaseResponse).Init()
  315. defer func() {
  316. this.Data["json"] = br
  317. this.ServeJSON()
  318. }()
  319. sysUser := this.SysUser
  320. if sysUser == nil {
  321. br.Msg = "请登录"
  322. br.ErrMsg = "请登录,SysUser Is Empty"
  323. br.Ret = 408
  324. return
  325. }
  326. var req request.PublishActivityReq
  327. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  328. if err != nil {
  329. br.Msg = "参数解析异常!"
  330. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  331. return
  332. }
  333. if req.ActivityId <= 0 {
  334. br.Msg = "活动ID异常!"
  335. br.ErrMsg = "活动ID异常"
  336. return
  337. }
  338. _, err, errMsg := ybService.PublishActivity(req.ActivityId)
  339. if err != nil {
  340. br.Msg = "发布活动失败!" + errMsg
  341. br.ErrMsg = "发布活动失败,Err:" + err.Error()
  342. return
  343. }
  344. msg := "发布成功"
  345. br.Ret = 200
  346. br.Success = true
  347. br.Msg = msg
  348. }
  349. // UnPublish
  350. // @Title 取消发布活动
  351. // @Description 取消发布活动接口
  352. // @Param request body request.PublishActivityReq true "type json string"
  353. // @Success 200 {object} 取消发布成功
  354. // @router /activity/unpublish [post]
  355. func (this *ActivityController) UnPublish() {
  356. br := new(models.BaseResponse).Init()
  357. defer func() {
  358. this.Data["json"] = br
  359. this.ServeJSON()
  360. }()
  361. sysUser := this.SysUser
  362. if sysUser == nil {
  363. br.Msg = "请登录"
  364. br.ErrMsg = "请登录,SysUser Is Empty"
  365. br.Ret = 408
  366. return
  367. }
  368. var req request.PublishActivityReq
  369. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  370. if err != nil {
  371. br.Msg = "参数解析异常!"
  372. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  373. return
  374. }
  375. if req.ActivityId <= 0 {
  376. br.Msg = "活动ID异常!"
  377. br.ErrMsg = "活动ID异常"
  378. return
  379. }
  380. _, err, errMsg := ybService.UnPublishActivity(req.ActivityId)
  381. if err != nil {
  382. br.Msg = "取消发布活动失败!" + errMsg
  383. br.ErrMsg = "取消发布活动失败,Err:" + err.Error()
  384. return
  385. }
  386. msg := "取消发布成功"
  387. br.Ret = 200
  388. br.Success = true
  389. br.Msg = msg
  390. }
  391. // DelPublish
  392. // @Title 删除活动
  393. // @Description 删除活动接口
  394. // @Param request body request.PublishActivityReq true "type json string"
  395. // @Success 200 {object} 删除成功
  396. // @router /activity/del_publish [post]
  397. func (this *ActivityController) DelPublish() {
  398. br := new(models.BaseResponse).Init()
  399. defer func() {
  400. this.Data["json"] = br
  401. this.ServeJSON()
  402. }()
  403. sysUser := this.SysUser
  404. if sysUser == nil {
  405. br.Msg = "请登录"
  406. br.ErrMsg = "请登录,SysUser Is Empty"
  407. br.Ret = 408
  408. return
  409. }
  410. var req request.PublishActivityReq
  411. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  412. if err != nil {
  413. br.Msg = "参数解析异常!"
  414. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  415. return
  416. }
  417. if req.ActivityId <= 0 {
  418. br.Msg = "活动ID异常!"
  419. br.ErrMsg = "活动ID异常"
  420. return
  421. }
  422. _, err, errMsg := ybService.DelActivity(req.ActivityId)
  423. if err != nil {
  424. br.Msg = "删除活动失败!" + errMsg
  425. br.ErrMsg = "删除活动失败,Err:" + err.Error()
  426. return
  427. }
  428. msg := "删除成功"
  429. br.Ret = 200
  430. br.Success = true
  431. br.Msg = msg
  432. }
  433. // ReportList
  434. // @Title 获取报告列表
  435. // @Description 获取报告列表
  436. // @Param Keyword query string false "搜索关键字"
  437. // @Param StartDate query string false "开始日期"
  438. // @Param EndDate query string false "结束日期"
  439. // @Param ReportType query string false "报告类型,枚举值:day,week,two_week,month,other"
  440. // @Success 200 {object} yb.ResearchReportListResp
  441. // @router /report/list [get]
  442. func (this *ActivityController) ReportList() {
  443. br := new(models.BaseResponse).Init()
  444. defer func() {
  445. this.Data["json"] = br
  446. this.ServeJSON()
  447. }()
  448. sysUser := this.SysUser
  449. if sysUser == nil {
  450. br.Msg = "请登录"
  451. br.ErrMsg = "请登录,SysUser Is Empty"
  452. br.Ret = 408
  453. return
  454. }
  455. keyword := this.GetString("Keyword")
  456. //startDate := this.GetString("StartDate")
  457. //endDate := this.GetString("EndDate")
  458. reportType := this.GetString("ReportType")
  459. classifyId, _ := this.GetInt("ClassifyId")
  460. pageSize, _ := this.GetInt("PageSize")
  461. currentIndex, _ := this.GetInt("CurrentIndex")
  462. var startSize int
  463. if pageSize <= 0 {
  464. pageSize = utils.PageSize20
  465. }
  466. if currentIndex <= 0 {
  467. currentIndex = 1
  468. }
  469. startSize = utils.StartIndex(currentIndex, pageSize)
  470. var condition string
  471. var pars []interface{}
  472. // 报告类型: 晨报, 周报, 其他电话会报告
  473. reportTypeArr := []string{"day", "week", "tel"}
  474. if !utils.InArrayByStr(reportTypeArr, reportType) {
  475. br.Msg = "报告类型有误"
  476. return
  477. }
  478. if reportType == "tel" && classifyId == 0 {
  479. br.Msg = "请选择报告类型"
  480. return
  481. }
  482. total := 0
  483. list := make([]*models.ResearchReportList, 0)
  484. // 晨报-查询老报告
  485. //if reportType == "day" {
  486. // if keyword != `` {
  487. // condition += ` and research_report_name like '%` + keyword + `%' `
  488. // }
  489. // if startDate != `` {
  490. // condition += ` and created_time >= ? `
  491. // pars = append(pars, startDate+" 00:00:00")
  492. // }
  493. // if endDate != `` {
  494. // condition += ` and created_time <= ? `
  495. // pars = append(pars, endDate+" 23:59:59")
  496. // }
  497. // if reportType != `` {
  498. // condition += ` and type = ? `
  499. // pars = append(pars, reportType)
  500. // }
  501. // oldTotal, reportList, err := models.GetResearchReportList(condition, pars, startSize, pageSize)
  502. // if err != nil {
  503. // br.Msg = "获取报告列表失败!"
  504. // br.ErrMsg = "获取报告列表失败,Err:" + err.Error()
  505. // return
  506. // }
  507. // total = oldTotal
  508. //
  509. // //环境不同,阅读报告的地址不同
  510. // linkUrl := `https://details.hzinsights.com/ficcReportDetail?research_report_id=`
  511. // if utils.RunMode == `debug` {
  512. // linkUrl = `http://advisoryadmin.brilliantstart.cn/xcx_h5/ficcReportDetail?research_report_id=`
  513. // }
  514. // for _, report := range reportList {
  515. // report.LinkUrl = fmt.Sprint(linkUrl, report.ResearchReportId)
  516. // }
  517. // list = reportList
  518. //}
  519. if keyword != "" {
  520. condition += ` AND title LIKE '%` + keyword + `%' `
  521. }
  522. if reportType == "week" || reportType == "day" {
  523. condition += ` AND state = 2 AND has_chapter = 1 AND chapter_type = ? AND old_report_id = 0 `
  524. pars = append(pars, reportType)
  525. } else {
  526. // 其他电话会报告暂时支持同步过来的报告
  527. condition += ` AND state = 2`
  528. // 此处仅查询二级分类中含电话会的报告, 一级分类可能含非电话会二级分类, 所以不用一级分类作为报告的查询条件
  529. var telCond, telOrder string
  530. var telPars []interface{}
  531. telCond += ` AND parent_id = ? AND has_teleconference = 1`
  532. telPars = append(telPars, classifyId)
  533. telList, e := models.GetClassifyByCondition(telCond, telOrder, telPars)
  534. if e != nil {
  535. br.Msg = "获取报告列表失败"
  536. br.ErrMsg = "获取其他报告电话会分类失败, Err: " + e.Error()
  537. return
  538. }
  539. telClassifyIds := make([]int, 0)
  540. for i := range telList {
  541. telClassifyIds = append(telClassifyIds, telList[i].Id)
  542. }
  543. if len(telClassifyIds) > 0 {
  544. condition += ` AND classify_id_second IN (` + utils.GetOrmInReplace(len(telClassifyIds)) + `)`
  545. pars = append(pars, telClassifyIds)
  546. } else {
  547. // 无电话会二级分类理应查不出任何数据
  548. condition += ` AND 1 = 2`
  549. }
  550. }
  551. newTotal, reportList, e := models.GetPageReportList(condition, pars, startSize, pageSize)
  552. if e != nil {
  553. br.Msg = "获取新报告列表失败"
  554. br.ErrMsg = "获取新报告列表失败, Err:" + e.Error()
  555. return
  556. }
  557. total = newTotal
  558. linkUrl := `https://details.hzinsights.com/xcx_h5/hzyb/report/detail?reportId=`
  559. if utils.RunMode == `debug` {
  560. linkUrl = `http://xcxh5test.hzinsights.com/xcx_h5/hzyb/report/detail?reportId=`
  561. }
  562. for _, v := range reportList {
  563. reportDate, e := time.Parse(utils.FormatDateTime, v.PublishTime)
  564. if e != nil {
  565. return
  566. }
  567. item := &models.ResearchReportList{
  568. ResearchReportId: v.Id,
  569. ResearchReportName: v.Title,
  570. ResearchReportDate: reportDate,
  571. Type: reportType,
  572. Author: v.Author,
  573. ReportVariety: v.ClassifyNameFirst,
  574. IsSendedMsg: int8(v.MsgIsSend),
  575. Periods: v.Stage,
  576. Status: "report",
  577. Enabled: 1,
  578. CreatedTime: v.CreateTime,
  579. LastUpdatedTime: v.ModifyTime,
  580. LinkUrl: fmt.Sprint(linkUrl, v.Id),
  581. }
  582. list = append(list, item)
  583. }
  584. page := paging.GetPaging(currentIndex, pageSize, total)
  585. resp := ybResp.ResearchReportListResp{
  586. List: list,
  587. Paging: page,
  588. }
  589. br.Ret = 200
  590. br.Success = true
  591. br.Msg = "获取成功"
  592. br.Data = resp
  593. }
  594. // Detail
  595. // @Title 活动详情
  596. // @Description 活动详情
  597. // @Param activityId query int true "活动ID"
  598. // @Success 200 {object} yb.Activity 获取成功
  599. // @router /activity/detail [get]
  600. func (this *ActivityController) Detail() {
  601. br := new(models.BaseResponse).Init()
  602. defer func() {
  603. this.Data["json"] = br
  604. this.ServeJSON()
  605. }()
  606. activityId, _ := this.GetInt("activityId", 0)
  607. if activityId <= 0 {
  608. br.Msg = "活动ID异常!"
  609. br.ErrMsg = "活动ID异常"
  610. return
  611. }
  612. activity, err := yb.GetById(activityId)
  613. if err != nil {
  614. if err.Error() == utils.ErrNoRow() {
  615. br.Msg = "活动信息不存在"
  616. br.ErrMsg = "活动信息不存在"
  617. return
  618. }
  619. br.Msg = "活动详情获取失败"
  620. br.ErrMsg = "活动详情获取失败,Err:" + err.Error()
  621. return
  622. }
  623. posterList, err := yb.GetPosterListByActivityId(activityId)
  624. if err != nil {
  625. br.Msg = "活动海报列表获取失败"
  626. br.ErrMsg = "活动海报列表获取失败,Err:" + err.Error()
  627. return
  628. }
  629. br.Ret = 200
  630. br.Success = true
  631. br.Msg = "获取成功"
  632. br.Data = ybResp.ActivityDetailResp{
  633. Activity: activity,
  634. Poster: posterList,
  635. }
  636. }