feat: add calculate points command
This commit is contained in:
parent
9ee1e3bb72
commit
4745c91915
@ -0,0 +1,6 @@
|
|||||||
|
using Fengling.Member.Application.Dtos;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace Fengling.Member.Application.Commands.Points;
|
||||||
|
|
||||||
|
public record CalculatePointsCommand(CodeInfoDto CodeInfo) : IRequest<PointsCalculationResultDto>;
|
||||||
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user