Files
Yi.Admin/Yi.Abp.Net8/module/bbs/Yi.Framework.Bbs.Domain/Managers/ForumManager.cs

41 lines
1.7 KiB
C#
Raw Normal View History

2023-12-11 09:55:12 +08:00
using Volo.Abp.Domain.Services;
using Yi.Framework.Bbs.Domain.Entities;
using Yi.Framework.SqlSugarCore.Abstractions;
2023-04-15 22:44:33 +08:00
2023-12-11 09:55:12 +08:00
namespace Yi.Framework.Bbs.Domain.Managers
2023-04-15 22:44:33 +08:00
{
/// <summary>
/// 论坛模块的领域服务
/// </summary>
2023-12-11 09:55:12 +08:00
public class ForumManager : DomainService
2023-04-15 22:44:33 +08:00
{
2023-12-11 09:55:12 +08:00
public readonly ISqlSugarRepository<DiscussEntity,Guid> _discussRepository;
public readonly ISqlSugarRepository<PlateEntity, Guid> _plateEntityRepository;
public readonly ISqlSugarRepository<CommentEntity, Guid> _commentRepository;
public ForumManager(ISqlSugarRepository<DiscussEntity, Guid> discussRepository, ISqlSugarRepository<PlateEntity, Guid> plateEntityRepository, ISqlSugarRepository<CommentEntity, Guid> commentRepository)
2023-04-15 22:44:33 +08:00
{
_discussRepository = discussRepository;
_plateEntityRepository = plateEntityRepository;
_commentRepository = commentRepository;
}
//主题是不能直接创建的,需要由领域服务统一创建
public async Task<DiscussEntity> CreateDiscussAsync(DiscussEntity entity)
{
entity.CreationTime = DateTime.Now;
entity.AgreeNum = 0;
entity.SeeNum = 0;
return await _discussRepository.InsertReturnEntityAsync(entity);
}
2023-12-11 09:55:12 +08:00
public async Task<CommentEntity> CreateCommentAsync(Guid discussId, Guid parentId, Guid rootId, string content)
2023-04-15 22:44:33 +08:00
{
var entity = new CommentEntity(discussId);
entity.Content = content;
entity.ParentId = parentId;
entity.RootId = rootId;
return await _commentRepository.InsertReturnEntityAsync(entity);
}
}
}