diff --git a/GFramework.Core.Abstractions/command/ICommandInput.cs b/GFramework.Core.Abstractions/command/ICommandInput.cs
new file mode 100644
index 0000000..57e68d7
--- /dev/null
+++ b/GFramework.Core.Abstractions/command/ICommandInput.cs
@@ -0,0 +1,7 @@
+namespace GFramework.Core.Abstractions.command;
+
+///
+/// 命令输入接口,定义命令模式中输入数据的契约
+/// 该接口作为标记接口使用,不包含任何成员定义
+///
+public interface ICommandInput;
\ No newline at end of file
diff --git a/GFramework.Core.Abstractions/query/IQueryInput.cs b/GFramework.Core.Abstractions/query/IQueryInput.cs
new file mode 100644
index 0000000..1a1933d
--- /dev/null
+++ b/GFramework.Core.Abstractions/query/IQueryInput.cs
@@ -0,0 +1,6 @@
+namespace GFramework.Core.Abstractions.query;
+
+///
+/// 查询输入接口,定义了查询操作的输入规范
+///
+public interface IQueryInput;
\ No newline at end of file
diff --git a/GFramework.Core/command/AbstractCommand.cs b/GFramework.Core/command/AbstractCommand.cs
index aef9baf..a5fa48b 100644
--- a/GFramework.Core/command/AbstractCommand.cs
+++ b/GFramework.Core/command/AbstractCommand.cs
@@ -6,40 +6,48 @@ namespace GFramework.Core.command;
///
/// 抽象命令类,实现 ICommand 接口,为具体命令提供基础架构支持
///
-public abstract class AbstractCommand : ContextAwareBase, ICommand
+/// 命令输入参数类型,必须实现 ICommandInput 接口
+/// 命令执行所需的输入参数
+public abstract class AbstractCommand(TInput input) : ContextAwareBase, ICommand
+ where TInput : ICommandInput
{
///
- /// 执行命令,调用抽象方法 OnExecute 来实现具体逻辑
+ /// 执行命令的入口方法,实现 ICommand 接口的 Execute 方法
///
void ICommand.Execute()
{
- OnExecute();
+ OnExecute(input);
}
///
- /// 抽象方法,由子类实现具体的命令执行逻辑
+ /// 命令执行的抽象方法,由派生类实现具体的命令逻辑
///
- protected abstract void OnExecute();
+ /// 命令执行所需的输入参数
+ protected abstract void OnExecute(TInput input);
}
///
/// 带返回值的抽象命令类,实现 ICommand{TResult} 接口,为需要返回结果的命令提供基础架构支持
///
+/// 命令输入参数类型,必须实现 ICommandInput 接口
/// 命令执行后返回的结果类型
-public abstract class AbstractCommand : ContextAwareBase, ICommand
+/// 命令执行所需的输入参数
+public abstract class AbstractCommand(TInput input) : ContextAwareBase, ICommand
+ where TInput : ICommandInput
{
///
- /// 执行命令,调用抽象方法 OnExecute 来实现具体逻辑并返回结果
+ /// 执行命令的入口方法,实现 ICommand{TResult} 接口的 Execute 方法
///
- /// TResult 类型的执行结果
+ /// 命令执行后的结果
TResult ICommand.Execute()
{
- return OnExecute();
+ return OnExecute(input);
}
///
- /// 抽象方法,由子类实现具体的命令执行逻辑
+ /// 命令执行的抽象方法,由派生类实现具体的命令逻辑
///
- /// TResult 类型的执行结果
- protected abstract TResult OnExecute();
+ /// 命令执行所需的输入参数
+ /// 命令执行后的结果
+ protected abstract TResult OnExecute(TInput input);
}
\ No newline at end of file
diff --git a/GFramework.Core/query/AbstractQuery.cs b/GFramework.Core/query/AbstractQuery.cs
index fbbc1fe..fba9bba 100644
--- a/GFramework.Core/query/AbstractQuery.cs
+++ b/GFramework.Core/query/AbstractQuery.cs
@@ -6,21 +6,24 @@ namespace GFramework.Core.query;
///
/// 抽象查询类,提供查询操作的基础实现
///
-/// 查询结果的类型
-public abstract class AbstractQuery : ContextAwareBase, IQuery
+/// 查询输入参数的类型,必须实现IQueryInput接口
+/// 查询结果的类型
+public abstract class AbstractQuery(TInput input) : ContextAwareBase, IQuery
+ where TInput : IQueryInput
{
///
/// 执行查询操作
///
- /// 查询结果
- public T Do()
+ /// 查询结果,类型为TResult
+ public TResult Do()
{
- return OnDo();
+ return OnDo(input);
}
///
- /// 抽象方法,由子类实现具体的查询逻辑
+ /// 抽象方法,用于实现具体的查询逻辑
///
- /// 查询结果
- protected abstract T OnDo();
+ /// 查询输入参数
+ /// 查询结果,类型为TResult
+ protected abstract TResult OnDo(TInput input);
}
\ No newline at end of file