Преглед на файлове

查询eta社区中的图表列表

xyxie преди 1 седмица
родител
ревизия
c49328a0a9
променени са 5 файла, в които са добавени 273 реда и са изтрити 5 реда
  1. 106 1
      controllers/eta_forum/eta_forum.go
  2. 27 0
      routers/commentsRouter.go
  3. 6 0
      routers/router.go
  4. 113 3
      services/eta_forum/chart_collect.go
  5. 21 1
      services/eta_forum/eta_forum_hub_lib.go

+ 106 - 1
controllers/eta_forum/eta_forum.go

@@ -16,7 +16,7 @@ type EtaForumController struct {
 // @Description 查询用户在eta社区中有权限查看的图表列表
 // @Param	request	body data_manage.SetChartInfoImageReq true "type json string"
 // @Success Ret=200 保存成功
-// @router /eta_forum/chart_list [get]
+// @router /chart_list [get]
 func (this *EtaForumController) UserChartList() {
 	br := new(models.BaseResponse).Init()
 	defer func() {
@@ -60,3 +60,108 @@ func (this *EtaForumController) UserChartList() {
 	br.Msg = "保存成功"
 	br.Data = resp
 }
+
+// UserCollectChartClassifyList
+// @Title 查询社区中用户收藏的分类列表
+// @Description 查询社区中用户收藏的分类列表
+// @Param	request	body data_manage.SetChartInfoImageReq true "type json string"
+// @Success Ret=200 保存成功
+// @router /collect/chart_classify [get]
+func (this *EtaForumController) UserCollectChartClassifyList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	businessCode := utils.BusinessCode
+	userMobile := sysUser.Mobile
+	telAreaCode := sysUser.TelAreaCode
+	if businessCode == "" {
+		br.Msg = "商户号未配置"
+		return
+	}
+
+	if userMobile == "" {
+		br.Msg = "请先绑定手机号"
+		return
+	}
+	if telAreaCode == "" {
+		telAreaCode = utils.TelAreaCodeHome
+	}
+
+	resp, err, errMsg := eta_forum.GetUserCollectChartClassifyList(businessCode, userMobile, telAreaCode)
+	if err != nil {
+		br.Msg = errMsg
+		br.ErrMsg = err.Error()
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "保存成功"
+	br.Data = resp
+}
+
+// UserCollectChartList
+// @Title 查询社区中用户收藏的图表列表
+// @Description 查询社区中用户收藏的图表列表
+// @Param	request	body data_manage.SetChartInfoImageReq true "type json string"
+// @Success Ret=200 保存成功
+// @router /collect/chart [get]
+func (this *EtaForumController) UserCollectChartList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	businessCode := utils.BusinessCode
+	userMobile := sysUser.Mobile
+	telAreaCode := sysUser.TelAreaCode
+	if businessCode == "" {
+		br.Msg = "商户号未配置"
+		return
+	}
+
+	if userMobile == "" {
+		br.Msg = "请先绑定手机号"
+		return
+	}
+	if telAreaCode == "" {
+		telAreaCode = utils.TelAreaCodeHome
+	}
+
+	collectClassifyIds := this.GetString("CollectClassifyIds")
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	keyword := this.GetString("Keyword")
+
+	resp, err, errMsg := eta_forum.GetUserCollectChartList(businessCode, userMobile, telAreaCode, keyword, collectClassifyIds, currentIndex, pageSize)
+	if err != nil {
+		br.Msg = errMsg
+		br.ErrMsg = err.Error()
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "保存成功"
+	br.Data = resp
+}

+ 27 - 0
routers/commentsRouter.go

@@ -7864,6 +7864,33 @@ 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: "UserChartList",
+            Router: `/chart_list`,
+            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: "UserCollectChartList",
+            Router: `/collect/chart`,
+            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: "UserCollectChartClassifyList",
+            Router: `/collect/chart_classify`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_api/controllers/eta_trial:EtaTrialController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/eta_trial:EtaTrialController"],
         beego.ControllerComments{
             Method: "QuestionnaireCommit",

+ 6 - 0
routers/router.go

@@ -27,6 +27,7 @@ import (
 	"eta/eta_api/controllers/document_manage"
 	"eta/eta_api/controllers/edb_monitor"
 	"eta/eta_api/controllers/english_report"
+	"eta/eta_api/controllers/eta_forum"
 	"eta/eta_api/controllers/eta_trial"
 	"eta/eta_api/controllers/fe_calendar"
 	"eta/eta_api/controllers/report_approve"
@@ -425,6 +426,11 @@ func init() {
 				&ai_predict_model.AiPredictModelIndexController{},
 			),
 		),
+		web.NSNamespace("/eta_forum",
+			web.NSInclude(
+				&eta_forum.EtaForumController{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }

+ 113 - 3
services/eta_forum/chart_collect.go

@@ -3,8 +3,10 @@ package eta_forum
 import (
 	"eta/eta_api/models/data_manage"
 	"eta/eta_api/services/alarm_msg"
+	"eta/eta_api/utils"
 	"fmt"
 	"github.com/rdlucklib/rdluck_tools/paging"
+	"time"
 )
 
 type UserChartListReq struct {
@@ -32,14 +34,68 @@ type UserChartListRespItem struct {
 	Paging        *paging.PagingItem `description:"分页数据"`
 }
 
+type UserCollectChartClassifyListResp struct {
+	Ret         int
+	Msg         string
+	ErrMsg      string
+	ErrCode     string
+	Data        *UserCollectChartClassifyListItem
+	Success     bool `description:"true 执行成功,false 执行失败"`
+	IsSendEmail bool `json:"-" description:"true 发送邮件,false 不发送邮件"`
+	IsAddLog    bool `json:"-" description:"true 新增操作日志,false 不新增操作日志" `
+}
+
+type UserCollectChartClassifyListItem struct {
+	List     []*ChartCollectClassifyItem
+	Language string `description:"指标的展示语言,CN:中文,EN:英文"`
+}
+
+// ChartCollectClassifyItem 我的图表分类信息
+type ChartCollectClassifyItem struct {
+	CollectClassifyId int    `description:"分类ID"`
+	ClassifyName      string `description:"分类名称"`
+	UserId            int    `description:"创建人id"`
+	ChartNum          int    `description:"分类下的图表数量"`
+}
+
+type UserCollectChartListResp struct {
+	Ret         int
+	Msg         string
+	ErrMsg      string
+	ErrCode     string
+	Data        *UserCollectChartListRespItem
+	Success     bool `description:"true 执行成功,false 执行失败"`
+	IsSendEmail bool `json:"-" description:"true 发送邮件,false 不发送邮件"`
+	IsAddLog    bool `json:"-" description:"true 新增操作日志,false 不新增操作日志" `
+}
+type UserCollectChartListRespItem struct {
+	Paging *paging.PagingItem
+	List   []*ChartCollectView
+}
+
+type ChartCollectView struct {
+	ChartCollectId    int
+	ChartInfoId       int       `description:"图表id"`
+	UserId            int       `description:"用户id"`
+	CreateTime        time.Time `description:"创建时间"`
+	CollectTime       time.Time `description:"收藏时间"`
+	CollectClassifyId int
+	ChartName         string `description:"来源名称"`
+	ChartNameEn       string `description:"英文图表名称"`
+	ChartImage        string `description:"图表图片"`
+	UniqueCode        string `description:"图表唯一编码"`
+}
+
 // GetUserChartList 查询社区中对用户可见的图表列表
 func GetUserChartList(businessCode, userMobile, telAreaCode, keyword string) (resp UserChartListRespItem, err error, errMsg string) {
 	defer func() {
 		if err != nil {
-			go alarm_msg.SendAlarmMsg(fmt.Sprintf("查询社区中对用户可见的图表列表 GetUserChartList:Err:%v,ErrMsg:%s", err, errMsg), 3)
+			msg := fmt.Sprintf("查询社区中对用户可见的图表列表 GetUserChartList:Err:%v,ErrMsg:%s", err, errMsg)
+			utils.FileLog.Info(msg)
+			go alarm_msg.SendAlarmMsg(msg, 3)
 		}
 	}()
-	urlQuery := fmt.Sprintf("BusinessCode=%s&UserMobile=%s&TelAreaCode=%s&Keyword=%s", businessCode, userMobile, telAreaCode, keyword)
+	urlQuery := fmt.Sprintf("BusinessCode=%s&UserMobile=%s&UserTelAreaCode=%s&Keyword=%s", businessCode, userMobile, telAreaCode, keyword)
 	result, err := GetUserChartListLib(urlQuery)
 	if err != nil {
 		errMsg = "查询失败"
@@ -48,7 +104,7 @@ func GetUserChartList(businessCode, userMobile, telAreaCode, keyword string) (re
 	}
 	if result.Ret != 200 {
 		errMsg = "查询失败"
-		err = fmt.Errorf(result.ErrMsg)
+		err = fmt.Errorf(result.Msg + result.ErrMsg)
 		return
 	}
 	resp.Paging = result.Data.Paging
@@ -56,3 +112,57 @@ func GetUserChartList(businessCode, userMobile, telAreaCode, keyword string) (re
 
 	return
 }
+
+// GetUserCollectChartClassifyList 查询社区中用户收藏的分类列表
+func GetUserCollectChartClassifyList(businessCode, userMobile, telAreaCode string) (resp UserCollectChartClassifyListItem, err error, errMsg string) {
+	defer func() {
+		if err != nil {
+			msg := fmt.Sprintf("查询社区中用户收藏的分类列表 GetUserCollectChartClassifyList:Err:%v,ErrMsg:%s", err, errMsg)
+			utils.FileLog.Info(msg)
+			go alarm_msg.SendAlarmMsg(msg, 3)
+		}
+	}()
+	urlQuery := fmt.Sprintf("BusinessCode=%s&UserMobile=%s&UserTelAreaCode=%s", businessCode, userMobile, telAreaCode)
+	result, err := getUserCollectChartClassifyLib(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.List = result.Data.List
+	resp.Language = result.Data.Language
+
+	return
+}
+
+// GetUserCollectChartList 查询社区中对用户收藏的图表列表
+func GetUserCollectChartList(businessCode, userMobile, telAreaCode, keyword, collectClassifyIds string, currentIndex, pageSize int) (resp UserCollectChartListRespItem, err error, errMsg string) {
+	defer func() {
+		if err != nil {
+			msg := fmt.Sprintf("查询社区中对用户收藏的图表列表 GetUserCollectChartList:Err:%v,ErrMsg:%s", err, errMsg)
+			utils.FileLog.Info(msg)
+			go alarm_msg.SendAlarmMsg(msg, 3)
+		}
+	}()
+	urlQuery := fmt.Sprintf("BusinessCode=%s&UserMobile=%s&UserTelAreaCode=%s&Keyword=%s&CollectClassifyIds=%s&PageSize=%d&CurrentIndex=%d", businessCode, userMobile, telAreaCode, keyword, collectClassifyIds, currentIndex, pageSize)
+	result, err := getUserCollectChartListLib(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.Paging = result.Data.Paging
+	resp.List = result.Data.List
+
+	return
+}

+ 21 - 1
services/eta_forum/eta_forum_hub_lib.go

@@ -82,7 +82,27 @@ func ChartThemeTypeSaveLib(req string) (resp *models.BaseResponse, err error) {
 
 // GetUserChartListLib 查询有权限的图表列表
 func GetUserChartListLib(req string) (resp *UserChartListResp, err error) {
-	_, resultByte, err := get(req, "/v1/chart/theme/type/save")
+	_, resultByte, err := get(req, "/v1/chart/user/chart_list")
+	err = json.Unmarshal(resultByte, &resp)
+	if err != nil {
+		return
+	}
+	return
+}
+
+// getUserCollectChartClassifyLib 查询收藏的分类列表
+func getUserCollectChartClassifyLib(req string) (resp *UserCollectChartClassifyListResp, err error) {
+	_, resultByte, err := get(req, "/v1/chart_collect/classify/list")
+	err = json.Unmarshal(resultByte, &resp)
+	if err != nil {
+		return
+	}
+	return
+}
+
+// getUserCollectChartListLib 查询收藏的图表列表
+func getUserCollectChartListLib(req string) (resp *UserCollectChartListResp, err error) {
+	_, resultByte, err := get(req, "/v1/chart_collect/chart/list")
 	err = json.Unmarshal(resultByte, &resp)
 	if err != nil {
 		return