feat: 初次启动
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package dict
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
"sundynix-micro-go/app/system/rpc/system"
|
||||
)
|
||||
|
||||
type UpdateDictLogic struct {
|
||||
@@ -21,26 +19,8 @@ func NewUpdateDictLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Update
|
||||
}
|
||||
|
||||
func (l *UpdateDictLogic) UpdateDict(req *types.DictUpdateReq) error {
|
||||
updates := map[string]interface{}{}
|
||||
if req.Type != "" {
|
||||
updates["type"] = req.Type
|
||||
}
|
||||
if req.Label != "" {
|
||||
updates["label"] = req.Label
|
||||
}
|
||||
if req.Value != "" {
|
||||
updates["value"] = req.Value
|
||||
}
|
||||
if req.Sort > 0 {
|
||||
updates["sort"] = req.Sort
|
||||
}
|
||||
if req.Desc != "" {
|
||||
updates["desc"] = req.Desc
|
||||
}
|
||||
if len(updates) > 0 {
|
||||
if err := l.svcCtx.DB.Model(&sysModel.SundynixDict{}).Where("id = ?", req.Id).Updates(updates).Error; err != nil {
|
||||
return fmt.Errorf("更新字典失败")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
_, err := l.svcCtx.SystemRpc.UpdateDict(l.ctx, &system.DictUpdateReq{
|
||||
Id: req.Id, Type: req.Type, Label: req.Label, Value: req.Value, Sort: int32(req.Sort), Desc: req.Desc,
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user