eta_forum.go 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. package eta_forum
  2. import (
  3. "eta/eta_api/controllers"
  4. "eta/eta_api/models"
  5. "eta/eta_api/models/data_manage"
  6. "eta/eta_api/services/eta_forum"
  7. "eta/eta_api/utils"
  8. )
  9. type EtaForumController struct {
  10. controllers.BaseAuthController
  11. }
  12. // UserChartList
  13. // @Title 查询用户在eta社区中有权限查看的图表列表
  14. // @Description 查询用户在eta社区中有权限查看的图表列表
  15. // @Param request body data_manage.SetChartInfoImageReq true "type json string"
  16. // @Success Ret=200 保存成功
  17. // @router /chart_list [get]
  18. func (this *EtaForumController) UserChartList() {
  19. br := new(models.BaseResponse).Init()
  20. defer func() {
  21. this.Data["json"] = br
  22. this.ServeJSON()
  23. }()
  24. sysUser := this.SysUser
  25. if sysUser == nil {
  26. br.Msg = "请登录"
  27. br.ErrMsg = "请登录,SysUser Is Empty"
  28. br.Ret = 408
  29. return
  30. }
  31. keyword := this.GetString("keyword")
  32. businessCode := utils.BusinessCode
  33. userMobile := sysUser.Mobile
  34. telAreaCode := sysUser.TelAreaCode
  35. if businessCode == "" {
  36. br.Msg = "商户号未配置"
  37. return
  38. }
  39. if userMobile == "" {
  40. br.Msg = "请先绑定手机号"
  41. return
  42. }
  43. if telAreaCode == "" {
  44. telAreaCode = utils.TelAreaCodeHome
  45. }
  46. resp, err, errMsg := eta_forum.GetUserChartList(businessCode, userMobile, telAreaCode, keyword)
  47. if err != nil {
  48. br.Msg = errMsg
  49. br.ErrMsg = err.Error()
  50. return
  51. }
  52. br.Ret = 200
  53. br.Success = true
  54. br.Msg = "保存成功"
  55. br.Data = resp
  56. }
  57. // UserCollectChartClassifyList
  58. // @Title 查询社区中用户收藏的分类列表
  59. // @Description 查询社区中用户收藏的分类列表
  60. // @Param request body data_manage.SetChartInfoImageReq true "type json string"
  61. // @Success Ret=200 保存成功
  62. // @router /collect/chart_classify [get]
  63. func (this *EtaForumController) UserCollectChartClassifyList() {
  64. br := new(models.BaseResponse).Init()
  65. defer func() {
  66. this.Data["json"] = br
  67. this.ServeJSON()
  68. }()
  69. sysUser := this.SysUser
  70. if sysUser == nil {
  71. br.Msg = "请登录"
  72. br.ErrMsg = "请登录,SysUser Is Empty"
  73. br.Ret = 408
  74. return
  75. }
  76. businessCode := utils.BusinessCode
  77. userMobile := sysUser.Mobile
  78. telAreaCode := sysUser.TelAreaCode
  79. if businessCode == "" {
  80. br.Msg = "商户号未配置"
  81. return
  82. }
  83. if userMobile == "" {
  84. br.Msg = "请先绑定手机号"
  85. return
  86. }
  87. if telAreaCode == "" {
  88. telAreaCode = utils.TelAreaCodeHome
  89. }
  90. resp, err, errMsg := eta_forum.GetUserCollectChartClassifyList(businessCode, userMobile, telAreaCode)
  91. if err != nil {
  92. br.Msg = errMsg
  93. br.ErrMsg = err.Error()
  94. return
  95. }
  96. br.Ret = 200
  97. br.Success = true
  98. br.Msg = "保存成功"
  99. br.Data = resp
  100. }
  101. // UserCollectChartList
  102. // @Title 查询社区中用户收藏的图表列表
  103. // @Description 查询社区中用户收藏的图表列表
  104. // @Param request body data_manage.SetChartInfoImageReq true "type json string"
  105. // @Success Ret=200 保存成功
  106. // @router /collect/chart [get]
  107. func (this *EtaForumController) UserCollectChartList() {
  108. br := new(models.BaseResponse).Init()
  109. defer func() {
  110. this.Data["json"] = br
  111. this.ServeJSON()
  112. }()
  113. sysUser := this.SysUser
  114. if sysUser == nil {
  115. br.Msg = "请登录"
  116. br.ErrMsg = "请登录,SysUser Is Empty"
  117. br.Ret = 408
  118. return
  119. }
  120. businessCode := utils.BusinessCode
  121. userMobile := sysUser.Mobile
  122. telAreaCode := sysUser.TelAreaCode
  123. if businessCode == "" {
  124. br.Msg = "商户号未配置"
  125. return
  126. }
  127. if userMobile == "" {
  128. br.Msg = "请先绑定手机号"
  129. return
  130. }
  131. if telAreaCode == "" {
  132. telAreaCode = utils.TelAreaCodeHome
  133. }
  134. collectClassifyIds := this.GetString("CollectClassifyIds")
  135. pageSize, _ := this.GetInt("PageSize")
  136. currentIndex, _ := this.GetInt("CurrentIndex")
  137. keyword := this.GetString("Keyword")
  138. resp, err, errMsg := eta_forum.GetUserCollectChartList(businessCode, userMobile, telAreaCode, keyword, collectClassifyIds, currentIndex, pageSize)
  139. if err != nil {
  140. br.Msg = errMsg
  141. br.ErrMsg = err.Error()
  142. return
  143. }
  144. br.Ret = 200
  145. br.Success = true
  146. br.Msg = "保存成功"
  147. br.Data = resp
  148. }
  149. // CommonChartInfoDetailFromUniqueCode
  150. // @Title 根据编码获取图表详情
  151. // @Description 根据编码获取图表详情接口
  152. // @Param UniqueCode query int true "图表唯一编码,如果是管理后台访问,传固定字符串:7c69b590249049942070ae9dcd5bf6dc"
  153. // @Param IsCache query bool true "是否走缓存,默认false"
  154. // @Success 200 {object} data_manage.ChartInfoDetailFromUniqueCodeResp
  155. // @router /chart/from_unique_code [get]
  156. func (this *EtaForumController) CommonChartInfoDetailFromUniqueCode() {
  157. br := new(models.BaseResponse).Init()
  158. defer func() {
  159. this.Data["json"] = br
  160. this.ServeJSON()
  161. }()
  162. uniqueCode := this.GetString("UniqueCode")
  163. if uniqueCode == "" {
  164. br.Msg = "参数错误"
  165. br.ErrMsg = "参数错误,uniqueCode is empty"
  166. return
  167. }
  168. //是否走缓存
  169. isCache, _ := this.GetBool("IsCache")
  170. resp := new(data_manage.ChartInfoDetailFromUniqueCodeResp)
  171. status := true
  172. forumResp, err, _ := eta_forum.GeChartFromUniqueCode(uniqueCode, isCache)
  173. if err != nil {
  174. endInfoList := make([]*data_manage.ChartEdbInfoMapping, 0)
  175. resp.EdbInfoList = endInfoList
  176. resp.ChartInfo = nil
  177. resp.Status = false
  178. br.Data = resp
  179. br.Ret = 200
  180. br.Success = true
  181. br.Msg = "获取成功"
  182. return
  183. }
  184. chartInfo := forumResp.ChartInfo
  185. if chartInfo == nil {
  186. endInfoList := make([]*data_manage.ChartEdbInfoMapping, 0)
  187. resp.EdbInfoList = endInfoList
  188. resp.ChartInfo = nil
  189. resp.Status = false
  190. br.Data = resp
  191. br.Ret = 200
  192. br.Success = true
  193. br.Msg = "获取成功"
  194. return
  195. }
  196. resp.ChartInfo = chartInfo
  197. resp.Status = status
  198. resp.DataResp = forumResp.DataResp
  199. resp.EdbInfoList = forumResp.EdbInfoList
  200. resp.XDataList = forumResp.XDataList
  201. resp.YDataList = forumResp.YDataList
  202. br.Ret = 200
  203. br.Success = true
  204. br.Msg = "获取成功"
  205. br.Data = resp
  206. }