Files
2026-10-08 15:44:07 +08:00

29 lines
1.5 KiB
C#

using F9WebAiTest.Application.Common;
using F9WebAiTest.Application.Dtos.SYS.Gongyingshangs;
using F9WebAiTest.Application.Interfaces.Repositories.SYS.Gongyingshangs;
using F9WebAiTest.Domain.Enums.SYS.Gongyingshangs;
using MediatR;
namespace F9WebAiTest.Application.CQRS.SYS.Gongyingshangs.Queries;
/// <summary>往来单位分页查询(业务类型 + 销售类型 + 关键字)</summary>
public record GetGongyingshangPagedQuery(Gys_Type_Enum Type = Gys_Type_Enum.干茧, Gys_SaleType_Enum? SaleType = null,
string Like = "", int PageIndex = 1, int PageSize = 20) : IRequest<PageResult<GongyingshangReadDto_View>>;
public class GetGongyingshangPagedQueryHandler(IGongyingshangReadRepository readRepository)
: IRequestHandler<GetGongyingshangPagedQuery, PageResult<GongyingshangReadDto_View>>
{
public async Task<PageResult<GongyingshangReadDto_View>> Handle(GetGongyingshangPagedQuery query, CancellationToken ct)
=> await readRepository.GetPagedAsync(query.Type, query.SaleType, query.Like, query.PageIndex, query.PageSize);
}
/// <summary>按 Id 查询往来单位(编辑回显)</summary>
public record GetGongyingshangByIdQuery(long Id) : IRequest<GongyingshangDto_Edit>;
public class GetGongyingshangByIdQueryHandler(IGongyingshangReadRepository readRepository)
: IRequestHandler<GetGongyingshangByIdQuery, GongyingshangDto_Edit>
{
public async Task<GongyingshangDto_Edit> Handle(GetGongyingshangByIdQuery query, CancellationToken ct)
=> await readRepository.GetByIdForEditAsync(query.Id);
}