package client

import (
	"context"
	"github.com/zeromicro/go-zero/core/logx"
	"sundynix-micro-go/app/system/api/internal/svc"
	"sundynix-micro-go/app/system/api/internal/types"
	"sundynix-micro-go/app/system/rpc/system"
)

type UpdateClientLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUpdateClientLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateClientLogic {
	return &UpdateClientLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
}

func (l *UpdateClientLogic) UpdateClient(req *types.ClientUpdateReq) error {
	_, 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
}
