From d6565bd2d98d02342a91fe198bfb57f904865853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A9=99=E5=AD=90?= <454313500@qq.com> Date: Sun, 29 Jan 2023 20:56:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0bbs=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/Yi.Framework.Template/Program.cs | 4 +-- .../ApplicationSwaggerDoc.xml | 8 +++++ .../BBS/Yi.BBS.Domain/DomainSwaggerDoc.xml | 7 ++++ .../project/BBS/Yi.BBS.Web/yi-sqlsugar-dev.db | Bin 94208 -> 94208 bytes .../Forum/Dtos/Article/ArticleAllOutputDto.cs | 18 ++++++++++ .../Dtos/Article/ArticleGetListOutputDto.cs | 1 - .../Forum/ArticleService.cs | 24 ++++++++++++- .../Forum/MapperConfig/ArticleProfile.cs | 1 + .../Forum/Entities/ArticleEntity.cs | 32 +++++++++++++++++- .../src/project/bbs/Yi.BBS.Web/TestAutofac.cs | 8 ----- .../project/bbs/Yi.BBS.Web/TestAutofac2.cs | 6 ---- 11 files changed, 90 insertions(+), 19 deletions(-) create mode 100644 Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Article/ArticleAllOutputDto.cs delete mode 100644 Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/TestAutofac.cs delete mode 100644 Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/TestAutofac2.cs diff --git a/Yi.Framework.Net6/src/module/Yi.Framework.Template/Program.cs b/Yi.Framework.Net6/src/module/Yi.Framework.Template/Program.cs index 61c1ac70..b5c98a2e 100644 --- a/Yi.Framework.Net6/src/module/Yi.Framework.Template/Program.cs +++ b/Yi.Framework.Net6/src/module/Yi.Framework.Template/Program.cs @@ -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"); \ No newline at end of file +//var template = "D:\\C#\\Yi\\Yi.Framework.Net6\\src\\project\\template"; +//FileHelper.AllInfoReplace(template, "Template", "RBAC"); \ No newline at end of file diff --git a/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Application/ApplicationSwaggerDoc.xml b/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Application/ApplicationSwaggerDoc.xml index a6680e5e..9dc71566 100644 --- a/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Application/ApplicationSwaggerDoc.xml +++ b/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Application/ApplicationSwaggerDoc.xml @@ -14,6 +14,14 @@ Article服务实现 + + + 获取文章全部平铺信息 + + + + + 查询文章 diff --git a/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Domain/DomainSwaggerDoc.xml b/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Domain/DomainSwaggerDoc.xml index df627c2b..91f7886c 100644 --- a/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Domain/DomainSwaggerDoc.xml +++ b/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Domain/DomainSwaggerDoc.xml @@ -4,6 +4,13 @@ Yi.BBS.Domain + + + 平铺自己 + + + + 论坛模块的领域服务 diff --git a/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/yi-sqlsugar-dev.db b/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/yi-sqlsugar-dev.db index acbfad1092892416749dbf9357aec8bed8f0ed8f..cdfebb0882e037b1ad2d8fb55fbee2ed1844d49d 100644 GIT binary patch delta 321 zcmZp8z}oPDb%Hdb-b5K^M!k&*OWuoc@D(!f-{N1wAH=WC&%$?}Zx&zSW5Ii7)ptia=qEtB*0+I0aPe2&&CE;sImnp1W{q6 zYXoP&6a$Uo&j%W1%#N%{@~IO-lOb4>)l?&0Lv&rLY(QP&FgJk>GBh$agjoYsK3VJk zEfEg>nGF12fL=Sx|D68-|7QMW{4;?bYvecKVP<25`G^zB0lS(5$^pBE9m)Y)!nXY^ IKcjI109_PalmGw# delta 65 zcmZp8z}oPDb%Hdb) + { + 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; } + } +} diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Article/ArticleGetListOutputDto.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Article/ArticleGetListOutputDto.cs index 8ba00442..466433fd 100644 --- a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Article/ArticleGetListOutputDto.cs +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Article/ArticleGetListOutputDto.cs @@ -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 Children { get; set; } } diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/Forum/ArticleService.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/Forum/ArticleService.cs index fc2c31c0..200ef445 100644 --- a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/Forum/ArticleService.cs +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/Forum/ArticleService.cs @@ -15,15 +15,37 @@ namespace Yi.BBS.Application.Forum /// Article服务实现 /// [AppService] + public class ArticleService : CrudAppService, IArticleService, IAutoApiService { [Autowired] private IArticleRepository _articleRepository { get; set; } + [Autowired] private IRepository _discussRepository { get; set; } + /// + /// 获取文章全部平铺信息 + /// + /// + /// + /// + [Route("/api/article/all/discuss-id/{discussId}")] + public async Task> 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>(result); + return items; + } + /// /// 查询文章 /// @@ -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; } diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/Forum/MapperConfig/ArticleProfile.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/Forum/MapperConfig/ArticleProfile.cs index f827724c..2bde67b2 100644 --- a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/Forum/MapperConfig/ArticleProfile.cs +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/Forum/MapperConfig/ArticleProfile.cs @@ -16,6 +16,7 @@ namespace Yi.BBS.Application.Forum.MapperConfig CreateMap(); CreateMap(); CreateMap(); + CreateMap(); CreateMap(); CreateMap(); } diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Forum/Entities/ArticleEntity.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Forum/Entities/ArticleEntity.cs index 70d5b188..2b3e8473 100644 --- a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Forum/Entities/ArticleEntity.cs +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Forum/Entities/ArticleEntity.cs @@ -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 Children { get; set; } } + + public static class ArticleEntityExtensions + { + /// + /// 平铺自己 + /// + /// + /// + public static List Tile(this List entities) + { + var result = new List(); + return StartRecursion(entities, result); + } + + private static List StartRecursion(List entities, List 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; + } + + } } diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/TestAutofac.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/TestAutofac.cs deleted file mode 100644 index aa35c91b..00000000 --- a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/TestAutofac.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Yi.BBS.Web -{ - public class TestAutofac - { - [Autowired] - public TestAutofac2 _testAutofac2 { get; set; } - } -} diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/TestAutofac2.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/TestAutofac2.cs deleted file mode 100644 index 3f431298..00000000 --- a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/TestAutofac2.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Yi.BBS.Web -{ - public class TestAutofac2 - { - } -}