zwxi 6 місяців тому
батько
коміт
f12effcfe1

+ 61 - 1
controllers/hisugar_data.go

@@ -850,7 +850,7 @@ func getHisugarClassifyTree(items []*data_manage.BaseFromHisugarClassifyItem, pa
 // @Param   Frequency   query   string  true       "频率"
 // @Success 200 {object} data_manage.LzFrequency
 // @router /data/hisugar/index/data [get]
-func (this *TradeCommonController) FenweiIndexData() {
+func (this *TradeCommonController) HisugarIndexData() {
 	br := new(models.BaseResponse).Init()
 	defer func() {
 		if br.ErrMsg == "" {
@@ -969,4 +969,64 @@ func (this *TradeCommonController) FenweiIndexData() {
 	br.Success = true
 	br.Msg = "获取成功"
 	br.Data = resultList
+}
+
+// GetFenWeiIndexInfo
+// @Title 添加指标-根据条件获取指标信息
+// @Description 添加指标-根据条件获取指标信息
+// @Param   KeyWord   query   string  false       "关键字"
+// @Param   ClassifyIds   query   string  false       "分类id"
+// @Param   Frequencies   query   string  false       "频率"
+// @Param   PageSize   query   int  false       "每页数据条数"
+// @Param   CurrentIndex   query   int  false       "当前页页码,从1开始"
+// @Success 200 {object} data_manage.BaseFromFenWeiIndexPage
+// @router /data/hisugar/index/info [get]
+func (this *TradeCommonController) GetHisugarIndexInfo() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		if br.ErrMsg == "" {
+			br.IsSendEmail = false
+		}
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+
+	keyWord := this.GetString("KeyWord")
+	classifyIds := this.GetString("ClassifyIds")
+	frequencies := this.GetString("Frequencies")
+
+	var classifyIdList []string
+	var frequencyList []string
+	if classifyIds != "" {
+		classifyIdList = strings.Split(classifyIds, ",")
+	}
+	if frequencies != "" {
+		frequencyList = strings.Split(frequencies, ",")
+	}
+	indexInfoPage, err := data.GethisugarIndexInfo(keyWord, classifyIdList, frequencyList, currentIndex, pageSize)
+	if err != nil {
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = indexInfoPage
 }

+ 31 - 0
models/data_manage/base_from_hisugar.go

@@ -351,4 +351,35 @@ func GetHisugarIndexDataV2(indexCode string, startSize, pageSize int) (items []*
 	sql := ` SELECT *  FROM base_from_hisugar_data WHERE index_code=? ORDER BY data_time DESC LIMIT ?,? `
 	_, err = o.Raw(sql, indexCode, startSize, pageSize).QueryRows(&items)
 	return
+}
+
+
+// GetHisugarIndexInfoCount 查询指标信息总数
+func GetHisugarIndexInfoCount(condition string, pars []interface{}) (count int, err error) {
+	o := orm.NewOrmUsingDB("data")
+	sql := ` SELECT COUNT(1) AS count FROM base_from_hisugar_index WHERE 1=1  `
+	if condition != "" {
+		sql += condition
+	}
+	err = o.Raw(sql, pars).QueryRow(&count)
+	return
+}
+
+
+type BaseFromHisugarIndexPage struct {
+	List   []*BaseFromHisugarIndex `description:"指标列表"`
+	Paging *paging.PagingItem     `description:"分页数据"`
+}
+
+// GetHisugarIndexInfoPage 分页查询指标信息
+func GetHisugarIndexInfoPage(condition string, pars []interface{}, size int, pageSize int) (items []*BaseFromHisugarIndex, err error) {
+	o := orm.NewOrmUsingDB("data")
+	sql := ` SELECT * FROM base_from_hisugar_index WHERE 1=1  `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` ORDER BY base_from_hisugar_index_id asc LIMIT ?,?`
+	_, err = o.Raw(sql, pars, size, pageSize).QueryRows(&items)
+	return
+
 }

+ 10 - 1
routers/commentsRouter.go

@@ -10404,13 +10404,22 @@ func init() {
 
     beego.GlobalControllerRouter["eta/eta_api/controllers:TradeCommonController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers:TradeCommonController"],
         beego.ControllerComments{
-            Method: "FenweiIndexData",
+            Method: "HisugarIndexData",
             Router: `/data/hisugar/index/data`,
             AllowHTTPMethods: []string{"get"},
             MethodParams: param.Make(),
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta/eta_api/controllers:TradeCommonController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers:TradeCommonController"],
+        beego.ControllerComments{
+            Method: "GetHisugarIndexInfo",
+            Router: `/data/hisugar/index/info`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_api/controllers:TradeCommonController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers:TradeCommonController"],
         beego.ControllerComments{
             Method: "HisugarIndexList",

+ 53 - 0
services/data/base_from_hisugar.go

@@ -4,6 +4,7 @@ import (
 	"eta/eta_api/models/data_manage"
 	"eta/eta_api/utils"
 	"fmt"
+	"github.com/rdlucklib/rdluck_tools/paging"
 )
 
 type HisugarIndexSource2EdbReq struct {
@@ -60,3 +61,55 @@ func HisugarIndexSource2Edb(req HisugarIndexSource2EdbReq, lang string) (edb *da
 	return
 }
 
+
+
+// GethisugarIndexInfo 获取指标信息-分页
+func GethisugarIndexInfo(keyWord string, classifyIdList []string, frequencyList []string, currentIndex int, pageSize int) (baseFromHisugarIndexPage *data_manage.BaseFromHisugarIndexPage, err error) {
+
+	// 获取指标
+	var condition string
+	var pars []interface{}
+	if keyWord != "" {
+		condition += ` AND CONCAT(index_name,index_code) LIKE '%` + keyWord + `%'`
+	}
+	if len(classifyIdList) > 0 {
+		condition += ` AND classify_id IN (`
+		for _, v := range classifyIdList {
+			condition += `?,`
+			pars = append(pars, v)
+		}
+		condition = condition[:len(condition)-1] + `)`
+	}
+	if len(frequencyList) > 0 {
+		condition += ` AND frequency IN (`
+		for _, v := range frequencyList {
+			condition += `?,`
+			pars = append(pars, v)
+		}
+		condition = condition[:len(condition)-1] + `)`
+	}
+
+	count, err := data_manage.GetHisugarIndexInfoCount(condition, pars)
+	if err != nil {
+		return
+	}
+	page := paging.GetPaging(currentIndex, pageSize, count)
+	if count <= 0 {
+		baseFromHisugarIndexPage = &data_manage.BaseFromHisugarIndexPage{
+			List:   []*data_manage.BaseFromHisugarIndex{},
+			Paging: page,
+		}
+		return
+	}
+
+	startSize := utils.StartIndex(currentIndex, pageSize)
+	fenWeiIndexInfoList, err := data_manage.GetHisugarIndexInfoPage(condition, pars, startSize, pageSize)
+	if err != nil {
+		return
+	}
+	baseFromHisugarIndexPage = &data_manage.BaseFromHisugarIndexPage{
+		List:   fenWeiIndexInfoList,
+		Paging: page,
+	}
+	return
+}