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

@@ -10,8 +10,8 @@ namespace Yi.Framework.Bbs.Application.Services
{
public class AccessLogService : ApplicationService, IAccessLogService
{
private readonly ISqlSugarRepository<AccessLogEntity> _repository;
public AccessLogService(ISqlSugarRepository<AccessLogEntity> repository) { _repository = repository; }
private readonly ISqlSugarRepository<AccessLogAggregateRoot> _repository;
public AccessLogService(ISqlSugarRepository<AccessLogAggregateRoot> repository) { _repository = repository; }
public DateTime GetWeekFirst()
{
@@ -71,11 +71,11 @@ namespace Yi.Framework.Bbs.Application.Services
if (last is null || last.CreationTime.Date != DateTime.Today)
{
await _repository.InsertAsync(new AccessLogEntity());
await _repository.InsertAsync(new AccessLogAggregateRoot());
}
else
{
await _repository._Db.Updateable<AccessLogEntity>().SetColumns(it => it.Number == it.Number + 1).Where(it => it.Id == last.Id).ExecuteCommandAsync();
await _repository._Db.Updateable<AccessLogAggregateRoot>().SetColumns(it => it.Number == it.Number + 1).Where(it => it.Id == last.Id).ExecuteCommandAsync();
}
}
@@ -95,7 +95,7 @@ namespace Yi.Framework.Bbs.Application.Services
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
private AccessLogDto[] WeekTimeHandler(AccessLogEntity[] data)
private AccessLogDto[] WeekTimeHandler(AccessLogAggregateRoot[] data)
{
data = data.Where(x => x.CreationTime >= GetWeekFirst()).OrderByDescending(x => x.CreationTime).DistinctBy(x => x.CreationTime.DayOfWeek).ToArray();

View File

@@ -31,7 +31,7 @@ namespace Yi.Framework.Bbs.Application.Services.Analyses
{
var output = await _forumManager._discussRepository._DbQueryable
.Where(discuss=>discuss.PermissionType== DiscussPermissionTypeEnum.Public)
.LeftJoin<UserEntity>((discuss, user) => discuss.CreatorId == user.Id)
.LeftJoin<UserAggregateRoot>((discuss, user) => discuss.CreatorId == user.Id)
.LeftJoin<BbsUserExtraInfoEntity>((discuss, user, info) => user.Id == info.UserId)
.OrderBy(discuss => SqlFunc.GetRandom())

View File

@@ -13,9 +13,9 @@ namespace Yi.Framework.Bbs.Application.Services.Bank
{
private BankManager _bankManager;
private BbsUserManager _bbsUserManager;
private ISqlSugarRepository<BankCardEntity, Guid> _repository;
private ISqlSugarRepository<InterestRecordsEntity, Guid> _interestRepository;
public BankService(BankManager bankManager, BbsUserManager userManager, ISqlSugarRepository<BankCardEntity, Guid> repository, ISqlSugarRepository<InterestRecordsEntity, Guid> interestRepository)
private ISqlSugarRepository<BankCardAggregateRoot, Guid> _repository;
private ISqlSugarRepository<InterestRecordsAggregateRoot, Guid> _interestRepository;
public BankService(BankManager bankManager, BbsUserManager userManager, ISqlSugarRepository<BankCardAggregateRoot, Guid> repository, ISqlSugarRepository<InterestRecordsAggregateRoot, Guid> interestRepository)
{
_bankManager = bankManager;
_bbsUserManager = userManager;

View File

@@ -13,7 +13,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
/// </summary>
public class AgreeService : ApplicationService, IApplicationService
{
public AgreeService(ISqlSugarRepository<AgreeEntity> repository, ISqlSugarRepository<DiscussEntity> discssRepository)
public AgreeService(ISqlSugarRepository<AgreeEntity> repository, ISqlSugarRepository<DiscussAggregateRoot> discssRepository)
{
_repository = repository;
_discssRepository = discssRepository;
@@ -21,7 +21,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
private ISqlSugarRepository<AgreeEntity> _repository { get; set; }
private ISqlSugarRepository<DiscussEntity> _discssRepository { get; set; }
private ISqlSugarRepository<DiscussAggregateRoot> _discssRepository { get; set; }
/// <summary>

View File

@@ -31,11 +31,11 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
/// Article服务实现
/// </summary>
public class ArticleService : YiCrudAppService<ArticleEntity, ArticleGetOutputDto, ArticleGetListOutputDto, Guid, ArticleGetListInputVo, ArticleCreateInputVo, ArticleUpdateInputVo>,
public class ArticleService : YiCrudAppService<ArticleAggregateRoot, ArticleGetOutputDto, ArticleGetListOutputDto, Guid, ArticleGetListInputVo, ArticleCreateInputVo, ArticleUpdateInputVo>,
IArticleService
{
public ArticleService(IArticleRepository articleRepository,
ISqlSugarRepository<DiscussEntity> discussRepository,
ISqlSugarRepository<DiscussAggregateRoot> discussRepository,
IDiscussService discussService,
ForumManager forumManager) : base(articleRepository)
{
@@ -48,7 +48,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
}
private ForumManager _forumManager;
private IArticleRepository _articleRepository;
private ISqlSugarRepository<DiscussEntity> _discussRepository;
private ISqlSugarRepository<DiscussAggregateRoot> _discussRepository;
private IDiscussService _discussService;
public override async Task<PagedResultDto<ArticleGetListOutputDto>> GetListAsync(ArticleGetListInputVo input)

View File

@@ -12,11 +12,11 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
/// <summary>
/// Banner服务实现
/// </summary>
public class BannerService : YiCrudAppService<BannerEntity, BannerGetOutputDto, BannerGetListOutputDto, Guid, BannerGetListInputVo, BannerCreateInputVo, BannerUpdateInputVo>,
public class BannerService : YiCrudAppService<BannerAggregateRoot, BannerGetOutputDto, BannerGetListOutputDto, Guid, BannerGetListInputVo, BannerCreateInputVo, BannerUpdateInputVo>,
IBannerService
{
private ISqlSugarRepository<BannerEntity, Guid> _repository;
public BannerService(ISqlSugarRepository<BannerEntity, Guid> repository) : base(repository)
private ISqlSugarRepository<BannerAggregateRoot, Guid> _repository;
public BannerService(ISqlSugarRepository<BannerAggregateRoot, Guid> repository) : base(repository)
{
_repository = repository;
}

View File

@@ -21,12 +21,12 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
/// <summary>
/// 评论
/// </summary>
public class CommentService : YiCrudAppService<CommentEntity, CommentGetOutputDto, CommentGetListOutputDto, Guid, CommentGetListInputVo, CommentCreateInputVo, CommentUpdateInputVo>,
public class CommentService : YiCrudAppService<CommentAggregateRoot, CommentGetOutputDto, CommentGetListOutputDto, Guid, CommentGetListInputVo, CommentCreateInputVo, CommentUpdateInputVo>,
ICommentService
{
private readonly ISqlSugarRepository<CommentEntity, Guid> _repository;
private readonly ISqlSugarRepository<CommentAggregateRoot, Guid> _repository;
private readonly BbsUserManager _bbsUserManager;
public CommentService(ForumManager forumManager, ISqlSugarRepository<DiscussEntity> discussRepository, IDiscussService discussService, ISqlSugarRepository<CommentEntity, Guid> CommentRepository, BbsUserManager bbsUserManager) : base(CommentRepository)
public CommentService(ForumManager forumManager, ISqlSugarRepository<DiscussAggregateRoot> discussRepository, IDiscussService discussService, ISqlSugarRepository<CommentAggregateRoot, Guid> CommentRepository, BbsUserManager bbsUserManager) : base(CommentRepository)
{
_forumManager = forumManager;
_discussRepository = discussRepository;
@@ -39,7 +39,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
private ISqlSugarRepository<DiscussEntity> _discussRepository { get; set; }
private ISqlSugarRepository<DiscussAggregateRoot> _discussRepository { get; set; }
private IDiscussService _discussService { get; set; }
/// <summary>

View File

@@ -29,12 +29,12 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
/// <summary>
/// Discuss应用服务实现,用于参数校验、领域服务业务组合、日志记录、事务处理、账户信息
/// </summary>
public class DiscussService : YiCrudAppService<DiscussEntity, DiscussGetOutputDto, DiscussGetListOutputDto, Guid, DiscussGetListInputVo, DiscussCreateInputVo, DiscussUpdateInputVo>,
public class DiscussService : YiCrudAppService<DiscussAggregateRoot, DiscussGetOutputDto, DiscussGetListOutputDto, Guid, DiscussGetListInputVo, DiscussCreateInputVo, DiscussUpdateInputVo>,
IDiscussService
{
private ISqlSugarRepository<DiscussTopEntity> _discussTopEntityRepository;
private BbsUserManager _bbsUserManager;
public DiscussService(BbsUserManager bbsUserManager, ForumManager forumManager, ISqlSugarRepository<DiscussTopEntity> discussTopEntityRepository, ISqlSugarRepository<PlateEntity> plateEntityRepository, ILocalEventBus localEventBus) : base(forumManager._discussRepository)
public DiscussService(BbsUserManager bbsUserManager, ForumManager forumManager, ISqlSugarRepository<DiscussTopEntity> discussTopEntityRepository, ISqlSugarRepository<PlateAggregateRoot> plateEntityRepository, ILocalEventBus localEventBus) : base(forumManager._discussRepository)
{
_forumManager = forumManager;
_plateEntityRepository = plateEntityRepository;
@@ -46,7 +46,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
private ForumManager _forumManager { get; set; }
private ISqlSugarRepository<PlateEntity> _plateEntityRepository { get; set; }
private ISqlSugarRepository<PlateAggregateRoot> _plateEntityRepository { get; set; }
@@ -60,9 +60,9 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
{
//查询主题发布 浏览主题 事件,浏览数+1
var item = await _forumManager._discussRepository._DbQueryable.LeftJoin<UserEntity>((discuss, user) => discuss.CreatorId == user.Id)
var item = await _forumManager._discussRepository._DbQueryable.LeftJoin<UserAggregateRoot>((discuss, user) => discuss.CreatorId == user.Id)
.LeftJoin<BbsUserExtraInfoEntity>((discuss, user, info) => user.Id == info.UserId)
.LeftJoin<PlateEntity>((discuss, user, info, plate) => plate.Id == discuss.PlateId)
.LeftJoin<PlateAggregateRoot>((discuss, user, info, plate) => plate.Id == discuss.PlateId)
.Select((discuss, user, info, plate) => new DiscussGetOutputDto
{
Id = discuss.Id,
@@ -114,7 +114,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
.WhereIF(input.PlateId is not null, x => x.PlateId == input.PlateId)
.WhereIF(input.IsTop is not null, x => x.IsTop == input.IsTop)
.WhereIF(input.UserId is not null,x=>x.CreatorId==input.UserId)
.LeftJoin<UserEntity>((discuss, user) => discuss.CreatorId == user.Id)
.LeftJoin<UserAggregateRoot>((discuss, user) => discuss.CreatorId == user.Id)
.WhereIF(input.UserName is not null, (discuss, user)=>user.UserName==input.UserName!)
.LeftJoin<BbsUserExtraInfoEntity>((discuss, user, info) => user.Id == info.UserId)
@@ -157,8 +157,8 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
/// <returns></returns>
public async Task<List<DiscussGetListOutputDto>> GetListTopAsync()
{
var output = await _discussTopEntityRepository._DbQueryable.LeftJoin<DiscussEntity>((top, discuss) => top.DiscussId == discuss.Id)
.LeftJoin<UserEntity>((top, discuss, user) => discuss.CreatorId == user.Id)
var output = await _discussTopEntityRepository._DbQueryable.LeftJoin<DiscussAggregateRoot>((top, discuss) => top.DiscussId == discuss.Id)
.LeftJoin<UserAggregateRoot>((top, discuss, user) => discuss.CreatorId == user.Id)
.LeftJoin<BbsUserExtraInfoEntity>((top, discuss, user, info) => user.Id == info.UserId)
.OrderByDescending(top => top.OrderNum)
.Select((top, discuss, user, info) => new DiscussGetListOutputDto

View File

@@ -13,11 +13,11 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
/// <summary>
/// Plate服务实现
/// </summary>
public class PlateService : YiCrudAppService<PlateEntity, PlateGetOutputDto, PlateGetListOutputDto, Guid, PlateGetListInputVo, PlateCreateInputVo, PlateUpdateInputVo>,
public class PlateService : YiCrudAppService<PlateAggregateRoot, PlateGetOutputDto, PlateGetListOutputDto, Guid, PlateGetListInputVo, PlateCreateInputVo, PlateUpdateInputVo>,
IPlateService
{
private ISqlSugarRepository<PlateEntity, Guid> _repository;
public PlateService(ISqlSugarRepository<PlateEntity, Guid> repository) : base(repository)
private ISqlSugarRepository<PlateAggregateRoot, Guid> _repository;
public PlateService(ISqlSugarRepository<PlateAggregateRoot, Guid> repository) : base(repository)
{
_repository = repository;
}

View File

@@ -22,11 +22,11 @@ namespace Yi.Framework.Bbs.Application.Services.Integral
/// <summary>
/// 等级服务
/// </summary>
public class LevelService : YiCrudAppService<LevelEntity, LevelOutputDto, Guid, LevelGetListInputDto>, ILevelService
public class LevelService : YiCrudAppService<LevelAggregateRoot, LevelOutputDto, Guid, LevelGetListInputDto>, ILevelService
{
private ISqlSugarRepository<LevelEntity, Guid> _repository;
private ISqlSugarRepository<LevelAggregateRoot, Guid> _repository;
private LevelManager _levelManager;
public LevelService(ISqlSugarRepository<LevelEntity, Guid> repository, LevelManager levelManager) : base(repository)
public LevelService(ISqlSugarRepository<LevelAggregateRoot, Guid> repository, LevelManager levelManager) : base(repository)
{
_repository = repository;
_levelManager = levelManager;

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);

View File

@@ -14,8 +14,8 @@ namespace Yi.Framework.Bbs.SqlSugarCore.DataSeeds
{
public class BannerDataSeed : IDataSeedContributor, ITransientDependency
{
private ISqlSugarRepository<BannerEntity> _repository;
public BannerDataSeed(ISqlSugarRepository<BannerEntity> repository)
private ISqlSugarRepository<BannerAggregateRoot> _repository;
public BannerDataSeed(ISqlSugarRepository<BannerAggregateRoot> repository)
{
_repository = repository;
}
@@ -26,18 +26,18 @@ namespace Yi.Framework.Bbs.SqlSugarCore.DataSeeds
await _repository.InsertManyAsync(GetSeedData());
}
}
public List<BannerEntity> GetSeedData()
public List<BannerAggregateRoot> GetSeedData()
{
//这里临时使用了图床图床地址https://mjj.today/
List<BannerEntity> entities = new List<BannerEntity>()
List<BannerAggregateRoot> entities = new List<BannerAggregateRoot>()
{
new BannerEntity{
new BannerAggregateRoot{
Name="欢迎",
Logo="https://i.miji.bid/2023/12/15/e6478d5d15a4b941077e336790c414f6.png",
Color=""
},
new BannerEntity{
new BannerAggregateRoot{
Name="前端",
Logo="https://i.miji.bid/2023/12/15/07e9291c9311889a31a2b433d4decca0.jpeg",
Color=""

View File

@@ -16,8 +16,8 @@ namespace Yi.Framework.Bbs.SqlSugarCore.DataSeeds
public class BbsMenuDataSeed : IDataSeedContributor, ITransientDependency
{
private IGuidGenerator _guidGenerator;
private ISqlSugarRepository<MenuEntity, Guid> _repository;
public BbsMenuDataSeed(ISqlSugarRepository<MenuEntity,Guid> repository, IGuidGenerator guidGenerator)
private ISqlSugarRepository<MenuAggregateRoot, Guid> _repository;
public BbsMenuDataSeed(ISqlSugarRepository<MenuAggregateRoot,Guid> repository, IGuidGenerator guidGenerator)
{
_repository=repository;
_guidGenerator=guidGenerator;
@@ -30,11 +30,11 @@ namespace Yi.Framework.Bbs.SqlSugarCore.DataSeeds
}
}
public List<MenuEntity> GetSeedData()
public List<MenuAggregateRoot> GetSeedData()
{
List<MenuEntity> entities = new List<MenuEntity>();
List<MenuAggregateRoot> entities = new List<MenuAggregateRoot>();
//BBS
MenuEntity bbs = new MenuEntity(_guidGenerator.Create())
MenuAggregateRoot bbs = new MenuAggregateRoot(_guidGenerator.Create())
{
MenuName = "BBS",
MenuType = MenuTypeEnum.Catalogue,
@@ -50,7 +50,7 @@ namespace Yi.Framework.Bbs.SqlSugarCore.DataSeeds
//板块管理
MenuEntity plate = new MenuEntity(_guidGenerator.Create())
MenuAggregateRoot plate = new MenuAggregateRoot(_guidGenerator.Create())
{
MenuName = "板块管理",
@@ -69,7 +69,7 @@ namespace Yi.Framework.Bbs.SqlSugarCore.DataSeeds
entities.Add(plate);
//文章管理
MenuEntity article = new MenuEntity(_guidGenerator.Create())
MenuAggregateRoot article = new MenuAggregateRoot(_guidGenerator.Create())
{
MenuName = "文章管理",

View File

@@ -15,8 +15,8 @@ namespace Yi.Framework.Bbs.SqlSugarCore.DataSeeds
public class BbsUserInfoDataSeed : IDataSeedContributor, ITransientDependency
{
private ISqlSugarRepository<BbsUserExtraInfoEntity> _repository;
private ISqlSugarRepository<UserEntity> _userRepository;
public BbsUserInfoDataSeed(ISqlSugarRepository<BbsUserExtraInfoEntity> repository, ISqlSugarRepository<UserEntity> userReponse)
private ISqlSugarRepository<UserAggregateRoot> _userRepository;
public BbsUserInfoDataSeed(ISqlSugarRepository<BbsUserExtraInfoEntity> repository, ISqlSugarRepository<UserAggregateRoot> userReponse)
{
_repository = repository;
_userRepository = userReponse;

View File

@@ -15,8 +15,8 @@ namespace Yi.Framework.Bbs.SqlSugarCore.DataSeeds
{
public class ConfigDataSeed : IDataSeedContributor, ITransientDependency
{
private ISqlSugarRepository<ConfigEntity> _repository;
public ConfigDataSeed(ISqlSugarRepository<ConfigEntity> repository)
private ISqlSugarRepository<ConfigAggregateRoot> _repository;
public ConfigDataSeed(ISqlSugarRepository<ConfigAggregateRoot> repository)
{
_repository = repository;
}
@@ -27,10 +27,10 @@ namespace Yi.Framework.Bbs.SqlSugarCore.DataSeeds
await _repository.InsertManyAsync(GetSeedData());
}
}
public List<ConfigEntity> GetSeedData()
public List<ConfigAggregateRoot> GetSeedData()
{
List<ConfigEntity> entities = new List<ConfigEntity>();
ConfigEntity config1 = new ConfigEntity()
List<ConfigAggregateRoot> entities = new List<ConfigAggregateRoot>();
ConfigAggregateRoot config1 = new ConfigAggregateRoot()
{
ConfigKey = "bbs.site.name",
ConfigName = "站点名称",
@@ -38,7 +38,7 @@ namespace Yi.Framework.Bbs.SqlSugarCore.DataSeeds
};
entities.Add(config1);
ConfigEntity config2 = new ConfigEntity()
ConfigAggregateRoot config2 = new ConfigAggregateRoot()
{
ConfigKey = "bbs.site.author",
ConfigName = "站点作者",
@@ -46,7 +46,7 @@ namespace Yi.Framework.Bbs.SqlSugarCore.DataSeeds
};
entities.Add(config2);
ConfigEntity config3 = new ConfigEntity()
ConfigAggregateRoot config3 = new ConfigAggregateRoot()
{
ConfigKey = "bbs.site.icp",
ConfigName = "站点Icp备案",
@@ -55,7 +55,7 @@ namespace Yi.Framework.Bbs.SqlSugarCore.DataSeeds
entities.Add(config3);
ConfigEntity config4 = new ConfigEntity()
ConfigAggregateRoot config4 = new ConfigAggregateRoot()
{
ConfigKey = "bbs.site.bottom",
ConfigName = "站点底部信息",

View File

@@ -7,8 +7,8 @@ namespace Yi.Framework.Bbs.SqlSugarCore.DataSeeds
{
public class LevelDataSeed : IDataSeedContributor, ITransientDependency
{
private ISqlSugarRepository<LevelEntity> _repository;
public LevelDataSeed(ISqlSugarRepository<LevelEntity> repository)
private ISqlSugarRepository<LevelAggregateRoot> _repository;
public LevelDataSeed(ISqlSugarRepository<LevelAggregateRoot> repository)
{
_repository = repository;
}
@@ -19,20 +19,20 @@ namespace Yi.Framework.Bbs.SqlSugarCore.DataSeeds
await _repository.InsertManyAsync(GetSeedData());
}
}
public List<LevelEntity> GetSeedData()
public List<LevelAggregateRoot> GetSeedData()
{
List<LevelEntity> entities = new List<LevelEntity>()
List<LevelAggregateRoot> entities = new List<LevelAggregateRoot>()
{
new LevelEntity(1,"小白",10),
new LevelEntity(2,"中白",30),
new LevelEntity(3,"大白",100),
new LevelEntity(4,"精英",300),
new LevelEntity(5,"熟练",600),
new LevelEntity(6,"高手",1000),
new LevelEntity(7,"老手",1500),
new LevelEntity(8,"大佬",2000),
new LevelEntity(9,"巨佬",2500),
new LevelEntity(10,"大神",3000),
new LevelAggregateRoot(1,"小白",10),
new LevelAggregateRoot(2,"中白",30),
new LevelAggregateRoot(3,"大白",100),
new LevelAggregateRoot(4,"精英",300),
new LevelAggregateRoot(5,"熟练",600),
new LevelAggregateRoot(6,"高手",1000),
new LevelAggregateRoot(7,"老手",1500),
new LevelAggregateRoot(8,"大佬",2000),
new LevelAggregateRoot(9,"巨佬",2500),
new LevelAggregateRoot(10,"大神",3000),
};
return entities;

View File

@@ -7,13 +7,13 @@ using Yi.Framework.SqlSugarCore.Repositories;
namespace Yi.Framework.Bbs.SqlSugarCore.Repositories
{
public class ArticleRepository : SqlSugarRepository<ArticleEntity,Guid>, IArticleRepository,ITransientDependency
public class ArticleRepository : SqlSugarRepository<ArticleAggregateRoot,Guid>, IArticleRepository,ITransientDependency
{
public ArticleRepository(ISugarDbContextProvider<ISqlSugarDbContext> sugarDbContextProvider) : base(sugarDbContextProvider)
{
}
public async Task<List<ArticleEntity>> GetTreeAsync(Expression<Func<ArticleEntity, bool>> where)
public async Task<List<ArticleAggregateRoot>> GetTreeAsync(Expression<Func<ArticleAggregateRoot, bool>> where)
{
return await _DbQueryable.Where(where).OrderBy(x=>x.OrderNum).OrderBy(x=>x.CreationTime).ToTreeAsync(x => x.Children, x => x.ParentId, Guid.Empty);
}