using F9WebAiTest.Application.Common.Exceptions;
using F9WebAiTest.Domain.Interfaces.SYS.RBAC.Menus;
using MediatR;
namespace F9WebAiTest.Application.CQRS.SYS.RBAC.Menus.Commands;
/// 命令定义
public record Menu_DelCommand(long Id) : IRequest;
/// 命令处理器
public class DelMenuCommandHandler(
IMenuWriteRepository menuWriteRepository) : IRequestHandler
{
public async Task Handle(Menu_DelCommand command, CancellationToken cancellationToken)
{
if (command.Id <= 0) throw new F9OperationException("菜单ID不能为空");
var result = await menuWriteRepository.SoftDeleteAsync(command.Id);
if (result == false) throw new F9OperationException("菜单", "删除");
return result;
}
}