feat: 简化测试

This commit is contained in:
橙子
2024-10-26 01:12:06 +08:00
parent 7cb78e70cb
commit bbc18dcaf9
2 changed files with 29 additions and 1 deletions

View File

@@ -8,6 +8,14 @@ namespace Yi.Framework.Bbs.Application.Contracts.IServices
/// </summary>
public interface ICommentService : IYiCrudAppService<CommentGetOutputDto, CommentGetListOutputDto, Guid, CommentGetListInputVo, CommentCreateInputVo, CommentUpdateInputVo>
{
/// <summary>
/// 发表评论
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="UserFriendlyException"></exception>
// [Permission("bbs:comment:add")]
// [Authorize]
Task<CommentGetOutputDto> CreateAsync(CommentCreateInputVo input);
}
}

View File

@@ -6,6 +6,8 @@ using Volo.Abp.Application.Services;
using Volo.Abp.Settings;
using Volo.Abp.Uow;
using Yi.Framework.Bbs.Application.Contracts.Dtos.Banner;
using Yi.Framework.Bbs.Application.Contracts.Dtos.Comment;
using Yi.Framework.Bbs.Application.Contracts.IServices;
using Yi.Framework.Bbs.Domain.Entities.Forum;
using Yi.Framework.Rbac.Domain.Authorization;
using Yi.Framework.Rbac.Domain.Extensions;
@@ -25,6 +27,24 @@ namespace Yi.Abp.Application.Services
/// </summary>
public ISqlSugarRepository<BannerAggregateRoot> sqlSugarRepository { get; set; }
private ICommentService _commentService;
public readonly ISqlSugarRepository<CommentAggregateRoot, Guid> _commentRepository;
public TestService(ICommentService commentService, ISqlSugarRepository<CommentAggregateRoot, Guid> commentRepository)
{
_commentService = commentService;
_commentRepository = commentRepository;
}
public async Task<string> GetAbpUnitOfWorkMiddleware()
{
var entity = new CommentAggregateRoot(Guid.Empty);
entity.Content = "测试";
entity.ParentId = Guid.Empty;
entity.RootId = Guid.Empty;
await _commentRepository.InsertAsync(entity);
return "yes";
}
/// <summary>
/// 动态Api
/// </summary>