style: 修改聚合跟类命名

This commit is contained in:
橙子
2024-05-22 14:35:08 +08:00
parent f2e3c76539
commit 3429de9eb6
89 changed files with 446 additions and 412 deletions

View File

@@ -5,7 +5,7 @@ using Volo.Abp.Domain.Entities;
namespace Yi.Framework.Bbs.Domain.Entities
{
[SugarTable("AccessLog")]
public class AccessLogEntity : Entity<Guid>, IHasModificationTime, IHasCreationTime
public class AccessLogAggregateRoot : AggregateRoot<Guid>, IHasModificationTime, IHasCreationTime
{
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
public override Guid Id { get; protected set; }

View File

@@ -14,13 +14,13 @@ namespace Yi.Framework.Bbs.Domain.Entities.Bank
/// 银行卡
/// </summary>
[SugarTable("BankCard")]
public class BankCardEntity : Entity<Guid>, IHasCreationTime
public class BankCardAggregateRoot : AggregateRoot<Guid>, IHasCreationTime
{
public BankCardEntity()
public BankCardAggregateRoot()
{
}
public BankCardEntity(Guid userId)
public BankCardAggregateRoot(Guid userId)
{
this.UserId = userId;
}

View File

@@ -13,11 +13,11 @@ namespace Yi.Framework.Bbs.Domain.Entities.Bank
/// 利息记录
/// </summary>
[SugarTable("InterestRecords")]
public class InterestRecordsEntity : Entity<Guid>, IHasCreationTime
public class InterestRecordsAggregateRoot : AggregateRoot<Guid>, IHasCreationTime
{
public InterestRecordsEntity()
public InterestRecordsAggregateRoot()
{ }
public InterestRecordsEntity(decimal comparisonValue, decimal inputValue, bool isFluctuate = false)
public InterestRecordsAggregateRoot(decimal comparisonValue, decimal inputValue, bool isFluctuate = false)
{
ComparisonValue = comparisonValue;
Value = inputValue;

View File

@@ -0,0 +1,32 @@
namespace Yi.Framework.Bbs.Domain.Entities
{
public class BbsNoticeAggregateRoot
{
public Guid AcceptUserId { get; set; }
/// <summary>
/// 消息
/// </summary>
public string Message { get; set; }
public MessageTypeEnum MessageType { get; set; }
/// <summary>
/// 是否已读
/// </summary>
public bool IsRead { get; set; }
/// <summary>
/// 已读时间
/// </summary>
public DateTime? ReadTime { get; set; }
}
/// <summary>
/// 消息类型
/// </summary>
public enum MessageTypeEnum
{
}
}

View File

@@ -9,7 +9,7 @@ namespace Yi.Framework.Bbs.Domain.Entities.Forum
[SugarIndex($"index_{nameof(Name)}", nameof(Name), OrderByType.Asc)]
[SugarIndex($"index_{nameof(ParentId)}", nameof(ParentId), OrderByType.Asc)]
[SugarIndex($"index_{nameof(DiscussId)}", nameof(DiscussId), OrderByType.Asc)]
public class ArticleEntity : Entity<Guid>, ISoftDelete, IAuditedObject
public class ArticleAggregateRoot : AggregateRoot<Guid>, ISoftDelete, IAuditedObject
{
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
public override Guid Id { get; protected set; }
@@ -26,7 +26,7 @@ namespace Yi.Framework.Bbs.Domain.Entities.Forum
[SugarColumn(IsIgnore = true)]
public List<ArticleEntity>? Children { get; set; }
public List<ArticleAggregateRoot>? Children { get; set; }
public DateTime CreationTime { get; set; }
@@ -50,14 +50,14 @@ namespace Yi.Framework.Bbs.Domain.Entities.Forum
/// </summary>
/// <param name="entities"></param>
/// <returns></returns>
public static List<ArticleEntity> Tile(this List<ArticleEntity> entities)
public static List<ArticleAggregateRoot> Tile(this List<ArticleAggregateRoot> entities)
{
if (entities is null) return new List<ArticleEntity>();
var result = new List<ArticleEntity>();
if (entities is null) return new List<ArticleAggregateRoot>();
var result = new List<ArticleAggregateRoot>();
return StartRecursion(entities, result);
}
private static List<ArticleEntity> StartRecursion(List<ArticleEntity> entities, List<ArticleEntity> result)
private static List<ArticleAggregateRoot> StartRecursion(List<ArticleAggregateRoot> entities, List<ArticleAggregateRoot> result)
{
foreach (var entity in entities)
{

View File

@@ -6,7 +6,7 @@ using Volo.Abp.Domain.Entities;
namespace Yi.Framework.Bbs.Domain.Entities.Forum
{
[SugarTable("Banner")]
public class BannerEntity : Entity<Guid>, ISoftDelete, IAuditedObject
public class BannerAggregateRoot : AggregateRoot<Guid>, ISoftDelete, IAuditedObject
{
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
public override Guid Id { get; protected set; }

View File

@@ -13,16 +13,16 @@ namespace Yi.Framework.Bbs.Domain.Entities.Forum
[SugarTable("Comment")]
[SugarIndex($"index_{nameof(DiscussId)}", nameof(DiscussId), OrderByType.Asc)]
[SugarIndex($"index_{nameof(ParentId)}", nameof(ParentId), OrderByType.Asc)]
public class CommentEntity : Entity<Guid>, ISoftDelete, IAuditedObject
public class CommentAggregateRoot : AggregateRoot<Guid>, ISoftDelete, IAuditedObject
{
/// <summary>
/// 采用二维数组方式,不使用树形方式
/// </summary>
public CommentEntity()
public CommentAggregateRoot()
{
}
public CommentEntity(Guid discussId)
public CommentAggregateRoot(Guid discussId)
{
DiscussId = discussId;
}
@@ -45,20 +45,20 @@ namespace Yi.Framework.Bbs.Domain.Entities.Forum
public Guid RootId { get; set; }
[SugarColumn(IsIgnore = true)]
public List<CommentEntity> Children { get; set; } = new();
public List<CommentAggregateRoot> Children { get; set; } = new();
/// <summary>
/// 用户,评论人用户信息
/// </summary>
[Navigate(NavigateType.OneToOne, nameof(CreatorId))]
public UserEntity CreateUser { get; set; }
public UserAggregateRoot CreateUser { get; set; }
/// <summary>
/// 被评论的用户信息
/// </summary>
[SugarColumn(IsIgnore = true)]
public UserEntity CommentedUser { get; set; }
public UserAggregateRoot CommentedUser { get; set; }
public Guid? CreatorId { get; set; }

View File

@@ -10,12 +10,12 @@ namespace Yi.Framework.Bbs.Domain.Entities.Forum
[SugarIndex($"index_{nameof(Title)}", nameof(Title), OrderByType.Asc)]
[SugarIndex($"index_{nameof(PlateId)}", nameof(PlateId), OrderByType.Asc)]
[SugarIndex($"index_{nameof(CreationTime)}", nameof(CreationTime), OrderByType.Desc)]
public class DiscussEntity : Entity<Guid>, ISoftDelete, IAuditedObject
public class DiscussAggregateRoot : AggregateRoot<Guid>, ISoftDelete, IAuditedObject
{
public DiscussEntity()
public DiscussAggregateRoot()
{
}
public DiscussEntity(Guid plateId)
public DiscussAggregateRoot(Guid plateId)
{
PlateId = plateId;
}

View File

@@ -6,7 +6,7 @@ using Volo.Abp.Auditing;
namespace Yi.Framework.Bbs.Domain.Entities.Forum
{
[SugarTable("Plate")]
public class PlateEntity : Entity<Guid>, ISoftDelete, IAuditedObject
public class PlateAggregateRoot : AggregateRoot<Guid>, ISoftDelete, IAuditedObject
{
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]

View File

@@ -7,11 +7,11 @@ namespace Yi.Framework.Bbs.Domain.Entities.Integral
/// 等级表
/// </summary>
[SugarTable("Level")]
public class LevelEntity : Entity<Guid>
public class LevelAggregateRoot : AggregateRoot<Guid>
{
public LevelEntity() { }
public LevelAggregateRoot() { }
public LevelEntity(int currentLevel, string name, decimal minExperience)
public LevelAggregateRoot(int currentLevel, string name, decimal minExperience)
{
this.CurrentLevel = currentLevel;
this.Name = name;

View File

@@ -15,7 +15,7 @@ namespace Yi.Framework.Bbs.Domain.Entities.Integral
[SugarTable("SignIn")]
[SugarIndex($"index_{nameof(CreatorId)}", nameof(CreatorId), OrderByType.Asc)]
public class SignInEntity : Entity<Guid>, ICreationAuditedObject
public class SignInAggregateRoot : AggregateRoot<Guid>, ICreationAuditedObject
{
[SugarColumn(IsPrimaryKey = true)]

View File

@@ -4,7 +4,7 @@ using Volo.Abp.Domain.Entities;
namespace Yi.Framework.Bbs.Domain.Entities
{
[SugarTable("Setting")]
public class SettingEntity : Entity<Guid>
public class SettingAggregateRoot : AggregateRoot<Guid>
{
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]

View File

@@ -23,7 +23,7 @@ namespace Yi.Framework.Bbs.Domain.EventHandlers
public async Task HandleEventAsync(EntityCreatedEventData<AgreeEntity> eventData)
{
var agreeEntity = eventData.Entity;
var userId = await _agreeRepository._DbQueryable.LeftJoin<DiscussEntity>((agree, discuss) => agree.DiscussId == discuss.Id)
var userId = await _agreeRepository._DbQueryable.LeftJoin<DiscussAggregateRoot>((agree, discuss) => agree.DiscussId == discuss.Id)
.Select((agree, discuss) => discuss.CreatorId).FirstAsync();
//给创建者发布数量+1
@@ -50,7 +50,7 @@ namespace Yi.Framework.Bbs.Domain.EventHandlers
public async Task HandleEventAsync(EntityCreatedEventData<AgreeEntity> eventData)
{
var agreeEntity = eventData.Entity;
var userId = await _agreeRepository._DbQueryable.LeftJoin<DiscussEntity>((agree, discuss) => agree.DiscussId == discuss.Id)
var userId = await _agreeRepository._DbQueryable.LeftJoin<DiscussAggregateRoot>((agree, discuss) => agree.DiscussId == discuss.Id)
.Select((agree, discuss) => discuss.CreatorId).FirstAsync();
//给创建者发布数量-1

View File

@@ -10,7 +10,7 @@ namespace Yi.Framework.Bbs.Domain.EventHandlers
/// <summary>
/// 评论创建的领域事件
/// </summary>
public class CommentCreatedEventHandler : ILocalEventHandler<EntityCreatedEventData<CommentEntity>>,
public class CommentCreatedEventHandler : ILocalEventHandler<EntityCreatedEventData<CommentAggregateRoot>>,
ITransientDependency
{
private ISqlSugarRepository<BbsUserExtraInfoEntity> _userRepository;
@@ -18,7 +18,7 @@ namespace Yi.Framework.Bbs.Domain.EventHandlers
{
_userRepository = userRepository;
}
public async Task HandleEventAsync(EntityCreatedEventData<CommentEntity> eventData)
public async Task HandleEventAsync(EntityCreatedEventData<CommentAggregateRoot> eventData)
{
var commentEntity = eventData.Entity;

View File

@@ -10,7 +10,7 @@ namespace Yi.Framework.Bbs.Domain.EventHandlers
/// <summary>
/// 主题创建的领域事件
/// </summary>
public class DiscussCreatedEventHandler : ILocalEventHandler<EntityCreatedEventData<DiscussEntity>>,
public class DiscussCreatedEventHandler : ILocalEventHandler<EntityCreatedEventData<DiscussAggregateRoot>>,
ITransientDependency
{
private ISqlSugarRepository<BbsUserExtraInfoEntity> _userRepository;
@@ -18,7 +18,7 @@ namespace Yi.Framework.Bbs.Domain.EventHandlers
{
_userRepository = userRepository;
}
public async Task HandleEventAsync(EntityCreatedEventData<DiscussEntity> eventData)
public async Task HandleEventAsync(EntityCreatedEventData<DiscussAggregateRoot> eventData)
{
var disucussEntity = eventData.Entity;

View File

@@ -13,8 +13,8 @@ namespace Yi.Framework.Bbs.Domain.EventHandlers
{
public class SeeDiscussEventHandler : ILocalEventHandler<SeeDiscussEventArgs>, ITransientDependency
{
private IRepository<DiscussEntity, Guid> _repository;
public SeeDiscussEventHandler(IRepository<DiscussEntity, Guid> repository)
private IRepository<DiscussAggregateRoot, Guid> _repository;
public SeeDiscussEventHandler(IRepository<DiscussAggregateRoot, Guid> repository)
{
_repository = repository;
}

View File

@@ -17,7 +17,7 @@ namespace Yi.Framework.Bbs.Domain.Managers.ArticleImport
LoggerFactory = loggerFactory;
}
protected ILoggerFactory LoggerFactory { get; set; }
public virtual List<ArticleEntity> Import(Guid discussId, Guid articleParentId, List<FileObject> fileObjs)
public virtual List<ArticleAggregateRoot> Import(Guid discussId, Guid articleParentId, List<FileObject> fileObjs)
{
var articles = Convert(fileObjs);
var orderNum = 0;
@@ -29,6 +29,6 @@ namespace Yi.Framework.Bbs.Domain.Managers.ArticleImport
});
return articles;
}
public abstract List<ArticleEntity> Convert(List<FileObject> fileObjs);
public abstract List<ArticleAggregateRoot> Convert(List<FileObject> fileObjs);
}
}

View File

@@ -10,9 +10,9 @@ namespace Yi.Framework.Bbs.Domain.Managers.ArticleImport
{
internal class DefaultArticleImport : AbstractArticleImport
{
public override List<ArticleEntity> Convert(List<FileObject> fileObjs)
public override List<ArticleAggregateRoot> Convert(List<FileObject> fileObjs)
{
return fileObjs.OrderBy(x => x.FileName).Select(x => new ArticleEntity { Name = x.FileName, Content = x.Content }).ToList();
return fileObjs.OrderBy(x => x.FileName).Select(x => new ArticleAggregateRoot { Name = x.FileName, Content = x.Content }).ToList();
}
}
}

View File

@@ -11,7 +11,7 @@ namespace Yi.Framework.Bbs.Domain.Managers.ArticleImport
{
internal class VuePressArticleImport : AbstractArticleImport
{
public override List<ArticleEntity> Convert(List<FileObject> fileObjs)
public override List<ArticleAggregateRoot> Convert(List<FileObject> fileObjs)
{
var logger = LoggerFactory.CreateLogger<VuePressArticleImport>();
@@ -65,7 +65,7 @@ namespace Yi.Framework.Bbs.Domain.Managers.ArticleImport
f.Content = result;
return f;
});
var output = fileContentHandler.Select(x => new ArticleEntity() { Content = x.Content, Name = x.FileName }).ToList();
var output = fileContentHandler.Select(x => new ArticleAggregateRoot() { Content = x.Content, Name = x.FileName }).ToList();
return output;
}

View File

@@ -15,11 +15,11 @@ namespace Yi.Framework.Bbs.Domain.Managers
/// </summary>
public class BankManager : DomainService
{
private ISqlSugarRepository<BankCardEntity> _repository;
private ISqlSugarRepository<BankCardAggregateRoot> _repository;
private ILocalEventBus _localEventBus;
private ISqlSugarRepository<InterestRecordsEntity> _interestRepository;
private ISqlSugarRepository<InterestRecordsAggregateRoot> _interestRepository;
private IBankValueProvider _bankValueProvider;
public BankManager(ISqlSugarRepository<BankCardEntity> repository, ILocalEventBus localEventBus, ISqlSugarRepository<InterestRecordsEntity> interestRepository, IBankValueProvider bankValueProvider)
public BankManager(ISqlSugarRepository<BankCardAggregateRoot> repository, ILocalEventBus localEventBus, ISqlSugarRepository<InterestRecordsAggregateRoot> interestRepository, IBankValueProvider bankValueProvider)
{
_repository = repository;
_localEventBus = localEventBus;
@@ -72,7 +72,7 @@ namespace Yi.Framework.Bbs.Domain.Managers
/// 强制创建一个记录,不管时间到没到
/// </summary>
/// <returns></returns>
public async Task<InterestRecordsEntity> CreateInterestRecordsAsync()
public async Task<InterestRecordsAggregateRoot> CreateInterestRecordsAsync()
{
//获取最新的实体
var lastEntity = await _interestRepository._DbQueryable.OrderByDescending(x => x.CreationTime).FirstAsync();
@@ -106,7 +106,7 @@ namespace Yi.Framework.Bbs.Domain.Managers
//根据上一次的老值进行变化率比较
var currentValue = oldValue + (oldValue* changeRate);
var entity = new InterestRecordsEntity(lastThirdPartyStandardValue, currentValue);
var entity = new InterestRecordsAggregateRoot(lastThirdPartyStandardValue, currentValue);
var output = await _interestRepository.InsertReturnEntityAsync(entity);
return output;
@@ -129,7 +129,7 @@ namespace Yi.Framework.Bbs.Domain.Managers
/// <returns></returns>
public async Task ApplyingBankCardAsync(Guid userId, int cardNumber)
{
var entities = Enumerable.Range(1, cardNumber).Select(x => new BankCardEntity(userId)).ToList();
var entities = Enumerable.Range(1, cardNumber).Select(x => new BankCardAggregateRoot(userId)).ToList();
await _repository.InsertManyAsync(entities);
}

View File

@@ -12,10 +12,10 @@ namespace Yi.Framework.Bbs.Domain.Managers
{
public class BbsUserManager : DomainService
{
public ISqlSugarRepository<UserEntity> _userRepository;
public ISqlSugarRepository<UserAggregateRoot> _userRepository;
public ISqlSugarRepository<BbsUserExtraInfoEntity> _bbsUserInfoRepository;
public Dictionary<int,LevelCacheItem> _levelCacheDic;
public BbsUserManager(ISqlSugarRepository<UserEntity> userRepository,
public BbsUserManager(ISqlSugarRepository<UserAggregateRoot> userRepository,
ISqlSugarRepository<BbsUserExtraInfoEntity> bbsUserInfoRepository,
IDistributedCache<List<LevelCacheItem>> levelCache
)

View File

@@ -14,11 +14,11 @@ namespace Yi.Framework.Bbs.Domain.Managers
/// </summary>
public class ForumManager : DomainService
{
public readonly ISqlSugarRepository<DiscussEntity, Guid> _discussRepository;
public readonly ISqlSugarRepository<PlateEntity, Guid> _plateEntityRepository;
public readonly ISqlSugarRepository<CommentEntity, Guid> _commentRepository;
public readonly ISqlSugarRepository<ArticleEntity, Guid> _articleRepository;
public ForumManager(ISqlSugarRepository<DiscussEntity, Guid> discussRepository, ISqlSugarRepository<PlateEntity, Guid> plateEntityRepository, ISqlSugarRepository<CommentEntity, Guid> commentRepository, ISqlSugarRepository<ArticleEntity, Guid> articleRepository)
public readonly ISqlSugarRepository<DiscussAggregateRoot, Guid> _discussRepository;
public readonly ISqlSugarRepository<PlateAggregateRoot, Guid> _plateEntityRepository;
public readonly ISqlSugarRepository<CommentAggregateRoot, Guid> _commentRepository;
public readonly ISqlSugarRepository<ArticleAggregateRoot, Guid> _articleRepository;
public ForumManager(ISqlSugarRepository<DiscussAggregateRoot, Guid> discussRepository, ISqlSugarRepository<PlateAggregateRoot, Guid> plateEntityRepository, ISqlSugarRepository<CommentAggregateRoot, Guid> commentRepository, ISqlSugarRepository<ArticleAggregateRoot, Guid> articleRepository)
{
_discussRepository = discussRepository;
_plateEntityRepository = plateEntityRepository;
@@ -27,7 +27,7 @@ namespace Yi.Framework.Bbs.Domain.Managers
}
//主题是不能直接创建的,需要由领域服务统一创建
public async Task<DiscussEntity> CreateDiscussAsync(DiscussEntity entity)
public async Task<DiscussAggregateRoot> CreateDiscussAsync(DiscussAggregateRoot entity)
{
entity.CreationTime = DateTime.Now;
entity.AgreeNum = 0;
@@ -35,9 +35,9 @@ namespace Yi.Framework.Bbs.Domain.Managers
return await _discussRepository.InsertReturnEntityAsync(entity);
}
public async Task<CommentEntity> CreateCommentAsync(Guid discussId, Guid parentId, Guid rootId, string content)
public async Task<CommentAggregateRoot> CreateCommentAsync(Guid discussId, Guid parentId, Guid rootId, string content)
{
var entity = new CommentEntity(discussId);
var entity = new CommentAggregateRoot(discussId);
entity.Content = content;
entity.ParentId = parentId;
entity.RootId = rootId;

View File

@@ -10,10 +10,10 @@ namespace Yi.Framework.Bbs.Domain.Managers
{
public class IntegralManager : DomainService
{
public ISqlSugarRepository<LevelEntity> _levelRepository;
public ISqlSugarRepository<SignInEntity> _signInRepository;
public ISqlSugarRepository<LevelAggregateRoot> _levelRepository;
public ISqlSugarRepository<SignInAggregateRoot> _signInRepository;
private readonly ILocalEventBus _localEventBus;
public IntegralManager(ISqlSugarRepository<LevelEntity> levelRepository, ISqlSugarRepository<SignInEntity> signInRepository, ILocalEventBus localEventBus)
public IntegralManager(ISqlSugarRepository<LevelAggregateRoot> levelRepository, ISqlSugarRepository<SignInAggregateRoot> signInRepository, ILocalEventBus localEventBus)
{
_levelRepository = levelRepository;
_localEventBus = localEventBus;
@@ -56,7 +56,7 @@ namespace Yi.Framework.Bbs.Domain.Managers
//插入记录
var entity = new SignInEntity() { ContinuousNumber = continuousNumber };
var entity = new SignInAggregateRoot() { ContinuousNumber = continuousNumber };
await _signInRepository.InsertAsync(entity);
//发布一个其他领域的事件
@@ -112,7 +112,7 @@ namespace Yi.Framework.Bbs.Domain.Managers
/// <summary>
/// 获取连续次数
/// </summary>
private int GetContinuousNumber(SignInEntity sigInLast)
private int GetContinuousNumber(SignInAggregateRoot sigInLast)
{
var continuousNumber = 1;

View File

@@ -9,8 +9,8 @@ using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.Bbs.Domain.Repositories
{
public interface IArticleRepository: ISqlSugarRepository<ArticleEntity,Guid>
public interface IArticleRepository: ISqlSugarRepository<ArticleAggregateRoot,Guid>
{
Task<List<ArticleEntity>> GetTreeAsync(Expression<Func<ArticleEntity, bool>> where);
Task<List<ArticleAggregateRoot>> GetTreeAsync(Expression<Func<ArticleAggregateRoot, bool>> where);
}
}

View File

@@ -28,7 +28,7 @@ namespace Yi.Framework.Bbs.Domain
var logger = services.GetRequiredService<ILogger<YiFrameworkBbsDomainModule>>();
logger.LogInformation("正在初始化【BBS-等级数据】......");
var levelRepository = services.GetRequiredService<IRepository<LevelEntity>>();
var levelRepository = services.GetRequiredService<IRepository<LevelAggregateRoot>>();
var levelCache = services.GetRequiredService<IDistributedCache<List<LevelCacheItem>>>();
var cacheItem = (await levelRepository.GetListAsync()).Adapt<List<LevelCacheItem>>();
await levelCache.SetAsync(LevelConst.LevelCacheKey, cacheItem);