eta_forum.go 5.8 KB

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