feat: add calculate points command

This commit is contained in:
Sam 2026-02-09 18:57:52 +08:00
parent 9ee1e3bb72
commit 4745c91915
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,6 @@
using Fengling.Member.Application.Dtos;
using MediatR;
namespace Fengling.Member.Application.Commands.Points;
public record CalculatePointsCommand(CodeInfoDto CodeInfo) : IRequest<PointsCalculationResultDto>;

View File

@ -0,0 +1,21 @@
using Fengling.Member.Application.Commands.Points;
using Fengling.Member.Application.Dtos;
using Fengling.Member.Application.Services;
using MediatR;
namespace Fengling.Member.Application.Commands.Points;
public class CalculatePointsCommandHandler : IRequestHandler<CalculatePointsCommand, PointsCalculationResultDto>
{
private readonly PointsRuleMatcher _matcher;
public CalculatePointsCommandHandler(PointsRuleMatcher matcher)
{
_matcher = matcher;
}
public async Task<PointsCalculationResultDto> Handle(CalculatePointsCommand request, CancellationToken cancellationToken)
{
return await _matcher.CalculatePointsAsync(request.CodeInfo);
}
}