Browse Source

Merge branch 'ETA_1.4.4' into debug

zwxi 1 year ago
parent
commit
e30ca69163
3 changed files with 136 additions and 0 deletions
  1. 96 0
      controllers/data_manage/smm_api.go
  2. 31 0
      models/data_manage/base_from_smm.go
  3. 9 0
      routers/commentsRouter.go

+ 96 - 0
controllers/data_manage/smm_api.go

@@ -0,0 +1,96 @@
+package data_manage
+
+import (
+	"eta/eta_api/models"
+	"eta/eta_api/models/data_manage"
+	"eta/eta_api/utils"
+	"fmt"
+	"github.com/rdlucklib/rdluck_tools/paging"
+)
+
+// SmmIndexList
+// @Title 有色api数据指标列表
+// @Description 有色api数据指标列表
+// @Success 200 {object} data_manage.SmmClassify
+// @router /smm/api/list [get]
+func (this *EdbInfoController) SmmApiList() {
+	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
+	}
+	types := this.GetString("Types")
+	frequency := this.GetString("Frequency")
+	dataState := this.GetString("DataState")
+	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
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = utils.StartIndex(currentIndex, pageSize)
+
+	var condition string
+	var pars []interface{}
+
+	if types != "" {
+
+	}
+
+	if frequency != "" {
+		condition += " ADN frequency = ? "
+		pars = append(pars, frequency)
+	}
+
+	if dataState != "" {
+		if dataState == "normal" {
+			condition += " AND (data_state = 'normal' OR data_state = '') "
+			pars = append(pars, dataState)
+		} else {
+			condition += " AND data_state = ? "
+			pars = append(pars, dataState)
+		}
+	}
+
+	sortStr := ``
+	if sortParam != `` {
+		sortStr = fmt.Sprintf("%s %s,modify_time desc ", sortParam, sortType)
+	} else {
+		sortStr = " data_time desc,modify_time desc "
+	}
+	total, err := data_manage.GetSmmIndexDataListCount(condition, pars)
+	if err!= nil {
+		br.Msg = "获取指标总数失败"
+		br.ErrMsg = "获取指标总数失败,Err:" + err.Error()
+		return
+	}
+
+	indexList, err := data_manage.GetSmmIndexDataList(condition, sortStr, pars, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取指标列表失败"
+		br.ErrMsg = "获取指标列表失败,Err:" + err.Error()
+		return
+	}
+
+
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	var ret data_manage.BaseFromSmmIndexListResp
+	ret.List = indexList
+	ret.Paging = page
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = ret
+}

+ 31 - 0
models/data_manage/base_from_smm.go

@@ -4,6 +4,7 @@ import (
 	"eta/eta_api/utils"
 	"fmt"
 	"github.com/beego/beego/v2/client/orm"
+	"github.com/rdlucklib/rdluck_tools/paging"
 	"time"
 )
 
@@ -72,6 +73,7 @@ type BaseFromSmmIndex struct {
 	Sort               int
 	CreateTime         time.Time
 	ModifyTime         time.Time
+	data_state         string
 }
 
 func AddBaseFromSmmIndex(item *BaseFromSmmIndex) (lastId int64, err error) {
@@ -327,3 +329,32 @@ type SmmSingleDataResp struct {
 	ModifyTime         string
 	Data               []*SmmIndexData
 }
+
+func GetSmmIndexDataList(condition, sortStr string, pars []interface{}, startSize, pageSize int) (items []*BaseFromSmmIndex, err error) {
+	sql := `select * FROM base_from_smm_index
+               WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` ORDER BY ` + sortStr
+	sql += `  limit ?,? `
+	o := orm.NewOrmUsingDB("data")
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+func GetSmmIndexDataListCount(condition string, pars []interface{}) (total int, err error) {
+	sql := `select count(1) FROM base_from_smm_index
+               WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	o := orm.NewOrmUsingDB("data")
+	err = o.Raw(sql, pars).QueryRow(&total)
+	return
+}
+
+type BaseFromSmmIndexListResp struct {
+	List   []*BaseFromSmmIndex
+	Paging *paging.PagingItem `description:"分页数据"`
+}

+ 9 - 0
routers/commentsRouter.go

@@ -3409,6 +3409,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage:EdbInfoController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage:EdbInfoController"],
+        beego.ControllerComments{
+            Method: "SmmApiList",
+            Router: `/smm/api/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage:EdbInfoController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/data_manage:EdbInfoController"],
         beego.ControllerComments{
             Method: "SmmClassify",