package logic import ( "context" "fmt" sysModel "sundynix-micro-go/app/system/model" "sundynix-micro-go/app/system/rpc/internal/svc" "sundynix-micro-go/app/system/rpc/system" "github.com/zeromicro/go-zero/core/logx" ) type CreateClientLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewCreateClientLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateClientLogic { return &CreateClientLogic{ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx)} } func (l *CreateClientLogic) CreateClient(in *system.ClientReq) (*system.CommonResp, error) { client := sysModel.SundynixClient{ ClientID: in.ClientId, Name: in.Name, GrantType: in.GrantType, AdditionalInfo: in.AdditionalInfo, ActiveTimeout: in.ActiveTimeout, } if err := l.svcCtx.DB.Create(&client).Error; err != nil { return nil, fmt.Errorf("创建客户端失败: %v", err) } return &system.CommonResp{Code: 200, Msg: "success"}, nil }