morning_meeting.go 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hongze_clpt/models"
  6. "hongze/hongze_clpt/services"
  7. "hongze/hongze_clpt/utils"
  8. "strconv"
  9. "strings"
  10. )
  11. // 晨会精华
  12. type MorningMeetingController struct {
  13. BaseAuthController
  14. }
  15. // @Title 晨会精华汇总列表
  16. // @Description 晨会精华汇总列表接口
  17. // @Param PageSize query int true "每页数据条数"
  18. // @Param CurrentIndex query int true "当前页页码,从1开始"
  19. // @Success Ret=200 {object} cygx.GetCygxTacticsTimeLineResp
  20. // @router /gather/list [get]
  21. func (this *MorningMeetingController) GatherList() {
  22. br := new(models.BaseResponse).Init()
  23. defer func() {
  24. this.Data["json"] = br
  25. this.ServeJSON()
  26. }()
  27. user := this.User
  28. if user == nil {
  29. br.Msg = "请登录"
  30. br.ErrMsg = "请登录,用户信息为空"
  31. br.Ret = 408
  32. return
  33. }
  34. resp := new(models.CygxMorningMeetingGatherListResp)
  35. pageSize, _ := this.GetInt("PageSize")
  36. currentIndex, _ := this.GetInt("CurrentIndex")
  37. var startSize int
  38. if pageSize <= 0 {
  39. pageSize = utils.PageSize20
  40. }
  41. if currentIndex <= 0 {
  42. currentIndex = 1
  43. }
  44. startSize = utils.StartIndex(currentIndex, pageSize)
  45. var condition string
  46. var pars []interface{}
  47. condition += ` AND status = 1 AND meeting_ids != '' `
  48. total, err := models.GetCygxMorningMeetingGatherCount(condition, pars)
  49. if err != nil {
  50. br.Msg = "获取失败"
  51. br.ErrMsg = "获取失败,Err:" + err.Error()
  52. return
  53. }
  54. condition += " ORDER BY publish_time DESC ,id DESC "
  55. list, err := models.GetCygxMorningMeetingGatherList(condition, pars, startSize, pageSize)
  56. if err != nil {
  57. br.Msg = "获取失败"
  58. br.ErrMsg = "获取失败,Err:" + err.Error()
  59. return
  60. }
  61. var meetids string
  62. for _, v := range list {
  63. meetids += v.MeetingIds + ","
  64. }
  65. meetids = strings.TrimRight(meetids, ",")
  66. mapMeetName := make(map[string]string)
  67. if meetids != "" {
  68. pars = make([]interface{}, 0)
  69. condition = ` AND id IN(` + meetids + `) AND status = 1 `
  70. listMeet, err := models.GetCygxMorningMeetingReviewsList(condition, pars, 0, 10000)
  71. if err != nil {
  72. br.Msg = "获取失败"
  73. br.ErrMsg = "获取失败,Err:" + err.Error()
  74. }
  75. for _, v := range listMeet {
  76. mapMeetName[strconv.Itoa(v.Id)] = v.IndustryNames
  77. }
  78. }
  79. page := paging.GetPaging(currentIndex, pageSize, total)
  80. for _, v := range list {
  81. item := new(models.CygxMorningMeetingGatherResp)
  82. item.Id = v.Id
  83. item.Title = v.Title
  84. sliceMeetingIds := strings.Split(v.MeetingIds, ",")
  85. for _, vM := range sliceMeetingIds {
  86. if mapMeetName[vM] != "" {
  87. item.IndustryName += mapMeetName[vM] + ","
  88. }
  89. }
  90. item.IndustryName = strings.TrimRight(item.IndustryName, ",")
  91. item.IndustryName = strings.Replace(item.IndustryName, ",", "】、【", -1)
  92. item.IndustryName = "【" + item.IndustryName + "】"
  93. resp.List = append(resp.List, item)
  94. }
  95. resp.Paging = page
  96. br.Ret = 200
  97. br.Success = true
  98. br.Msg = "获取成功"
  99. br.Data = resp
  100. }
  101. // @Title 晨会精华汇总详情
  102. // @Description 晨会精华汇总详情接口
  103. // @Param Id query int true "Id"
  104. // @Success Ret=200 {object} cygx.GetCygxTacticsTimeLineResp
  105. // @router /gather/detail [get]
  106. func (this *MorningMeetingController) GatherDetail() {
  107. br := new(models.BaseResponse).Init()
  108. defer func() {
  109. this.Data["json"] = br
  110. this.ServeJSON()
  111. }()
  112. user := this.User
  113. if user == nil {
  114. br.Msg = "请登录"
  115. br.ErrMsg = "请登录,用户信息为空"
  116. br.Ret = 408
  117. return
  118. }
  119. id, _ := this.GetInt("Id")
  120. resp := new(models.CygxMorningMeetingGatherDetailResp)
  121. hasPermission, err := services.GetUserhasPermission(user)
  122. if err != nil {
  123. br.Msg = "获取信息失败"
  124. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  125. }
  126. if hasPermission != 1 {
  127. br.Ret = 200
  128. br.Success = true
  129. br.Msg = "获取成功"
  130. br.Data = resp
  131. return
  132. }
  133. var condition string
  134. var pars []interface{}
  135. condition += ` AND status = 1 AND id = ? `
  136. pars = append(pars, id)
  137. total, err := models.GetCygxMorningMeetingGatherCount(condition, pars)
  138. if err != nil {
  139. br.Msg = "获取失败"
  140. br.ErrMsg = "获取失败,Err:" + err.Error()
  141. return
  142. }
  143. if total == 0 {
  144. br.Msg = "内容不存在,或未发布"
  145. }
  146. detail, err := models.GetCygxMorningMeetingGatherById(condition, pars)
  147. if err != nil {
  148. br.Msg = "获取失败"
  149. br.ErrMsg = "获取失败,Err:" + err.Error()
  150. return
  151. }
  152. var meetids string
  153. meetids = detail.MeetingIds
  154. detailResp := new(models.CygxMorningMeetingGatherDetail)
  155. if meetids != "" {
  156. pars = make([]interface{}, 0)
  157. condition = ` AND meeting_id IN(` + meetids + `) `
  158. listMeet, err := models.GetCygxMorningMeetingReviewChapterList(condition, pars)
  159. if err != nil {
  160. br.Msg = "获取失败"
  161. br.ErrMsg = "获取失败,Err:" + err.Error()
  162. }
  163. var meetingreviewchaptIds []int
  164. for _, v := range listMeet {
  165. meetingreviewchaptIds = append(meetingreviewchaptIds, v.Id)
  166. }
  167. detailResp.List, err = services.GetCygxMorningMeetingReviewChapterListByIds(meetingreviewchaptIds)
  168. if err != nil {
  169. br.Msg = "获取失败"
  170. br.ErrMsg = "GetCygxMorningMeetingReviewChapterListByIds,Err:" + err.Error()
  171. }
  172. } else {
  173. detailResp.List = make([]*models.CygxMorningMeetingGatherDetailListResp, 0)
  174. }
  175. detailResp.Id = detail.Id
  176. detailResp.Title = detail.Title
  177. detailResp.PublishTime = utils.GetTimeDateRemoveYear(detail.PublishTime)
  178. detailResp.Department = "弘则产品组"
  179. resp.Detail = detailResp
  180. resp.HasPermission = hasPermission
  181. br.Ret = 200
  182. br.Success = true
  183. br.Msg = "获取成功"
  184. br.Data = resp
  185. }
  186. // @Title 晨会精华点击记录
  187. // @Description 晨会精华点击记录接口
  188. // @Param request body models.ArticleCollectResp true "type json string"
  189. // @Success 200
  190. // @router /history/add [post]
  191. func (this *MorningMeetingController) SpecialMsg() {
  192. br := new(models.BaseResponse).Init()
  193. defer func() {
  194. this.Data["json"] = br
  195. this.ServeJSON()
  196. }()
  197. user := this.User
  198. if user == nil {
  199. br.Msg = "请重新登录"
  200. br.Ret = 408
  201. return
  202. }
  203. var req models.AddCygxMorningMeetingReviewChapterHistoryReq
  204. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  205. if err != nil {
  206. br.Msg = "参数解析异常!"
  207. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  208. return
  209. }
  210. articleId := req.Id
  211. sourcePage := req.SourcePage
  212. go services.AddCygxMorningMeetingReviewChapterHistory(user, articleId, sourcePage)
  213. br.Ret = 200
  214. br.Success = true
  215. br.Msg = "操作成功!"
  216. }