chart_collect.go 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. type ChartFromUniqueCodeResp struct {
  80. Ret int
  81. Msg string
  82. ErrMsg string
  83. ErrCode string
  84. Data *ChartFromUniqueCodeRespItem
  85. Success bool `description:"true 执行成功,false 执行失败"`
  86. IsSendEmail bool `json:"-" description:"true 发送邮件,false 不发送邮件"`
  87. IsAddLog bool `json:"-" description:"true 新增操作日志,false 不新增操作日志" `
  88. }
  89. type ChartFromUniqueCodeRespItem struct {
  90. ChartInfo *data_manage.ChartInfoView
  91. EdbInfoList []*data_manage.ChartEdbInfoMapping
  92. XEdbIdValue []int `description:"柱方图的x轴数据,指标id"`
  93. YDataList []data_manage.YData `description:"柱方图的y轴数据"`
  94. XDataList []data_manage.XData `description:"商品价格曲线的X轴数据"`
  95. //BarChartInfo BarChartInfoReq `description:"柱方图的配置"`
  96. //CorrelationChartInfo *CorrelationInfo `description:"相关性图表信息"`
  97. DataResp interface{} `description:"图表数据,根据图的类型而定的,没有确定的数据格式"`
  98. WaterMark string `description:"水印"`
  99. }
  100. // GetUserChartList 查询社区中对用户可见的图表列表
  101. func GetUserChartList(businessCode, userMobile, telAreaCode, keyword string) (resp UserChartListRespItem, err error, errMsg string) {
  102. defer func() {
  103. if err != nil {
  104. msg := fmt.Sprintf("查询社区中对用户可见的图表列表 GetUserChartList:Err:%v,ErrMsg:%s", err, errMsg)
  105. utils.FileLog.Info(msg)
  106. go alarm_msg.SendAlarmMsg(msg, 3)
  107. }
  108. }()
  109. urlQuery := fmt.Sprintf("BusinessCode=%s&UserMobile=%s&UserTelAreaCode=%s&Keyword=%s", businessCode, userMobile, telAreaCode, keyword)
  110. result, err := GetUserChartListLib(urlQuery)
  111. if err != nil {
  112. errMsg = "查询失败"
  113. err = fmt.Errorf("查询失败,Err:" + err.Error())
  114. return
  115. }
  116. if result.Ret != 200 {
  117. errMsg = "查询失败"
  118. err = fmt.Errorf(result.Msg + result.ErrMsg)
  119. return
  120. }
  121. resp.Paging = result.Data.Paging
  122. resp.ChartInfoList = result.Data.ChartInfoList
  123. return
  124. }
  125. // GetUserCollectChartClassifyList 查询社区中用户收藏的分类列表
  126. func GetUserCollectChartClassifyList(businessCode, userMobile, telAreaCode string) (resp UserCollectChartClassifyListItem, err error, errMsg string) {
  127. defer func() {
  128. if err != nil {
  129. msg := fmt.Sprintf("查询社区中用户收藏的分类列表 GetUserCollectChartClassifyList:Err:%v,ErrMsg:%s", err, errMsg)
  130. utils.FileLog.Info(msg)
  131. go alarm_msg.SendAlarmMsg(msg, 3)
  132. }
  133. }()
  134. urlQuery := fmt.Sprintf("BusinessCode=%s&UserMobile=%s&UserTelAreaCode=%s", businessCode, userMobile, telAreaCode)
  135. result, err := getUserCollectChartClassifyLib(urlQuery)
  136. if err != nil {
  137. errMsg = "查询失败"
  138. err = fmt.Errorf("查询失败,Err:" + err.Error())
  139. return
  140. }
  141. if result.Ret != 200 {
  142. errMsg = "查询失败"
  143. err = fmt.Errorf(result.Msg + result.ErrMsg)
  144. return
  145. }
  146. resp.List = result.Data.List
  147. resp.Language = result.Data.Language
  148. return
  149. }
  150. // GetUserCollectChartList 查询社区中对用户收藏的图表列表
  151. func GetUserCollectChartList(businessCode, userMobile, telAreaCode, keyword, collectClassifyIds string, currentIndex, pageSize int) (resp UserCollectChartListRespItem, err error, errMsg string) {
  152. defer func() {
  153. if err != nil {
  154. msg := fmt.Sprintf("查询社区中对用户收藏的图表列表 GetUserCollectChartList:Err:%v,ErrMsg:%s", err, errMsg)
  155. utils.FileLog.Info(msg)
  156. go alarm_msg.SendAlarmMsg(msg, 3)
  157. }
  158. }()
  159. urlQuery := fmt.Sprintf("BusinessCode=%s&UserMobile=%s&UserTelAreaCode=%s&Keyword=%s&CollectClassifyIds=%s&CurrentIndex=%d&PageSize=%d", businessCode, userMobile, telAreaCode, keyword, collectClassifyIds, currentIndex, pageSize)
  160. result, err := getUserCollectChartListLib(urlQuery)
  161. if err != nil {
  162. errMsg = "查询失败"
  163. err = fmt.Errorf("查询失败,Err:" + err.Error())
  164. return
  165. }
  166. if result.Ret != 200 {
  167. errMsg = "查询失败"
  168. err = fmt.Errorf(result.Msg + result.ErrMsg)
  169. return
  170. }
  171. resp.Paging = result.Data.Paging
  172. resp.List = result.Data.List
  173. return
  174. }
  175. // GeChartFromUniqueCode 社区中根据唯一编码查询图表
  176. func GeChartFromUniqueCode(uniqueCode string, isCache bool) (resp ChartFromUniqueCodeRespItem, err error, errMsg string) {
  177. defer func() {
  178. if err != nil {
  179. msg := fmt.Sprintf("查询社区中对用户可见的图表列表 GeChartFromUniqueCode:Err:%v,ErrMsg:%s", err, errMsg)
  180. utils.FileLog.Info(msg)
  181. go alarm_msg.SendAlarmMsg(msg, 3)
  182. }
  183. }()
  184. urlQuery := fmt.Sprintf("UniqueCode=%s&isCache=%v", uniqueCode, isCache)
  185. result, err := getChartFromUniqueCodeLib(urlQuery)
  186. if err != nil {
  187. errMsg = "查询失败"
  188. err = fmt.Errorf("查询失败,Err:" + err.Error())
  189. return
  190. }
  191. if result.Ret != 200 {
  192. errMsg = "查询失败"
  193. err = fmt.Errorf(result.Msg + result.ErrMsg)
  194. return
  195. }
  196. resp = *result.Data
  197. return
  198. }