From d881bd5ad1db58f344ad61bbbaa704bb99233fe6 Mon Sep 17 00:00:00 2001 From: GeWuYou <95328647+GeWuYou@users.noreply.github.com> Date: Wed, 15 Apr 2026 19:02:53 +0800 Subject: [PATCH] =?UTF-8?q?refactor(cqrs):=20=E7=AE=80=E5=8C=96=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=AE=9A=E4=B9=89=E5=B9=B6=E5=88=86=E7=A6=BB=E6=B5=81?= =?UTF-8?q?=E5=BC=8F=E5=91=BD=E4=BB=A4=E5=92=8C=E6=9F=A5=E8=AF=A2=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除 ICommand 和 ICommand 的空实现体 - 移除 IQuery 和 IStreamQuery 的空实现体 - 移除 INotification、IRequest、IStreamRequest 的空实现体 - 将 IStreamCommand 分离到独立文件中 - 将 IStreamQuery 分离到独立文件中 - 保持所有接口的核心功能不变,仅简化语法结构 --- .../Cqrs/Command/ICommand.cs | 16 ++------------- .../Cqrs/Command/IStreamCommand.cs | 20 +++++++++++++++++++ .../Cqrs/INotification.cs | 4 +--- GFramework.Cqrs.Abstractions/Cqrs/IRequest.cs | 4 +--- .../Cqrs/IStreamRequest.cs | 4 +--- .../Cqrs/Query/IQuery.cs | 12 +---------- .../Cqrs/Query/IStreamQuery.cs | 20 +++++++++++++++++++ 7 files changed, 46 insertions(+), 34 deletions(-) create mode 100644 GFramework.Cqrs.Abstractions/Cqrs/Command/IStreamCommand.cs create mode 100644 GFramework.Cqrs.Abstractions/Cqrs/Query/IStreamQuery.cs diff --git a/GFramework.Cqrs.Abstractions/Cqrs/Command/ICommand.cs b/GFramework.Cqrs.Abstractions/Cqrs/Command/ICommand.cs index 6eaa1869..9c62f8f5 100644 --- a/GFramework.Cqrs.Abstractions/Cqrs/Command/ICommand.cs +++ b/GFramework.Cqrs.Abstractions/Cqrs/Command/ICommand.cs @@ -5,21 +5,9 @@ namespace GFramework.Cqrs.Abstractions.Cqrs.Command; /// 命令通常用于修改系统状态。 /// /// 命令响应类型。 -public interface ICommand : IRequest -{ -} +public interface ICommand : IRequest; /// /// 表示一个无显式返回值的 CQRS 命令。 /// -public interface ICommand : ICommand -{ -} - -/// -/// 表示一个流式 CQRS 命令。 -/// -/// 流式响应元素类型。 -public interface IStreamCommand : IStreamRequest -{ -} +public interface ICommand : ICommand; diff --git a/GFramework.Cqrs.Abstractions/Cqrs/Command/IStreamCommand.cs b/GFramework.Cqrs.Abstractions/Cqrs/Command/IStreamCommand.cs new file mode 100644 index 00000000..51323d19 --- /dev/null +++ b/GFramework.Cqrs.Abstractions/Cqrs/Command/IStreamCommand.cs @@ -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; + +/// +/// 表示一个流式 CQRS 命令。 +/// +/// 流式响应元素类型。 +public interface IStreamCommand : IStreamRequest; diff --git a/GFramework.Cqrs.Abstractions/Cqrs/INotification.cs b/GFramework.Cqrs.Abstractions/Cqrs/INotification.cs index 727f9c07..4a2dbb68 100644 --- a/GFramework.Cqrs.Abstractions/Cqrs/INotification.cs +++ b/GFramework.Cqrs.Abstractions/Cqrs/INotification.cs @@ -4,6 +4,4 @@ namespace GFramework.Cqrs.Abstractions.Cqrs; /// 表示一个一对多发布的通知消息。 /// 通知不要求返回值,允许被零个或多个处理器消费。 /// -public interface INotification -{ -} +public interface INotification; diff --git a/GFramework.Cqrs.Abstractions/Cqrs/IRequest.cs b/GFramework.Cqrs.Abstractions/Cqrs/IRequest.cs index 78627e4b..dd6abb62 100644 --- a/GFramework.Cqrs.Abstractions/Cqrs/IRequest.cs +++ b/GFramework.Cqrs.Abstractions/Cqrs/IRequest.cs @@ -5,6 +5,4 @@ namespace GFramework.Cqrs.Abstractions.Cqrs; /// 该接口是命令、查询以及其他请求语义的统一基接口。 /// /// 请求响应类型。 -public interface IRequest -{ -} +public interface IRequest; diff --git a/GFramework.Cqrs.Abstractions/Cqrs/IStreamRequest.cs b/GFramework.Cqrs.Abstractions/Cqrs/IStreamRequest.cs index 37a211d4..5464459b 100644 --- a/GFramework.Cqrs.Abstractions/Cqrs/IStreamRequest.cs +++ b/GFramework.Cqrs.Abstractions/Cqrs/IStreamRequest.cs @@ -5,6 +5,4 @@ namespace GFramework.Cqrs.Abstractions.Cqrs; /// 请求处理器可以逐步产生响应序列,而不是一次性返回完整结果。 /// /// 流式响应元素类型。 -public interface IStreamRequest -{ -} +public interface IStreamRequest; diff --git a/GFramework.Cqrs.Abstractions/Cqrs/Query/IQuery.cs b/GFramework.Cqrs.Abstractions/Cqrs/Query/IQuery.cs index 9592a9bd..edf5e1a2 100644 --- a/GFramework.Cqrs.Abstractions/Cqrs/Query/IQuery.cs +++ b/GFramework.Cqrs.Abstractions/Cqrs/Query/IQuery.cs @@ -5,14 +5,4 @@ namespace GFramework.Cqrs.Abstractions.Cqrs.Query; /// 查询用于读取数据,不应产生副作用。 /// /// 查询响应类型。 -public interface IQuery : IRequest -{ -} - -/// -/// 表示一个流式 CQRS 查询。 -/// -/// 流式响应元素类型。 -public interface IStreamQuery : IStreamRequest -{ -} +public interface IQuery : IRequest; diff --git a/GFramework.Cqrs.Abstractions/Cqrs/Query/IStreamQuery.cs b/GFramework.Cqrs.Abstractions/Cqrs/Query/IStreamQuery.cs new file mode 100644 index 00000000..150fb32c --- /dev/null +++ b/GFramework.Cqrs.Abstractions/Cqrs/Query/IStreamQuery.cs @@ -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; + +/// +/// 表示一个流式 CQRS 查询。 +/// +/// 流式响应元素类型。 +public interface IStreamQuery : IStreamRequest;