// 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.
using GFramework.Core.Rule;
using Mediator;
namespace GFramework.Core.Cqrs.Request;
///
/// 抽象请求处理器基类,用于处理不返回具体响应的请求
/// 继承自ContextAwareBase并实现IRequestHandler接口
///
/// 请求类型,必须实现IRequest[Unit]接口
public abstract class AbstractRequestHandler : ContextAwareBase, IRequestHandler
where TRequest : IRequest
{
///
/// 处理请求的核心方法
///
/// 要处理的请求对象
/// 取消令牌,用于取消操作
/// 表示异步操作的ValueTask,完成时返回Unit值
public abstract ValueTask Handle(TRequest request, CancellationToken cancellationToken);
}
///
/// 抽象请求处理器基类,用于处理需要返回具体响应的请求
/// 继承自ContextAwareBase并实现IRequestHandler接口
///
/// 请求类型,必须实现IRequest[TResponse]接口
/// 响应类型
public abstract class AbstractRequestHandler : ContextAwareBase,
IRequestHandler where TRequest : IRequest
{
///
/// 处理请求并返回响应的核心方法
///
/// 要处理的请求对象
/// 取消令牌,用于取消操作
/// 表示异步操作的ValueTask,完成时返回处理结果
public abstract ValueTask Handle(TRequest request, CancellationToken cancellationToken);
}