mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 18:52:08 +08:00
- 将命令相关抽象接口从command目录迁移至cqrs.command目录 - 新增CommandBase、NotificationBase、QueryBase和RequestBase通用基类 - 统一所有CQRS组件的命名空间为GFramework.Core.Abstractions.cqrs - 更新所有引用位置的using语句指向新的命名空间路径 - 为命令和查询输入接口添加IInput基接口继承 - 在测试文件中同步更新相关的引用路径修改
31 lines
1.2 KiB
C#
31 lines
1.2 KiB
C#
using GFramework.Core.Abstractions.command;
|
|
using GFramework.Core.Abstractions.cqrs.command;
|
|
using GFramework.Core.rule;
|
|
|
|
namespace GFramework.Core.command;
|
|
|
|
/// <summary>
|
|
/// 带返回值的抽象命令类,实现 ICommand{TResult} 接口,为需要返回结果的命令提供基础架构支持
|
|
/// </summary>
|
|
/// <typeparam name="TInput">命令输入参数类型,必须实现 ICommandInput 接口</typeparam>
|
|
/// <typeparam name="TResult">命令执行后返回的结果类型</typeparam>
|
|
/// <param name="input">命令执行所需的输入参数</param>
|
|
public abstract class AbstractCommand<TInput, TResult>(TInput input) : ContextAwareBase, ICommand<TResult>
|
|
where TInput : ICommandInput
|
|
{
|
|
/// <summary>
|
|
/// 执行命令的入口方法,实现 ICommand{TResult} 接口的 Execute 方法
|
|
/// </summary>
|
|
/// <returns>命令执行后的结果</returns>
|
|
TResult ICommand<TResult>.Execute()
|
|
{
|
|
return OnExecute(input);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 命令执行的抽象方法,由派生类实现具体的命令逻辑
|
|
/// </summary>
|
|
/// <param name="input">命令执行所需的输入参数</param>
|
|
/// <returns>命令执行后的结果</returns>
|
|
protected abstract TResult OnExecute(TInput input);
|
|
} |