feat: 新增标签模块

This commit is contained in:
橙子
2025-01-19 03:31:48 +08:00
parent 3be5675828
commit 438abf6cea
16 changed files with 211 additions and 181 deletions

View File

@@ -44,7 +44,6 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
private IDiscussService _discussService { get; set; }
/// <summary>
/// 获取改主题下的评论,结构为二维列表,该查询无分页
/// Todo: 可放入领域层
/// </summary>
/// <param name="discussId"></param>
/// <param name="input"></param>
@@ -64,15 +63,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
List<Guid> userIds = entities.Where(x => x.CreatorId != null).Select(x => x.CreatorId ?? Guid.Empty).ToList();
var bbsUserInfoDic = (await _bbsUserManager.GetBbsUserInfoAsync(userIds)).ToDictionary(x => x.Id);
//------数据查询完成------
//------数据查询完成------,以下只是dto的简单组装
//从根目录开始组装
//结果初始值,第一层等于全部根节点
@@ -117,11 +108,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
rootOutoutDto?.ForEach(x =>
{
x.Children = x.Children.OrderByDescending(x => x.CreationTime).ToList();
});
return new PagedResultDto<CommentGetListOutputDto>(entities.Count(), rootOutoutDto);
}

View File

@@ -0,0 +1,53 @@
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Data;
using Yi.Framework.Bbs.Application.Contracts.Dtos.MyType;
using Yi.Framework.Bbs.Application.Contracts.IServices;
using Yi.Framework.Bbs.Domain.Entities.Forum;
using Yi.Framework.Ddd.Application;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.Bbs.Application.Services.Forum
{
/// <summary>
/// DiscussLable服务实现
/// </summary>
public class DiscussLableService : YiCrudAppService<DiscussLableAggregateRoot, DiscussLableOutputDto,
DiscussLableGetListOutputDto, Guid, DiscussLableGetListInputVo, DiscussLableCreateInputVo,
DiscussLableUpdateInputVo>,
IDiscussLableService
{
private ISqlSugarRepository<DiscussLableAggregateRoot, Guid> _repository;
public DiscussLableService(ISqlSugarRepository<DiscussLableAggregateRoot, Guid> repository) : base(repository)
{
_repository = repository;
}
[HttpGet("discuss-lable/all")]
public async Task<ListResultDto<DiscussLableGetListOutputDto>> GetAllListAsync(DiscussLableGetListInputVo input)
{
var order = input.Sorting ?? nameof(DiscussLableAggregateRoot.Name);
var output = await _repository._DbQueryable
.WhereIF(input.Name is not null, x => x.Name.Contains(input.Name))
.OrderBy(order)
.Select(x => new DiscussLableGetListOutputDto(), true)
.ToListAsync();
return new ListResultDto<DiscussLableGetListOutputDto>(output);
}
public override async Task<PagedResultDto<DiscussLableGetListOutputDto>> GetListAsync(
DiscussLableGetListInputVo input)
{
RefAsync<int> total = 0;
var order = input.Sorting ?? nameof(DiscussLableAggregateRoot.Name);
var output = await _repository._DbQueryable
.WhereIF(input.Name is not null, x => x.Name.Contains(input.Name))
.OrderBy(order)
.Select(x => new DiscussLableGetListOutputDto(), true)
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
return new PagedResultDto<DiscussLableGetListOutputDto>(total, output);
}
}
}

View File

@@ -1,54 +0,0 @@
using Volo.Abp.Application.Dtos;
using Volo.Abp.Data;
using Yi.Framework.Bbs.Application.Contracts.Dtos.MyType;
using Yi.Framework.Bbs.Application.Contracts.IServices;
using Yi.Framework.Bbs.Domain.Entities.Forum;
using Yi.Framework.Ddd.Application;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.Bbs.Application.Services.Forum
{
/// <summary>
/// Label服务实现
/// </summary>
public class MyTypeService : YiCrudAppService<MyTypeEntity, MyTypeOutputDto, MyTypeGetListOutputDto, Guid, MyTypeGetListInputVo, MyTypeCreateInputVo, MyTypeUpdateInputVo>,
IMyTypeService
{
private ISqlSugarRepository<MyTypeEntity, Guid> _repository;
public MyTypeService(ISqlSugarRepository<MyTypeEntity, Guid> repository, IDataFilter dataFilter) : base(repository)
{
_repository = repository;
_dataFilter = dataFilter;
}
private IDataFilter _dataFilter { get; set; }
/// <summary>
/// 获取当前用户的主题类型
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public Task<PagedResultDto<MyTypeGetListOutputDto>> GetListCurrentAsync(MyTypeGetListInputVo input)
{
//过滤器需要更换
//_dataFilter.Enable<MyTypeEntity>(x => x.UserId == CurrentUser.Id);
//_dataFilter.AddFilter<MyTypeEntity>(x => x.UserId == CurrentUser.Id);
return base.GetListAsync(input);
}
/// <summary>
/// 创建
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public override async Task<MyTypeOutputDto> CreateAsync(MyTypeCreateInputVo input)
{
var entity = await MapToEntityAsync(input);
entity.UserId = CurrentUser.Id ?? Guid.Empty;
entity.IsDeleted = false;
var outputEntity = await _repository.InsertReturnEntityAsync(entity);
return await MapToGetOutputDtoAsync(outputEntity);
}
}
}