chart_collect.go 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. package eta_forum
  2. import (
  3. "eta/eta_api/models/data_manage"
  4. "eta/eta_api/services/alarm_msg"
  5. "eta/eta_api/utils"
  6. "fmt"
  7. "github.com/rdlucklib/rdluck_tools/paging"
  8. "time"
  9. )
  10. type UserChartListReq struct {
  11. Keyword string `description:"搜索关键词"`
  12. PageSize int
  13. CurrentIndex int
  14. UserMobile string `description:"用户手机号"`
  15. BusinessCode string `description:"商户号"`
  16. UserTelAreaCode string `description:"手机号区号"`
  17. }
  18. type UserChartListResp struct {
  19. Ret int
  20. Msg string
  21. ErrMsg string
  22. ErrCode string
  23. Data *UserChartListRespItem
  24. Success bool `description:"true 执行成功,false 执行失败"`
  25. IsSendEmail bool `json:"-" description:"true 发送邮件,false 不发送邮件"`
  26. IsAddLog bool `json:"-" description:"true 新增操作日志,false 不新增操作日志" `
  27. }
  28. type UserChartListRespItem struct {
  29. ChartInfoList []*data_manage.ChartInfo
  30. Paging *paging.PagingItem `description:"分页数据"`
  31. }
  32. type UserCollectChartClassifyListResp struct {
  33. Ret int
  34. Msg string
  35. ErrMsg string
  36. ErrCode string
  37. Data *UserCollectChartClassifyListItem
  38. Success bool `description:"true 执行成功,false 执行失败"`
  39. IsSendEmail bool `json:"-" description:"true 发送邮件,false 不发送邮件"`
  40. IsAddLog bool `json:"-" description:"true 新增操作日志,false 不新增操作日志" `
  41. }
  42. type UserCollectChartClassifyListItem struct {
  43. List []*ChartCollectClassifyItem
  44. Language string `description:"指标的展示语言,CN:中文,EN:英文"`
  45. }
  46. // ChartCollectClassifyItem 我的图表分类信息
  47. type ChartCollectClassifyItem struct {
  48. CollectClassifyId int `description:"分类ID"`
  49. ClassifyName string `description:"分类名称"`
  50. UserId int `description:"创建人id"`
  51. ChartNum int `description:"分类下的图表数量"`
  52. }
  53. type UserCollectChartListResp struct {
  54. Ret int
  55. Msg string
  56. ErrMsg string
  57. ErrCode string
  58. Data *UserCollectChartListRespItem
  59. Success bool `description:"true 执行成功,false 执行失败"`
  60. IsSendEmail bool `json:"-" description:"true 发送邮件,false 不发送邮件"`
  61. IsAddLog bool `json:"-" description:"true 新增操作日志,false 不新增操作日志" `
  62. }
  63. type UserCollectChartListRespItem struct {
  64. Paging *paging.PagingItem
  65. List []*ChartCollectView
  66. }
  67. type ChartCollectView struct {
  68. ChartCollectId int
  69. ChartInfoId int `description:"图表id"`
  70. UserId int `description:"用户id"`
  71. CreateTime time.Time `description:"创建时间"`
  72. CollectTime time.Time `description:"收藏时间"`
  73. CollectClassifyId int
  74. ChartName string `description:"来源名称"`
  75. ChartNameEn string `description:"英文图表名称"`
  76. ChartImage string `description:"图表图片"`
  77. UniqueCode string `description:"图表唯一编码"`
  78. }
  79. // GetUserChartList 查询社区中对用户可见的图表列表
  80. func GetUserChartList(businessCode, userMobile, telAreaCode, keyword string) (resp UserChartListRespItem, err error, errMsg string) {
  81. defer func() {
  82. if err != nil {
  83. msg := fmt.Sprintf("查询社区中对用户可见的图表列表 GetUserChartList:Err:%v,ErrMsg:%s", err, errMsg)
  84. utils.FileLog.Info(msg)
  85. go alarm_msg.SendAlarmMsg(msg, 3)
  86. }
  87. }()
  88. urlQuery := fmt.Sprintf("BusinessCode=%s&UserMobile=%s&UserTelAreaCode=%s&Keyword=%s", businessCode, userMobile, telAreaCode, keyword)
  89. result, err := GetUserChartListLib(urlQuery)
  90. if err != nil {
  91. errMsg = "查询失败"
  92. err = fmt.Errorf("查询失败,Err:" + err.Error())
  93. return
  94. }
  95. if result.Ret != 200 {
  96. errMsg = "查询失败"
  97. err = fmt.Errorf(result.Msg + result.ErrMsg)
  98. return
  99. }
  100. resp.Paging = result.Data.Paging
  101. resp.ChartInfoList = result.Data.ChartInfoList
  102. return
  103. }
  104. // GetUserCollectChartClassifyList 查询社区中用户收藏的分类列表
  105. func GetUserCollectChartClassifyList(businessCode, userMobile, telAreaCode string) (resp UserCollectChartClassifyListItem, err error, errMsg string) {
  106. defer func() {
  107. if err != nil {
  108. msg := fmt.Sprintf("查询社区中用户收藏的分类列表 GetUserCollectChartClassifyList:Err:%v,ErrMsg:%s", err, errMsg)
  109. utils.FileLog.Info(msg)
  110. go alarm_msg.SendAlarmMsg(msg, 3)
  111. }
  112. }()
  113. urlQuery := fmt.Sprintf("BusinessCode=%s&UserMobile=%s&UserTelAreaCode=%s", businessCode, userMobile, telAreaCode)
  114. result, err := getUserCollectChartClassifyLib(urlQuery)
  115. if err != nil {
  116. errMsg = "查询失败"
  117. err = fmt.Errorf("查询失败,Err:" + err.Error())
  118. return
  119. }
  120. if result.Ret != 200 {
  121. errMsg = "查询失败"
  122. err = fmt.Errorf(result.Msg + result.ErrMsg)
  123. return
  124. }
  125. resp.List = result.Data.List
  126. resp.Language = result.Data.Language
  127. return
  128. }
  129. // GetUserCollectChartList 查询社区中对用户收藏的图表列表
  130. func GetUserCollectChartList(businessCode, userMobile, telAreaCode, keyword, collectClassifyIds string, currentIndex, pageSize int) (resp UserCollectChartListRespItem, err error, errMsg string) {
  131. defer func() {
  132. if err != nil {
  133. msg := fmt.Sprintf("查询社区中对用户收藏的图表列表 GetUserCollectChartList:Err:%v,ErrMsg:%s", err, errMsg)
  134. utils.FileLog.Info(msg)
  135. go alarm_msg.SendAlarmMsg(msg, 3)
  136. }
  137. }()
  138. urlQuery := fmt.Sprintf("BusinessCode=%s&UserMobile=%s&UserTelAreaCode=%s&Keyword=%s&CollectClassifyIds=%s&PageSize=%d&CurrentIndex=%d", businessCode, userMobile, telAreaCode, keyword, collectClassifyIds, currentIndex, pageSize)
  139. result, err := getUserCollectChartListLib(urlQuery)
  140. if err != nil {
  141. errMsg = "查询失败"
  142. err = fmt.Errorf("查询失败,Err:" + err.Error())
  143. return
  144. }
  145. if result.Ret != 200 {
  146. errMsg = "查询失败"
  147. err = fmt.Errorf(result.Msg + result.ErrMsg)
  148. return
  149. }
  150. resp.Paging = result.Data.Paging
  151. resp.List = result.Data.List
  152. return
  153. }