refactor(cqrs): 简化接口定义并分离流式命令和查询接口

- 移除 ICommand<TResponse> 和 ICommand 的空实现体
- 移除 IQuery<TResponse> 和 IStreamQuery<TResponse> 的空实现体
- 移除 INotification、IRequest<TResponse>、IStreamRequest<TResponse> 的空实现体
- 将 IStreamCommand<TResponse> 分离到独立文件中
- 将 IStreamQuery<TResponse> 分离到独立文件中
- 保持所有接口的核心功能不变,仅简化语法结构
This commit is contained in:
GeWuYou 2026-04-15 19:02:53 +08:00
parent fe73d13991
commit d881bd5ad1
7 changed files with 46 additions and 34 deletions

View File

@ -5,21 +5,9 @@ namespace GFramework.Cqrs.Abstractions.Cqrs.Command;
/// 命令通常用于修改系统状态。
/// </summary>
/// <typeparam name="TResponse">命令响应类型。</typeparam>
public interface ICommand<out TResponse> : IRequest<TResponse>
{
}
public interface ICommand<out TResponse> : IRequest<TResponse>;
/// <summary>
/// 表示一个无显式返回值的 CQRS 命令。
/// </summary>
public interface ICommand : ICommand<Unit>
{
}
/// <summary>
/// 表示一个流式 CQRS 命令。
/// </summary>
/// <typeparam name="TResponse">流式响应元素类型。</typeparam>
public interface IStreamCommand<out TResponse> : IStreamRequest<TResponse>
{
}
public interface ICommand : ICommand<Unit>;

View File

@ -0,0 +1,20 @@
// Copyright (c) 2026 GeWuYou
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
namespace GFramework.Cqrs.Abstractions.Cqrs.Command;
/// <summary>
/// 表示一个流式 CQRS 命令。
/// </summary>
/// <typeparam name="TResponse">流式响应元素类型。</typeparam>
public interface IStreamCommand<out TResponse> : IStreamRequest<TResponse>;

View File

@ -4,6 +4,4 @@ namespace GFramework.Cqrs.Abstractions.Cqrs;
/// 表示一个一对多发布的通知消息。
/// 通知不要求返回值,允许被零个或多个处理器消费。
/// </summary>
public interface INotification
{
}
public interface INotification;

View File

@ -5,6 +5,4 @@ namespace GFramework.Cqrs.Abstractions.Cqrs;
/// 该接口是命令、查询以及其他请求语义的统一基接口。
/// </summary>
/// <typeparam name="TResponse">请求响应类型。</typeparam>
public interface IRequest<out TResponse>
{
}
public interface IRequest<out TResponse>;

View File

@ -5,6 +5,4 @@ namespace GFramework.Cqrs.Abstractions.Cqrs;
/// 请求处理器可以逐步产生响应序列,而不是一次性返回完整结果。
/// </summary>
/// <typeparam name="TResponse">流式响应元素类型。</typeparam>
public interface IStreamRequest<out TResponse>
{
}
public interface IStreamRequest<out TResponse>;

View File

@ -5,14 +5,4 @@ namespace GFramework.Cqrs.Abstractions.Cqrs.Query;
/// 查询用于读取数据,不应产生副作用。
/// </summary>
/// <typeparam name="TResponse">查询响应类型。</typeparam>
public interface IQuery<out TResponse> : IRequest<TResponse>
{
}
/// <summary>
/// 表示一个流式 CQRS 查询。
/// </summary>
/// <typeparam name="TResponse">流式响应元素类型。</typeparam>
public interface IStreamQuery<out TResponse> : IStreamRequest<TResponse>
{
}
public interface IQuery<out TResponse> : IRequest<TResponse>;

View File

@ -0,0 +1,20 @@
// Copyright (c) 2026 GeWuYou
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
namespace GFramework.Cqrs.Abstractions.Cqrs.Query;
/// <summary>
/// 表示一个流式 CQRS 查询。
/// </summary>
/// <typeparam name="TResponse">流式响应元素类型。</typeparam>
public interface IStreamQuery<out TResponse> : IStreamRequest<TResponse>;