update:添加领域事件
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using Base62;
|
using Base62;
|
||||||
|
using Domain.Events;
|
||||||
using Domain.SeedWork;
|
using Domain.SeedWork;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -40,6 +41,8 @@ namespace Domain.AggregateModel.LinkAggregate
|
|||||||
AppId = appId;
|
AppId = appId;
|
||||||
Time = DateTime.Now;
|
Time = DateTime.Now;
|
||||||
CalculateShortCode();
|
CalculateShortCode();
|
||||||
|
|
||||||
|
AddDomainEvent(new LinkCreatedDomainEvent(this));
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据值计算短链字段
|
/// 根据值计算短链字段
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Domain.Events;
|
||||||
|
using MediatR;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace QRCodeService.Application.DomainEventHandler.LinkCreated
|
||||||
|
{
|
||||||
|
public class LogWhenLinkCreatedDomainEventHandler : INotificationHandler<LinkCreatedDomainEvent>
|
||||||
|
{
|
||||||
|
readonly ILogger<LogWhenLinkCreatedDomainEventHandler> logger;
|
||||||
|
|
||||||
|
public LogWhenLinkCreatedDomainEventHandler(ILogger<LogWhenLinkCreatedDomainEventHandler> logger)
|
||||||
|
{
|
||||||
|
this.logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Handle(LinkCreatedDomainEvent notification, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
logger.LogInformation("domainEvent: link");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user