package role

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

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

func (l *AssignRoleMenusLogic) AssignRoleMenus(req *types.AssignRoleMenusReq) error {
	_, err := l.svcCtx.SystemRpc.AssignRoleMenus(l.ctx, &system.AssignRoleMenusReq{
		RoleId:  req.RoleId,
		MenuIds: req.MenuIds,
	})
	return err
}
