package user

import (
	"context"

	"sundynix-micro-go/app/system/api/internal/svc"
	"sundynix-micro-go/app/system/api/internal/types"
	"sundynix-micro-go/app/system/rpc/system"

	"github.com/zeromicro/go-zero/core/logx"
)

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

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

func (l *UpdateUserLogic) UpdateUser(req *types.UserUpdateReq) error {
	_, err := l.svcCtx.SystemRpc.UpdateUser(l.ctx, &system.UpdateUserReq{
		Id:       req.Id,
		Name:     req.Name,
		Account:  req.Account,
		Phone:    req.Phone,
		NickName: req.NickName,
	})
	return err
}
