Kaynağa Gözat

根据唯一编码查询eta社区图表

xyxie 1 hafta önce
ebeveyn
işleme
0683840e20

+ 64 - 0
controllers/eta_forum/eta_forum.go

@@ -3,6 +3,7 @@ package eta_forum
 import (
 	"eta/eta_api/controllers"
 	"eta/eta_api/models"
+	"eta/eta_api/models/data_manage"
 	"eta/eta_api/services/eta_forum"
 	"eta/eta_api/utils"
 )
@@ -165,3 +166,66 @@ func (this *EtaForumController) UserCollectChartList() {
 	br.Msg = "保存成功"
 	br.Data = resp
 }
+
+// CommonChartInfoDetailFromUniqueCode
+// @Title 根据编码获取图表详情
+// @Description 根据编码获取图表详情接口
+// @Param   UniqueCode   query   int  true       "图表唯一编码,如果是管理后台访问,传固定字符串:7c69b590249049942070ae9dcd5bf6dc"
+// @Param   IsCache   query   bool  true       "是否走缓存,默认false"
+// @Success 200 {object} data_manage.ChartInfoDetailFromUniqueCodeResp
+// @router /chart/from_unique_code [get]
+func (this *EtaForumController) CommonChartInfoDetailFromUniqueCode() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+
+	uniqueCode := this.GetString("UniqueCode")
+	if uniqueCode == "" {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误,uniqueCode is empty"
+		return
+	}
+
+	//是否走缓存
+	isCache, _ := this.GetBool("IsCache")
+	resp := new(data_manage.ChartInfoDetailFromUniqueCodeResp)
+	status := true
+	forumResp, err, _ := eta_forum.GeChartFromUniqueCode(uniqueCode, isCache)
+	if err != nil {
+		endInfoList := make([]*data_manage.ChartEdbInfoMapping, 0)
+		resp.EdbInfoList = endInfoList
+		resp.ChartInfo = nil
+		resp.Status = false
+
+		br.Data = resp
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		return
+	}
+	chartInfo := forumResp.ChartInfo
+	if chartInfo == nil {
+		endInfoList := make([]*data_manage.ChartEdbInfoMapping, 0)
+		resp.EdbInfoList = endInfoList
+		resp.ChartInfo = nil
+		resp.Status = false
+
+		br.Data = resp
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		return
+	}
+	resp.ChartInfo = chartInfo
+	resp.Status = status
+	resp.DataResp = forumResp.DataResp
+	resp.EdbInfoList = forumResp.EdbInfoList
+	resp.XDataList = forumResp.XDataList
+	resp.YDataList = forumResp.YDataList
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 9 - 0
routers/commentsRouter.go

@@ -7864,6 +7864,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta/eta_api/controllers/eta_forum:EtaForumController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/eta_forum:EtaForumController"],
+        beego.ControllerComments{
+            Method: "CommonChartInfoDetailFromUniqueCode",
+            Router: `/chart/from_unique_code`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_api/controllers/eta_forum:EtaForumController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/eta_forum:EtaForumController"],
         beego.ControllerComments{
             Method: "UserChartList",

+ 49 - 0
services/eta_forum/chart_collect.go

@@ -86,6 +86,29 @@ type ChartCollectView struct {
 	UniqueCode        string `description:"图表唯一编码"`
 }
 
+type ChartFromUniqueCodeResp struct {
+	Ret         int
+	Msg         string
+	ErrMsg      string
+	ErrCode     string
+	Data        *ChartFromUniqueCodeRespItem
+	Success     bool `description:"true 执行成功,false 执行失败"`
+	IsSendEmail bool `json:"-" description:"true 发送邮件,false 不发送邮件"`
+	IsAddLog    bool `json:"-" description:"true 新增操作日志,false 不新增操作日志" `
+}
+
+type ChartFromUniqueCodeRespItem struct {
+	ChartInfo   *data_manage.ChartInfoView
+	EdbInfoList []*data_manage.ChartEdbInfoMapping
+	XEdbIdValue []int               `description:"柱方图的x轴数据,指标id"`
+	YDataList   []data_manage.YData `description:"柱方图的y轴数据"`
+	XDataList   []data_manage.XData `description:"商品价格曲线的X轴数据"`
+	//BarChartInfo BarChartInfoReq `description:"柱方图的配置"`
+	//CorrelationChartInfo *CorrelationInfo `description:"相关性图表信息"`
+	DataResp  interface{} `description:"图表数据,根据图的类型而定的,没有确定的数据格式"`
+	WaterMark string      `description:"水印"`
+}
+
 // GetUserChartList 查询社区中对用户可见的图表列表
 func GetUserChartList(businessCode, userMobile, telAreaCode, keyword string) (resp UserChartListRespItem, err error, errMsg string) {
 	defer func() {
@@ -166,3 +189,29 @@ func GetUserCollectChartList(businessCode, userMobile, telAreaCode, keyword, col
 
 	return
 }
+
+// GeChartFromUniqueCode 社区中根据唯一编码查询图表
+func GeChartFromUniqueCode(uniqueCode string, isCache bool) (resp ChartFromUniqueCodeRespItem, err error, errMsg string) {
+	defer func() {
+		if err != nil {
+			msg := fmt.Sprintf("查询社区中对用户可见的图表列表 GeChartFromUniqueCode:Err:%v,ErrMsg:%s", err, errMsg)
+			utils.FileLog.Info(msg)
+			go alarm_msg.SendAlarmMsg(msg, 3)
+		}
+	}()
+	urlQuery := fmt.Sprintf("UniqueCode=%s&isCache=%v", uniqueCode, isCache)
+	result, err := getChartFromUniqueCodeLib(urlQuery)
+	if err != nil {
+		errMsg = "查询失败"
+		err = fmt.Errorf("查询失败,Err:" + err.Error())
+		return
+	}
+	if result.Ret != 200 {
+		errMsg = "查询失败"
+		err = fmt.Errorf(result.Msg + result.ErrMsg)
+		return
+	}
+	resp = *result.Data
+
+	return
+}

+ 10 - 0
services/eta_forum/eta_forum_hub_lib.go

@@ -110,6 +110,16 @@ func getUserCollectChartListLib(req string) (resp *UserCollectChartListResp, err
 	return
 }
 
+// getChartFromUniqueCodeLib 根据唯一编码查询图表
+func getChartFromUniqueCodeLib(req string) (resp ChartFromUniqueCodeResp, err error) {
+	_, resultByte, err := get(req, "/v1/chart/common/from_unique_code")
+	err = json.Unmarshal(resultByte, &resp)
+	if err != nil {
+		return
+	}
+	return
+}
+
 // post
 func post(paramStr string, urlStr string) (resp *models.BaseResponse, result []byte, err error) {
 	if utils.ETA_FORUM_HUB_URL == "" {