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 AssignUserRolesLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

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

func (l *AssignUserRolesLogic) AssignUserRoles(req *types.AssignUserRolesReq) error {
	_, err := l.svcCtx.SystemRpc.AssignUserRoles(l.ctx, &system.AssignUserRolesReq{
		UserId:  req.UserId,
		RoleIds: req.RoleIds,
	})
	return err
}
