添加bbs模块
This commit is contained in:
@@ -47,5 +47,5 @@ Console.WriteLine("Yi.Framework.Template:模板全部生成完成!");
|
||||
Console.ReadKey();
|
||||
|
||||
//根据模板文件生成项目文件
|
||||
//var template = "D:\\C#\\Yi\\Yi.Framework.Net6\\src\\project\\BBS";
|
||||
//FileHelper.AllInfoReplace(template, "Template", "BBS");
|
||||
//var template = "D:\\C#\\Yi\\Yi.Framework.Net6\\src\\project\\template";
|
||||
//FileHelper.AllInfoReplace(template, "Template", "RBAC");
|
||||
@@ -14,6 +14,14 @@
|
||||
Article服务实现
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.BBS.Application.Forum.ArticleService.GetAllAsync(System.Int64)">
|
||||
<summary>
|
||||
获取文章全部平铺信息
|
||||
</summary>
|
||||
<param name="discussId"></param>
|
||||
<returns></returns>
|
||||
<exception cref="T:Yi.Framework.Core.Exceptions.UserFriendlyException"></exception>
|
||||
</member>
|
||||
<member name="M:Yi.BBS.Application.Forum.ArticleService.GetDiscussIdAsync(System.Int64)">
|
||||
<summary>
|
||||
查询文章
|
||||
|
||||
@@ -4,6 +4,13 @@
|
||||
<name>Yi.BBS.Domain</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="M:Yi.BBS.Domain.Forum.Entities.ArticleEntityExtensions.Tile(System.Collections.Generic.List{Yi.BBS.Domain.Forum.Entities.ArticleEntity})">
|
||||
<summary>
|
||||
平铺自己
|
||||
</summary>
|
||||
<param name="entities"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.BBS.Domain.Forum.ForumManager">
|
||||
<summary>
|
||||
论坛模块的领域服务
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Ddd.Dtos;
|
||||
|
||||
namespace Yi.BBS.Application.Contracts.Forum.Dtos
|
||||
{
|
||||
public class ArticleAllOutputDto : IEntityDto<long>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string Content { get; set; }
|
||||
public string Name { get; set; }
|
||||
public long DiscussId { get; set; }
|
||||
public long ParentId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos
|
||||
public string Content { get; set; }
|
||||
public string Name { get; set; }
|
||||
public long DiscussId { get; set; }
|
||||
public long ParentId { get; set; }
|
||||
|
||||
public List<ArticleGetListOutputDto> Children { get; set; }
|
||||
}
|
||||
|
||||
@@ -15,15 +15,37 @@ namespace Yi.BBS.Application.Forum
|
||||
/// Article服务实现
|
||||
/// </summary>
|
||||
[AppService]
|
||||
|
||||
public class ArticleService : CrudAppService<ArticleEntity, ArticleGetOutputDto, ArticleGetListOutputDto, long, ArticleGetListInputVo, ArticleCreateInputVo, ArticleUpdateInputVo>,
|
||||
IArticleService, IAutoApiService
|
||||
{
|
||||
[Autowired]
|
||||
private IArticleRepository _articleRepository { get; set; }
|
||||
|
||||
|
||||
[Autowired]
|
||||
private IRepository<DiscussEntity> _discussRepository { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取文章全部平铺信息
|
||||
/// </summary>
|
||||
/// <param name="discussId"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="UserFriendlyException"></exception>
|
||||
[Route("/api/article/all/discuss-id/{discussId}")]
|
||||
public async Task<List<ArticleAllOutputDto>> GetAllAsync([FromRoute] long discussId)
|
||||
{
|
||||
if (!await _discussRepository.IsAnyAsync(x => x.Id == discussId))
|
||||
{
|
||||
throw new UserFriendlyException(DiscussConst.主题不存在);
|
||||
}
|
||||
|
||||
var entities = await _articleRepository.GetTreeAsync(x => x.DiscussId == discussId);
|
||||
var result = entities.Tile();
|
||||
var items = _mapper.Map<List<ArticleAllOutputDto>>(result);
|
||||
return items;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询文章
|
||||
/// </summary>
|
||||
@@ -37,7 +59,7 @@ namespace Yi.BBS.Application.Forum
|
||||
throw new UserFriendlyException(DiscussConst.主题不存在);
|
||||
}
|
||||
|
||||
var entities = await _articleRepository.GetTreeAsync(x=>x.DiscussId==discussId);
|
||||
var entities = await _articleRepository.GetTreeAsync(x => x.DiscussId == discussId);
|
||||
var items = await MapToGetListOutputDtosAsync(entities);
|
||||
return items;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace Yi.BBS.Application.Forum.MapperConfig
|
||||
CreateMap<ArticleGetListInputVo, ArticleEntity>();
|
||||
CreateMap<ArticleCreateInputVo, ArticleEntity>();
|
||||
CreateMap<ArticleUpdateInputVo, ArticleEntity>();
|
||||
CreateMap<ArticleEntity, ArticleAllOutputDto>();
|
||||
CreateMap<ArticleEntity, ArticleGetListOutputDto>();
|
||||
CreateMap<ArticleEntity, ArticleGetOutputDto>();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using SqlSugar;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Data.Entities;
|
||||
@@ -26,4 +28,32 @@ namespace Yi.BBS.Domain.Forum.Entities
|
||||
|
||||
public List<ArticleEntity> Children { get; set; }
|
||||
}
|
||||
|
||||
public static class ArticleEntityExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 平铺自己
|
||||
/// </summary>
|
||||
/// <param name="entities"></param>
|
||||
/// <returns></returns>
|
||||
public static List<ArticleEntity> Tile(this List<ArticleEntity> entities)
|
||||
{
|
||||
var result = new List<ArticleEntity>();
|
||||
return StartRecursion(entities, result);
|
||||
}
|
||||
|
||||
private static List<ArticleEntity> StartRecursion(List<ArticleEntity> entities, List<ArticleEntity> result)
|
||||
{
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
result.Add(entity);
|
||||
if (entity.Children is not null && entity.Children.Where(x => x.IsDeleted == false).Count() > 0)
|
||||
{
|
||||
StartRecursion(entity.Children, result);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace Yi.BBS.Web
|
||||
{
|
||||
public class TestAutofac
|
||||
{
|
||||
[Autowired]
|
||||
public TestAutofac2 _testAutofac2 { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Yi.BBS.Web
|
||||
{
|
||||
public class TestAutofac2
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user