feat: 初次启动
This commit is contained in:
@@ -1,17 +1,11 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package client
|
||||
|
||||
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"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/system/rpc/system"
|
||||
)
|
||||
|
||||
type UpdateClientLogic struct {
|
||||
@@ -21,34 +15,13 @@ type UpdateClientLogic struct {
|
||||
}
|
||||
|
||||
func NewUpdateClientLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateClientLogic {
|
||||
return &UpdateClientLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
return &UpdateClientLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *UpdateClientLogic) UpdateClient(req *types.ClientUpdateReq) error {
|
||||
updates := map[string]interface{}{}
|
||||
if req.ClientId != "" {
|
||||
updates["client_id"] = req.ClientId
|
||||
}
|
||||
if req.Name != "" {
|
||||
updates["name"] = req.Name
|
||||
}
|
||||
if req.GrantType != "" {
|
||||
updates["grant_type"] = req.GrantType
|
||||
}
|
||||
if req.AdditionalInfo != "" {
|
||||
updates["additional_info"] = req.AdditionalInfo
|
||||
}
|
||||
if req.ActiveTimeout > 0 {
|
||||
updates["active_timeout"] = req.ActiveTimeout
|
||||
}
|
||||
|
||||
if err := l.svcCtx.DB.Model(&sysModel.SundynixClient{}).Where("id = ?", req.Id).Updates(updates).Error; err != nil {
|
||||
l.Errorf("更新客户端失败: %v", err)
|
||||
return fmt.Errorf("更新客户端失败")
|
||||
}
|
||||
return nil
|
||||
_, err := l.svcCtx.SystemRpc.UpdateClient(l.ctx, &system.ClientUpdateReq{
|
||||
Id: req.Id, ClientId: req.ClientId, Name: req.Name, GrantType: req.GrantType,
|
||||
AdditionalInfo: req.AdditionalInfo, ActiveTimeout: req.ActiveTimeout,
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user