first commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using F9WebAiTest.Application.Common.Exceptions;
|
||||
using F9WebAiTest.Domain.Interfaces.SYS.RBAC.Roles;
|
||||
using MediatR;
|
||||
|
||||
namespace F9WebAiTest.Application.CQRS.SYS.RBAC.Roles.Commands;
|
||||
|
||||
/// <summary>命令定义</summary>
|
||||
public record Role_DelCommand(long Id) : IRequest<bool>;
|
||||
|
||||
/// <summary>命令处理器</summary>
|
||||
public class DelRoleCommandHandler(
|
||||
IRoleWriteRepository roleWriteRepository) : IRequestHandler<Role_DelCommand, bool>
|
||||
{
|
||||
public async Task<bool> Handle(Role_DelCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
if (command.Id <= 0) throw new F9OperationException("角色ID不能为空");
|
||||
|
||||
var result = await roleWriteRepository.SoftDeleteAsync(command.Id);
|
||||
if (result == false) throw new F9OperationException("角色", "删除");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user