|
@@ -6,6 +6,7 @@ import (
|
|
|
"eta/eta_api/utils"
|
|
|
"fmt"
|
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
|
+ "strings"
|
|
|
)
|
|
|
|
|
|
// SmmIndexList
|
|
@@ -29,10 +30,13 @@ func (this *EdbInfoController) SmmApiList() {
|
|
|
types := this.GetString("Types")
|
|
|
frequency := this.GetString("Frequency")
|
|
|
dataState := this.GetString("DataState")
|
|
|
+ keyword := this.GetString("Keyword")
|
|
|
+ indexCodes := this.GetString("IndexCodes")
|
|
|
sortType := this.GetString("SortType", "desc")
|
|
|
sortParam := this.GetString("SortParam")
|
|
|
pageSize, _ := this.GetInt("PageSize")
|
|
|
currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
+
|
|
|
var startSize int
|
|
|
if pageSize <= 0 {
|
|
|
pageSize = utils.PageSize20
|
|
@@ -57,19 +61,34 @@ func (this *EdbInfoController) SmmApiList() {
|
|
|
if dataState != "" {
|
|
|
if dataState == "normal" {
|
|
|
condition += " AND (data_state = 'normal' OR data_state = '') "
|
|
|
- pars = append(pars, dataState)
|
|
|
+ pars = append(pars)
|
|
|
} else {
|
|
|
condition += " AND data_state = ? "
|
|
|
pars = append(pars, dataState)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if keyword != "" {
|
|
|
+ condition += " AND (index_name LIKE ? OR index_code LIKE ?) "
|
|
|
+ pars = utils.GetLikeKeywordPars(pars, keyword, 2)
|
|
|
+ }
|
|
|
+
|
|
|
+ if indexCodes != "" {
|
|
|
+ indexCodeArr := strings.Split(indexCodes,",")
|
|
|
+ indexCodeStr := ""
|
|
|
+ for _, v := range indexCodeArr {
|
|
|
+ indexCodeStr += "'" + v + "',"
|
|
|
+ }
|
|
|
+ condition += " AND index_code IN (" + indexCodeStr + ") "
|
|
|
+ }
|
|
|
+
|
|
|
sortStr := ``
|
|
|
if sortParam != `` {
|
|
|
- sortStr = fmt.Sprintf("%s %s,modify_time desc ", sortParam, sortType)
|
|
|
+ sortStr = fmt.Sprintf("%s %s,modify_time desc ", utils.PascalToSnake(sortParam), sortType)
|
|
|
} else {
|
|
|
sortStr = " modify_time desc "
|
|
|
}
|
|
|
+
|
|
|
total, err := data_manage.GetSmmIndexDataListCount(condition, pars)
|
|
|
if err!= nil {
|
|
|
br.Msg = "获取指标总数失败"
|
|
@@ -97,3 +116,71 @@ func (this *EdbInfoController) SmmApiList() {
|
|
|
br.Msg = "获取成功"
|
|
|
br.Data = ret
|
|
|
}
|
|
|
+
|
|
|
+// SmmApiTypeList
|
|
|
+// @Title 有色api数据分类列表
|
|
|
+// @Description 有色api数据分类列表
|
|
|
+// @Success 200 {object} data_manage.SmmClassify
|
|
|
+// @router /smm/api/type/list [get]
|
|
|
+func (this *EdbInfoController) SmmApiTypeList() {
|
|
|
+ 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
|
|
|
+ }
|
|
|
+
|
|
|
+ typeList, err := data_manage.GetBaseFromSmmIndexTypeList()
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取指标列表失败"
|
|
|
+ br.ErrMsg = "获取指标列表失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ resp := make([]data_manage.TypeListRespItem, 0)
|
|
|
+
|
|
|
+ typeMap := make(map[string]map[string][]string)
|
|
|
+ //type2Map := make(map[string][]string)
|
|
|
+
|
|
|
+ //type2Map := make(map[string]data_manage.TypeListRespItem)
|
|
|
+
|
|
|
+ // 初始化
|
|
|
+ for _, v := range typeList {
|
|
|
+ if _, ok := typeMap[v.Type1];!ok {
|
|
|
+ typeMap[v.Type1] = make(map[string][]string)
|
|
|
+ } else {
|
|
|
+ if _, ok := typeMap[v.Type1][v.Type2];!ok {
|
|
|
+ typeMap[v.Type1][v.Type2] = make([]string, 0)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range typeList {
|
|
|
+ typeMap[v.Type1][v.Type2] = append(typeMap[v.Type1][v.Type2], v.Type3)
|
|
|
+ }
|
|
|
+
|
|
|
+ for type1, type2Map := range typeMap {
|
|
|
+ var item data_manage.TypeListRespItem
|
|
|
+ item.Type = type1
|
|
|
+ for type2, type3List := range type2Map {
|
|
|
+ var child data_manage.TypeListRespItem
|
|
|
+ child.Type = type2
|
|
|
+ for _, type3 := range type3List {
|
|
|
+ child.Child = append(child.Child, data_manage.TypeListRespItem{type3,nil})
|
|
|
+ }
|
|
|
+ item.Child = append(item.Child, child)
|
|
|
+ }
|
|
|
+ resp = append(resp, item)
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = resp
|
|
|
+}
|