morning_meeting.go 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hongze_cygx/models"
  6. "hongze/hongze_cygx/services"
  7. "hongze/hongze_cygx/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 user.UserId == 0 {
  127. hasPermission = 1 //用户未登录(绑定登录信息)的时候也能展示 v12.2.1
  128. }
  129. resp.HasPermission = hasPermission
  130. if hasPermission != 1 {
  131. br.Ret = 200
  132. br.Success = true
  133. br.Msg = "获取成功"
  134. br.Data = resp
  135. return
  136. }
  137. var condition string
  138. var pars []interface{}
  139. condition += ` AND status = 1 AND id = ? `
  140. pars = append(pars, id)
  141. total, err := models.GetCygxMorningMeetingGatherCount(condition, pars)
  142. if err != nil {
  143. br.Msg = "获取失败"
  144. br.ErrMsg = "获取失败,Err:" + err.Error()
  145. return
  146. }
  147. if total == 0 {
  148. br.Msg = "内容不存在,或未发布"
  149. }
  150. detail, err := models.GetCygxMorningMeetingGatherById(condition, pars)
  151. if err != nil {
  152. br.Msg = "获取失败"
  153. br.ErrMsg = "获取失败,Err:" + err.Error()
  154. return
  155. }
  156. var meetids string
  157. meetids = detail.MeetingIds
  158. detailResp := new(models.CygxMorningMeetingGatherDetail)
  159. if meetids != "" {
  160. pars = make([]interface{}, 0)
  161. condition = ` AND meeting_id IN(` + meetids + `) `
  162. listMeet, err := models.GetCygxMorningMeetingReviewChapterList(condition, pars)
  163. if err != nil {
  164. br.Msg = "获取失败"
  165. br.ErrMsg = "获取失败,Err:" + err.Error()
  166. }
  167. var meetingreviewchaptIds []int
  168. for _, v := range listMeet {
  169. meetingreviewchaptIds = append(meetingreviewchaptIds, v.Id)
  170. }
  171. detailResp.List, err = services.GetCygxMorningMeetingReviewChapterListByIds(meetingreviewchaptIds)
  172. if err != nil {
  173. br.Msg = "获取失败"
  174. br.ErrMsg = "GetCygxMorningMeetingReviewChapterListByIds,Err:" + err.Error()
  175. }
  176. } else {
  177. detailResp.List = make([]*models.CygxMorningMeetingGatherDetailListResp, 0)
  178. }
  179. detailResp.Id = detail.Id
  180. detailResp.Title = detail.Title
  181. detailResp.PublishTime = utils.GetTimeDateRemoveYear(detail.PublishTime)
  182. detailResp.Department = "弘则产品组"
  183. resp.Detail = detailResp
  184. br.Ret = 200
  185. br.Success = true
  186. br.Msg = "获取成功"
  187. br.Data = resp
  188. }
  189. // @Title 晨会精华点击记录
  190. // @Description 晨会精华点击记录接口
  191. // @Param request body models.ArticleCollectResp true "type json string"
  192. // @Success 200
  193. // @router /history/add [post]
  194. func (this *MorningMeetingController) SpecialMsg() {
  195. br := new(models.BaseResponse).Init()
  196. defer func() {
  197. this.Data["json"] = br
  198. this.ServeJSON()
  199. }()
  200. user := this.User
  201. if user == nil {
  202. br.Msg = "请重新登录"
  203. br.Ret = 408
  204. return
  205. }
  206. var req models.AddCygxMorningMeetingReviewChapterHistoryReq
  207. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  208. if err != nil {
  209. br.Msg = "参数解析异常!"
  210. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  211. return
  212. }
  213. articleId := req.Id
  214. sourcePage := req.SourcePage
  215. go services.AddCygxMorningMeetingReviewChapterHistory(user, articleId, sourcePage)
  216. br.Ret = 200
  217. br.Success = true
  218. br.Msg = "操作成功!"
  219. }