eta_forum.go 6.4 KB

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