Commit 6caff425 authored by 李科's avatar 李科

Merge remote-tracking branch 'origin/dev' into dev

parents 6a02848b 7bce6f49
......@@ -45,3 +45,8 @@ type DictManageListReq struct {
MinVal string `json:"min_val" form:"min_val"` //最大值
MaxVal string `json:"max_val" form:"max_val"` //最小值
}
type DictSortInput struct {
Id string `json:"id"` //id
Sort int `json:"sort"` //排序
}
......@@ -169,6 +169,31 @@ func (d Dict) ClassList(c *gin.Context) {
SendJsonResponse(c, resp.OK, classList)
}
func (d Dict) DictSort(c *gin.Context) {
var (
err error
req []request.DictSortInput
)
err = c.ShouldBind(&req)
if err != nil {
SendJsonResponse(c, resp.InvalidParam.WithError(err), "")
return
}
svc := new(service.Dict)
svc.Ctx = c
svc.User = header.GetUser(c)
err = svc.DictSort(req)
if err != nil {
SendJsonResponse(c, resp.FAIL.WithError(err), "")
return
}
SendJsonResponse(c, resp.OK, "")
}
// List 组件列表
//func (d Dict) ManageList(c *gin.Context) {
//
......
......@@ -21,6 +21,7 @@ func initDictRoute(e *gin.Engine) {
base.GET("", dict.List) //字典列表
base.GET("/tree", dict.DictTree) //字典列表-树结构
base.GET("/classList", dict.ClassList) //字典分类列表
base.PUT("/sort", dict.DictSort) //字典排序
//base.GET("/manage_list", dict.ManageList) //字典管理列表
}
......@@ -5,9 +5,12 @@ import (
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/bean/vo/request"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/bean/vo/response"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/common/client"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/common/conf"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/jsontime"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/resp"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/util"
"go.uber.org/zap"
"xorm.io/xorm"
"github.com/gin-gonic/gin"
"github.com/pkg/errors"
......@@ -235,6 +238,31 @@ func (c *Dict) ClassList(className string) (classList []response.ClassListRes, e
return
}
func (c *Dict) DictSort(req []request.DictSortInput) error {
db, err := client.GetDbClient()
if err != nil {
return resp.DbConnectError.ErrorDetail(err)
}
_, err = db.Transaction(func(x *xorm.Session) (interface{}, error) {
for _, v := range req {
_, err := x.Table("dict").Cols("sort, updated_at, updated_by").Where("id = ? and is_delete = 0", v.Id).Update(
&entity.Dict{
Sort: v.Sort,
UpdatedBy: c.User.Id,
UpdatedAt: jsontime.Time(time.Now()),
})
if err != nil {
conf.Logger.Error("排序失败", zap.Error(err))
return nil, resp.DbUpdateError.ErrorDetail(err)
}
}
return nil, nil
})
return err
}
//func (c *Dict) ManageList(req request.DictManageListReq) (componentDictTreeRes []*response.DictListRes, err error) {
// listReq := request.DictReq{
// Class: req.Class,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment