From ac26df68273a2c246b03df0321a719dc3bf42956 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A9=99=E5=AD=90?= <454313500@qq.com> Date: Wed, 25 Jan 2023 22:27:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=B8=BB=E9=A2=98=E5=86=85?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ControllerAddExtension.cs | 25 ++++++++++ .../Yi.Framework.AspNetCore.csproj | 1 + .../Exceptions/UserFriendlyException.cs | 16 ------- .../Services/CrudAppService.cs | 2 +- .../ApplicationSwaggerDoc.xml | 16 +++++++ .../BBS/Yi.BBS.Domain/DomainSwaggerDoc.xml | 5 ++ .../project/BBS/Yi.BBS.Web/YiBBSWebModule.cs | 1 + .../project/BBS/Yi.BBS.Web/yi-sqlsugar-dev.db | Bin 53248 -> 53248 bytes .../Dtos/Banner/BannerGetListOutputDto.cs | 2 + .../Dtos/Banner/BannerGetOutputDto.cs | 2 + .../Dtos/Discuss/DiscussCreateInputVo.cs | 3 -- .../Dtos/Discuss/DiscussGetListOutputDto.cs | 2 + .../Forum/Dtos/Discuss/DiscussGetOutputDto.cs | 2 + .../Forum/Dtos/Plate/PlateGetListOutputDto.cs | 2 + .../Forum/Dtos/Plate/PlateUpdateInputVo.cs | 2 + .../GlobalSetting/Dtos/Temp/ActionJwtDto.cs | 6 ++- .../GlobalSetting/Dtos/Temp/LoginDto.cs | 4 +- .../Forum/DiscussService.cs | 39 ++++++++++++++- .../Forum/ConstClasses/PlateConst.cs | 1 + .../Forum/Entities/DiscussEntity.cs | 3 ++ .../Forum/Entities/PlateEntity.cs | 1 + .../bbs/Yi.BBS.Domain/Forum/ForumManager.cs | 45 ++++++++++++++++++ 22 files changed, 155 insertions(+), 25 deletions(-) create mode 100644 Yi.Framework.Net6/src/framework/Yi.Framework.AspNetCore/Microsoft/Extensions/DependencyInjection/ControllerAddExtension.cs create mode 100644 Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Forum/ForumManager.cs diff --git a/Yi.Framework.Net6/src/framework/Yi.Framework.AspNetCore/Microsoft/Extensions/DependencyInjection/ControllerAddExtension.cs b/Yi.Framework.Net6/src/framework/Yi.Framework.AspNetCore/Microsoft/Extensions/DependencyInjection/ControllerAddExtension.cs new file mode 100644 index 00000000..cb17808a --- /dev/null +++ b/Yi.Framework.Net6/src/framework/Yi.Framework.AspNetCore/Microsoft/Extensions/DependencyInjection/ControllerAddExtension.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.DependencyInjection; +using Newtonsoft.Json.Serialization; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.AspNetCore.Microsoft.Extensions.DependencyInjection +{ + public static class ControllerAddExtension + { + public static IMvcBuilder AddNewtonsoftJsonServer(this IMvcBuilder mvcBuilder) + { + return mvcBuilder.AddNewtonsoftJson(opt => + { + //忽略循环引用 + opt.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; + //不改变字段大小 + //opt.SerializerSettings.ContractResolver = new DefaultContractResolver(); + }); + } + } +} diff --git a/Yi.Framework.Net6/src/framework/Yi.Framework.AspNetCore/Yi.Framework.AspNetCore.csproj b/Yi.Framework.Net6/src/framework/Yi.Framework.AspNetCore/Yi.Framework.AspNetCore.csproj index 1fb2656f..4c195f34 100644 --- a/Yi.Framework.Net6/src/framework/Yi.Framework.AspNetCore/Yi.Framework.AspNetCore.csproj +++ b/Yi.Framework.Net6/src/framework/Yi.Framework.AspNetCore/Yi.Framework.AspNetCore.csproj @@ -8,6 +8,7 @@ + diff --git a/Yi.Framework.Net6/src/framework/Yi.Framework.Core/Exceptions/UserFriendlyException.cs b/Yi.Framework.Net6/src/framework/Yi.Framework.Core/Exceptions/UserFriendlyException.cs index 35084ab5..71b0a4a4 100644 --- a/Yi.Framework.Net6/src/framework/Yi.Framework.Core/Exceptions/UserFriendlyException.cs +++ b/Yi.Framework.Net6/src/framework/Yi.Framework.Core/Exceptions/UserFriendlyException.cs @@ -27,22 +27,6 @@ LogLevel logLevel = LogLevel.Warning) Details = details; } - public UserFriendlyException( - string message, - ResultCodeEnum code = ResultCodeEnum.NotSuccess, - string? details = null, - Exception? innerException = null, - LogLevel logLevel = LogLevel.Warning) - : base( - (int)code, - message, - details, - innerException, - logLevel) - { - Details = details; - } - /// /// 序列化参数的构造函数 /// diff --git a/Yi.Framework.Net6/src/framework/Yi.Framework.Ddd/Services/CrudAppService.cs b/Yi.Framework.Net6/src/framework/Yi.Framework.Ddd/Services/CrudAppService.cs index b61590d8..0176e292 100644 --- a/Yi.Framework.Net6/src/framework/Yi.Framework.Ddd/Services/CrudAppService.cs +++ b/Yi.Framework.Net6/src/framework/Yi.Framework.Ddd/Services/CrudAppService.cs @@ -93,7 +93,7 @@ namespace Yi.Framework.Ddd.Services /// /// /// - public async Task CreateAsync(TCreateInput input) + public virtual async Task CreateAsync(TCreateInput input) { var entity = await MapToEntityAsync(input); 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 5a9e6fa0..5529edee 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,22 @@ Discuss服务实现 + + + 获取改板块下的主题 + + + + + + + + 创建主题 + + + + + Plate服务实现 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 2bb88ab8..df627c2b 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,5 +4,10 @@ Yi.BBS.Domain + + + 论坛模块的领域服务 + + diff --git a/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/YiBBSWebModule.cs b/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/YiBBSWebModule.cs index 2ec52465..b9bf3ce0 100644 --- a/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/YiBBSWebModule.cs +++ b/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/YiBBSWebModule.cs @@ -5,6 +5,7 @@ using Yi.Framework.Core; using Yi.Framework.Core.Attributes; using Yi.BBS.Application; using Yi.BBS.Sqlsugar; +using Yi.Framework.AspNetCore.Microsoft.Extensions.DependencyInjection; namespace Yi.BBS.Web { 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 c9071c58ad53e8d77e563a28560526664a956c96..a29b96376f03944c9eaff1dd38794dfd01781186 100644 GIT binary patch delta 174 zcmV;f08#&dpaX!Q1CSd56p70P*rh({( cs^zY$7IV}N%R&MW0J1>&4+nJ$?7o5!02@6{mjD0& delta 24 gcmZozz}&Ead4e>f@I)DBM&XSKOV)2@3HT!q0A#lakN^Mx diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Exhibition/Dtos/Banner/BannerGetListOutputDto.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Exhibition/Dtos/Banner/BannerGetListOutputDto.cs index 72c518aa..db8ddd47 100644 --- a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Exhibition/Dtos/Banner/BannerGetListOutputDto.cs +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Exhibition/Dtos/Banner/BannerGetListOutputDto.cs @@ -1,3 +1,4 @@ +using SqlSugar; using System; using System.Collections.Generic; using System.Linq; @@ -9,6 +10,7 @@ namespace Yi.BBS.Application.Contracts.Exhibition.Dtos.Banner { public class BannerGetListOutputDto : IEntityDto { + public long Id { get; set; } public string Name { get; set; } public string? Logo { get; set; } diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Exhibition/Dtos/Banner/BannerGetOutputDto.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Exhibition/Dtos/Banner/BannerGetOutputDto.cs index 0e900bc3..a5a34491 100644 --- a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Exhibition/Dtos/Banner/BannerGetOutputDto.cs +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Exhibition/Dtos/Banner/BannerGetOutputDto.cs @@ -1,3 +1,4 @@ +using SqlSugar; using System; using System.Collections.Generic; using System.Linq; @@ -9,6 +10,7 @@ namespace Yi.BBS.Application.Contracts.Exhibition.Dtos { public class BannerGetOutputDto : IEntityDto { + public long Id { get; set; } public string Name { get; set; } public string? Logo { get; set; } diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Discuss/DiscussCreateInputVo.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Discuss/DiscussCreateInputVo.cs index 5a1afc11..0f3bbcc7 100644 --- a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Discuss/DiscussCreateInputVo.cs +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Discuss/DiscussCreateInputVo.cs @@ -11,13 +11,10 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss /// public class DiscussCreateInputVo { - public long Id { get; set; } public string Title { get; set; } public string Types { get; set; } public string? Introduction { get; set; } public DateTime? CreateTime { get; set; } - public int AgreeNum { get; set; } - public int SeeNum { get; set; } public string Content { get; set; } public string? Color { get; set; } } diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Discuss/DiscussGetListOutputDto.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Discuss/DiscussGetListOutputDto.cs index 1ae57b18..d0020706 100644 --- a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Discuss/DiscussGetListOutputDto.cs +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Discuss/DiscussGetListOutputDto.cs @@ -1,3 +1,4 @@ +using SqlSugar; using System; using System.Collections.Generic; using System.Linq; @@ -9,6 +10,7 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss { public class DiscussGetListOutputDto : IEntityDto { + public long Id { get; set; } public string Title { get; set; } public string Types { get; set; } diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Discuss/DiscussGetOutputDto.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Discuss/DiscussGetOutputDto.cs index 03c10369..ec993420 100644 --- a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Discuss/DiscussGetOutputDto.cs +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Discuss/DiscussGetOutputDto.cs @@ -1,3 +1,4 @@ +using SqlSugar; using System; using System.Collections.Generic; using System.Linq; @@ -9,6 +10,7 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos { public class DiscussGetOutputDto : IEntityDto { + public long Id { get; set; } public string Title { get; set; } public string Types { get; set; } diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Plate/PlateGetListOutputDto.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Plate/PlateGetListOutputDto.cs index 3415146a..14841038 100644 --- a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Plate/PlateGetListOutputDto.cs +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Plate/PlateGetListOutputDto.cs @@ -1,3 +1,4 @@ +using SqlSugar; using System; using System.Collections.Generic; using System.Linq; @@ -9,6 +10,7 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos.Plate { public class PlateGetListOutputDto : IEntityDto { + public long Id { get; set; } public string Name { get; set; } public string? Logo { get; set; } diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Plate/PlateUpdateInputVo.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Plate/PlateUpdateInputVo.cs index 4567cca6..c033bd3d 100644 --- a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Plate/PlateUpdateInputVo.cs +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Plate/PlateUpdateInputVo.cs @@ -1,3 +1,4 @@ +using SqlSugar; using System; using System.Collections.Generic; using System.Linq; @@ -8,6 +9,7 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos.Plate { public class PlateUpdateInputVo { + public long Id { get; set; } public string Name { get; set; } public string? Logo { get; set; } diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/GlobalSetting/Dtos/Temp/ActionJwtDto.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/GlobalSetting/Dtos/Temp/ActionJwtDto.cs index d0af2df9..1abc63bb 100644 --- a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/GlobalSetting/Dtos/Temp/ActionJwtDto.cs +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/GlobalSetting/Dtos/Temp/ActionJwtDto.cs @@ -1,4 +1,5 @@ -using System; +using SqlSugar; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,7 +9,8 @@ namespace Yi.BBS.Application.Contracts.GlobalSetting.Dtos.Temp { public class ActionJwtDto { - public int Id { get; set; } + + public long Id { get; set; } public string ActionName { get; set; } public string Router { get; set; } public string Icon { get; set; } diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/GlobalSetting/Dtos/Temp/LoginDto.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/GlobalSetting/Dtos/Temp/LoginDto.cs index d2897df7..416fdb9e 100644 --- a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/GlobalSetting/Dtos/Temp/LoginDto.cs +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/GlobalSetting/Dtos/Temp/LoginDto.cs @@ -1,4 +1,5 @@ -using System; +using SqlSugar; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -18,6 +19,7 @@ namespace Yi.BBS.Application.Contracts.GlobalSetting.Dtos.Temp public class LoginUserInfoDto { + public long Id { get; set; } public string UserName { get; set; } diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/Forum/DiscussService.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/Forum/DiscussService.cs index 8075f030..32984772 100644 --- a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/Forum/DiscussService.cs +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/Forum/DiscussService.cs @@ -6,6 +6,10 @@ using Yi.Framework.Ddd.Services; using Yi.BBS.Application.Contracts.Forum.Dtos.Discuss; using Microsoft.AspNetCore.Mvc; using Yi.Framework.Ddd.Dtos; +using Yi.BBS.Domain.Forum; +using AutoMapper; +using SqlSugar; +using Microsoft.AspNetCore.Routing; namespace Yi.BBS.Application.Forum { @@ -16,12 +20,43 @@ namespace Yi.BBS.Application.Forum public class DiscussService : CrudAppService, IDiscussService, IAutoApiService { + private readonly ForumManager _forumManager; + public DiscussService(ForumManager forumManager) + { + _forumManager = forumManager; + } + + /// + /// 获取改板块下的主题 + /// + /// + /// + /// + public async Task> GetPlateIdAsync([FromRoute] long plateId, [FromQuery] DiscussGetListInputVo input) { var entities = await _repository.GetPageListAsync(x => x.PlateId == plateId, input); - var items= await MapToGetListOutputDtosAsync(entities); - var total = await _repository.CountAsync(x=>x.IsDeleted==false); + var items = await MapToGetListOutputDtosAsync(entities); + var total = await _repository.CountAsync(x => x.IsDeleted == false); return new PagedResultDto(total, items); } + + [AutoApi(false)] + public override Task CreateAsync(DiscussCreateInputVo input) + { + return base.CreateAsync(input); + } + + /// + /// 创建主题 + /// + /// + /// + /// + public async Task CreatePlateIdAsync([FromRoute] long plateId, DiscussCreateInputVo input) + { + var entity = await _forumManager.CreateDiscussAsync(plateId, input.Title, input.Types, input.Content, input.Introduction); + return await MapToGetOutputDtoAsync(entity); + } } } diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain.Shared/Forum/ConstClasses/PlateConst.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain.Shared/Forum/ConstClasses/PlateConst.cs index 8edbe1e1..92acf486 100644 --- a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain.Shared/Forum/ConstClasses/PlateConst.cs +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain.Shared/Forum/ConstClasses/PlateConst.cs @@ -12,5 +12,6 @@ namespace Yi.BBS.Domain.Shared.Forum.ConstClasses public class PlateConst { + public const string 板块不存在 = "传入的板块id不存在"; } } diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Forum/Entities/DiscussEntity.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Forum/Entities/DiscussEntity.cs index bc75096d..8be0dc73 100644 --- a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Forum/Entities/DiscussEntity.cs +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Forum/Entities/DiscussEntity.cs @@ -13,6 +13,9 @@ namespace Yi.BBS.Domain.Forum.Entities [SugarTable("Discuss")] public class DiscussEntity : IEntity, ISoftDelete { + public DiscussEntity() + { + } public DiscussEntity(long plateId) { PlateId = plateId; diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Forum/Entities/PlateEntity.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Forum/Entities/PlateEntity.cs index 096ec0d0..f2901366 100644 --- a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Forum/Entities/PlateEntity.cs +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Forum/Entities/PlateEntity.cs @@ -12,6 +12,7 @@ namespace Yi.BBS.Domain.Forum.Entities [SugarTable("Plate")] public class PlateEntity : IEntity, ISoftDelete { + [SugarColumn(IsPrimaryKey = true)] public long Id { get; set; } public string Name { get; set; } diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Forum/ForumManager.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Forum/ForumManager.cs new file mode 100644 index 00000000..327b5cb2 --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Forum/ForumManager.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.BBS.Domain.Forum.Entities; +using Yi.BBS.Domain.Shared.Forum.ConstClasses; +using Yi.Framework.Ddd.Repositories; + +namespace Yi.BBS.Domain.Forum +{ + /// + /// 论坛模块的领域服务 + /// + [AppService] + public class ForumManager + { + private readonly IRepository _discussRepository; + private readonly IRepository _plateEntityRepository; + public ForumManager(IRepository discussRepository, IRepository plateEntityRepository) + { + _discussRepository = discussRepository; + _plateEntityRepository = plateEntityRepository; + } + + //主题是不能直接创建的,需要由领域服务统一创建 + public async Task CreateDiscussAsync(long plateId, string title, string types, string content, string? introduction = null) + { + if (!await _plateEntityRepository.IsAnyAsync(x => x.Id == plateId)) + { + throw new UserFriendlyException(PlateConst.板块不存在); + } + var entity = new DiscussEntity(plateId); + entity.Id = SnowflakeHelper.NextId; + entity.Title = title; + entity.Types = types; + entity.Introduction = introduction; + entity.Content = content; + entity.CreateTime = DateTime.Now; + entity.AgreeNum= 0; + entity.SeeNum= 0; + return await _discussRepository.InsertReturnEntityAsync(entity); + } + } +}