From 4745c91915b9474aa8e6272addc11aab06485969 Mon Sep 17 00:00:00 2001 From: Sam <315859133@qq.com> Date: Mon, 9 Feb 2026 18:57:52 +0800 Subject: [PATCH] feat: add calculate points command --- .../Commands/Points/CalculatePointsCommand.cs | 6 ++++++ .../Points/CalculatePointsCommandHandler.cs | 21 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 src/Fengling.Member.Application/Commands/Points/CalculatePointsCommand.cs create mode 100644 src/Fengling.Member.Application/Commands/Points/CalculatePointsCommandHandler.cs diff --git a/src/Fengling.Member.Application/Commands/Points/CalculatePointsCommand.cs b/src/Fengling.Member.Application/Commands/Points/CalculatePointsCommand.cs new file mode 100644 index 0000000..caa4349 --- /dev/null +++ b/src/Fengling.Member.Application/Commands/Points/CalculatePointsCommand.cs @@ -0,0 +1,6 @@ +using Fengling.Member.Application.Dtos; +using MediatR; + +namespace Fengling.Member.Application.Commands.Points; + +public record CalculatePointsCommand(CodeInfoDto CodeInfo) : IRequest; diff --git a/src/Fengling.Member.Application/Commands/Points/CalculatePointsCommandHandler.cs b/src/Fengling.Member.Application/Commands/Points/CalculatePointsCommandHandler.cs new file mode 100644 index 0000000..6d5e404 --- /dev/null +++ b/src/Fengling.Member.Application/Commands/Points/CalculatePointsCommandHandler.cs @@ -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 +{ + private readonly PointsRuleMatcher _matcher; + + public CalculatePointsCommandHandler(PointsRuleMatcher matcher) + { + _matcher = matcher; + } + + public async Task Handle(CalculatePointsCommand request, CancellationToken cancellationToken) + { + return await _matcher.CalculatePointsAsync(request.CodeInfo); + } +}