diff --git a/Yi.Framework.Net6/src/framework/Yi.Framework.Core.Sqlsugar/Repositories/SqlsugarRepository.cs b/Yi.Framework.Net6/src/framework/Yi.Framework.Core.Sqlsugar/Repositories/SqlsugarRepository.cs index 58db3a20..c530e44b 100644 --- a/Yi.Framework.Net6/src/framework/Yi.Framework.Core.Sqlsugar/Repositories/SqlsugarRepository.cs +++ b/Yi.Framework.Net6/src/framework/Yi.Framework.Core.Sqlsugar/Repositories/SqlsugarRepository.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; +using System.Reflection; using System.Text; using System.Threading.Tasks; using Yi.Framework.Core.Attributes; @@ -64,7 +65,7 @@ namespace Yi.Framework.Core.Sqlsugar.Repositories } public override async Task DeleteAsync(List deleteObjs) { - if (typeof(T) is ISoftDelete) + if (typeof(ISoftDelete).IsAssignableFrom(typeof(T))) { //反射赋值 deleteObjs.ForEach(e => ReflexHelper.SetModelValue(nameof(ISoftDelete.IsDeleted), true, e)); @@ -77,7 +78,7 @@ namespace Yi.Framework.Core.Sqlsugar.Repositories } public override async Task DeleteAsync(Expression> whereExpression) { - if (typeof(T) is ISoftDelete) + if (typeof(ISoftDelete).IsAssignableFrom(typeof(T))) { var entities = await GetListAsync(whereExpression); //反射赋值 @@ -91,8 +92,8 @@ namespace Yi.Framework.Core.Sqlsugar.Repositories } public override async Task DeleteByIdAsync(dynamic id) { - if (typeof(T) is ISoftDelete) - { + if (typeof(ISoftDelete).IsAssignableFrom(typeof(T))) + { var entity = await GetByIdAsync(id); //反射赋值 ReflexHelper.SetModelValue(nameof(ISoftDelete.IsDeleted), true, entity); @@ -106,9 +107,13 @@ namespace Yi.Framework.Core.Sqlsugar.Repositories } public override async Task DeleteByIdsAsync(dynamic[] ids) { - if (typeof(T) is ISoftDelete) + if (typeof(ISoftDelete).IsAssignableFrom(typeof(T))) { var entities = await _DbQueryable.In(ids).ToListAsync(); + if (entities.Count == 0) + { + return false; + } //反射赋值 entities.ForEach(e => ReflexHelper.SetModelValue(nameof(ISoftDelete.IsDeleted), true, e)); return await UpdateRangeAsync(entities); diff --git a/Yi.Framework.Net6/src/framework/Yi.Framework.Ddd/Services/Abstract/IDeleteAppService.cs b/Yi.Framework.Net6/src/framework/Yi.Framework.Ddd/Services/Abstract/IDeleteAppService.cs index d1c59f86..344af80f 100644 --- a/Yi.Framework.Net6/src/framework/Yi.Framework.Ddd/Services/Abstract/IDeleteAppService.cs +++ b/Yi.Framework.Net6/src/framework/Yi.Framework.Ddd/Services/Abstract/IDeleteAppService.cs @@ -8,6 +8,6 @@ namespace Yi.Framework.Ddd.Services.Abstract { public interface IDeleteAppService : IApplicationService { - Task DeleteAsync(TKey id); + Task DeleteAsync(string id); } } 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 0176e292..daf9217e 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 @@ -1,5 +1,7 @@ -using System; +using Microsoft.AspNetCore.Mvc; +using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -104,20 +106,40 @@ namespace Yi.Framework.Ddd.Services } /// - /// 删 + /// 单、多删 /// /// /// /// - public async Task DeleteAsync(TKey id) + public async Task DeleteAsync(string id) { if (id is null) { throw new ArgumentNullException(nameof(id)); } - await _repository.DeleteByIdAsync(id); + var idsValue = id.Split(','); + if (idsValue is null || idsValue.Length == 0) + { + throw new ArgumentNullException(nameof(id)); + } + return await _repository.DeleteByIdsAsync(idsValue.Select(x => (object)x!).ToArray()); } + ///// + ///// 删 + ///// + ///// + ///// + ///// + //public async Task DeleteAsync(TKey id) + //{ + // if (id is null) + // { + // throw new ArgumentNullException(nameof(id)); + // } + // return await _repository.DeleteByIdAsync(id); + //} + /// /// 改 /// @@ -131,7 +153,7 @@ namespace Yi.Framework.Ddd.Services { throw new ArgumentNullException(nameof(id)); } - + var entity = await MapToEntityAsync(input); entity.Id = id; await _repository.UpdateIgnoreNullAsync(entity); diff --git a/Yi.Framework.Net6/src/framework/Yi.Framework.Ddd/YiFrameworkSwaggerDoc.xml b/Yi.Framework.Net6/src/framework/Yi.Framework.Ddd/YiFrameworkSwaggerDoc.xml index 390a19a0..651ac4e1 100644 --- a/Yi.Framework.Net6/src/framework/Yi.Framework.Ddd/YiFrameworkSwaggerDoc.xml +++ b/Yi.Framework.Net6/src/framework/Yi.Framework.Ddd/YiFrameworkSwaggerDoc.xml @@ -11,9 +11,9 @@ - + - 删 + 单、多删 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 7b660a7e..61c1ac70 100644 --- a/Yi.Framework.Net6/src/module/Yi.Framework.Template/Program.cs +++ b/Yi.Framework.Net6/src/module/Yi.Framework.Template/Program.cs @@ -16,7 +16,7 @@ TemplateFactory templateFactory = new(); //List entityNames = new() { "Banner" }; string modelName = "Forum"; string nameSpaces = "Yi.BBS"; -List entityNames = new() { "Comment" }; +List entityNames = new() { "_" }; diff --git a/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Application.Contracts/ApplicationContractsSwaggerDoc.xml b/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Application.Contracts/ApplicationContractsSwaggerDoc.xml index ca95e020..fc82778f 100644 --- a/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Application.Contracts/ApplicationContractsSwaggerDoc.xml +++ b/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Application.Contracts/ApplicationContractsSwaggerDoc.xml @@ -14,6 +14,11 @@ Banner抽象 + + + Article输入创建对象 + + Comment输入创建对象 @@ -24,11 +29,21 @@ Discuss输入创建对象 + + + Label输入创建对象 + + Plate输入创建对象 + + + Article服务抽象 + + Comment服务抽象 @@ -39,6 +54,11 @@ Discuss服务抽象 + + + Label服务抽象 + + Plate服务抽象 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 98986fbc..a6680e5e 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 @@ -9,6 +9,27 @@ Banner服务实现 + + + Article服务实现 + + + + + 查询文章 + + + + + + + + 发表文章 + + + + + Comment服务实现 @@ -50,6 +71,25 @@ + + + Label服务实现 + + + + + 获取当前用户的主题类型 + + + + + + + 创建 + + + + Plate服务实现 diff --git a/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/Program.cs b/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/Program.cs index 5697f10f..c1a8d5b5 100644 --- a/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/Program.cs +++ b/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/Program.cs @@ -5,7 +5,6 @@ using Yi.Framework.Core.Extensions; using Yi.BBS.Web; using Yi.BBS.Application; - var builder = WebApplication.CreateBuilder(args); builder.WebHost.UseStartUrlsServer(builder.Configuration); 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 3f90022a..acbfad10 100644 Binary files a/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/yi-sqlsugar-dev.db and b/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/yi-sqlsugar-dev.db differ diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Article/ArticleCreateInputVo.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Article/ArticleCreateInputVo.cs new file mode 100644 index 00000000..2372df66 --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Article/ArticleCreateInputVo.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.BBS.Application.Contracts.Forum.Dtos +{ + /// + /// Article输入创建对象 + /// + public class ArticleCreateInputVo + { + 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/ArticleGetListInputVo.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Article/ArticleGetListInputVo.cs new file mode 100644 index 00000000..85ea760a --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Article/ArticleGetListInputVo.cs @@ -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 ArticleGetListInputVo : PagedAndSortedResultRequestDto + { + 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 new file mode 100644 index 00000000..8ba00442 --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Article/ArticleGetListOutputDto.cs @@ -0,0 +1,20 @@ +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 ArticleGetListOutputDto : IEntityDto + { + 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; } + + public List Children { get; set; } + } +} diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Article/ArticleGetOutputDto.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Article/ArticleGetOutputDto.cs new file mode 100644 index 00000000..8d3acff7 --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Article/ArticleGetOutputDto.cs @@ -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 ArticleGetOutputDto : IEntityDto + { + 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/ArticleUpdateInputVo.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Article/ArticleUpdateInputVo.cs new file mode 100644 index 00000000..f8607650 --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/Article/ArticleUpdateInputVo.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.BBS.Application.Contracts.Forum.Dtos +{ + public class ArticleUpdateInputVo + { + 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/MyType/MyTypeCreateInputVo.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/MyType/MyTypeCreateInputVo.cs new file mode 100644 index 00000000..8b23c3b0 --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/MyType/MyTypeCreateInputVo.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.BBS.Application.Contracts.Forum.Dtos +{ + /// + /// Label输入创建对象 + /// + public class MyTypeCreateInputVo + { + public string Name { get; set; } + public string? Color { get; set; } + public string? BackgroundColor { get; set; } + } +} diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/MyType/MyTypeGetListInputVo.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/MyType/MyTypeGetListInputVo.cs new file mode 100644 index 00000000..c81f294a --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/MyType/MyTypeGetListInputVo.cs @@ -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 MyTypeGetListInputVo : PagedAndSortedResultRequestDto + { + public long Id { get; set; } + public string Name { get; set; } + public string? Color { get; set; } + public string? BackgroundColor { get; set; } + public long UserId { get; set; } + } +} diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/MyType/MyTypeGetListOutputDto.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/MyType/MyTypeGetListOutputDto.cs new file mode 100644 index 00000000..93180425 --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/MyType/MyTypeGetListOutputDto.cs @@ -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 MyTypeGetListOutputDto : IEntityDto + { + public long Id { get; set; } + public string Name { get; set; } + public string? Color { get; set; } + public string? BackgroundColor { get; set; } + public long UserId { get; set; } + } +} diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/MyType/MyTypeOutputDto.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/MyType/MyTypeOutputDto.cs new file mode 100644 index 00000000..b25fd998 --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/MyType/MyTypeOutputDto.cs @@ -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 MyTypeOutputDto : IEntityDto + { + public long Id { get; set; } + public string Name { get; set; } + public string? Color { get; set; } + public string? BackgroundColor { get; set; } + public long UserId { get; set; } + } +} diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/MyType/MyTypeUpdateInputVo.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/MyType/MyTypeUpdateInputVo.cs new file mode 100644 index 00000000..1adc2969 --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/Dtos/MyType/MyTypeUpdateInputVo.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.BBS.Application.Contracts.Forum.Dtos +{ + public class MyTypeUpdateInputVo + { + public long Id { get; set; } + public string Name { get; set; } + public string? Color { get; set; } + public string? BackgroundColor { get; set; } + public long UserId { get; set; } + } +} diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/IArticleService.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/IArticleService.cs new file mode 100644 index 00000000..c1c8a411 --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/IArticleService.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.BBS.Application.Contracts.Forum.Dtos; +using Yi.Framework.Ddd.Services.Abstract; + +namespace Yi.BBS.Application.Contracts.Forum +{ + /// + /// Article服务抽象 + /// + public interface IArticleService : ICrudAppService + { + + } +} diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/ILabelService.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/ILabelService.cs new file mode 100644 index 00000000..bcbacbec --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application.Contracts/Forum/ILabelService.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.BBS.Application.Contracts.Forum.Dtos; +using Yi.Framework.Ddd.Services.Abstract; + +namespace Yi.BBS.Application.Contracts.Forum +{ + /// + /// Label服务抽象 + /// + public interface ILabelService : ICrudAppService + { + + } +} 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 new file mode 100644 index 00000000..fc2c31c0 --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/Forum/ArticleService.cs @@ -0,0 +1,64 @@ +using Yi.BBS.Application.Contracts.Forum; +using NET.AutoWebApi.Setting; +using Yi.BBS.Application.Contracts.Forum.Dtos; +using Yi.BBS.Domain.Forum.Entities; +using Yi.Framework.Ddd.Services; +using Yi.Framework.Ddd.Dtos; +using Microsoft.AspNetCore.Mvc; +using Yi.BBS.Domain.Forum.Repositories; +using Yi.Framework.Ddd.Repositories; +using Yi.BBS.Domain.Shared.Forum.ConstClasses; + +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; } + + /// + /// 查询文章 + /// + /// + /// + /// + public async Task> GetDiscussIdAsync([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 items = await MapToGetListOutputDtosAsync(entities); + return items; + } + + /// + /// 发表文章 + /// + /// + /// + /// + public async override Task CreateAsync(ArticleCreateInputVo input) + { + if (!await _discussRepository.IsAnyAsync(x => x.Id == input.DiscussId)) + { + throw new UserFriendlyException(DiscussConst.主题不存在); + } + if (input.ParentId != 0 && !await _repository.IsAnyAsync(x => x.Id == input.ParentId)) + { + throw new UserFriendlyException(ArticleConst.文章不存在); + } + return await base.CreateAsync(input); + } + } +} 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 new file mode 100644 index 00000000..f827724c --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/Forum/MapperConfig/ArticleProfile.cs @@ -0,0 +1,23 @@ +using AutoMapper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.BBS.Application.Contracts.Forum.Dtos; +using Yi.BBS.Domain.Forum.Entities; + +namespace Yi.BBS.Application.Forum.MapperConfig +{ + public class ArticleProfile: Profile + { + public ArticleProfile() + { + CreateMap(); + CreateMap(); + CreateMap(); + CreateMap(); + CreateMap(); + } + } +} diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/Forum/MapperConfig/MyTypeProfile.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/Forum/MapperConfig/MyTypeProfile.cs new file mode 100644 index 00000000..65d2724e --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/Forum/MapperConfig/MyTypeProfile.cs @@ -0,0 +1,23 @@ +using AutoMapper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.BBS.Application.Contracts.Forum.Dtos; +using Yi.BBS.Domain.Forum.Entities; + +namespace Yi.BBS.Application.Forum.MapperConfig +{ + public class MyTypeProfile: Profile + { + public MyTypeProfile() + { + CreateMap(); + CreateMap(); + CreateMap(); + CreateMap(); + CreateMap(); + } + } +} diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/Forum/MyTypeService.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/Forum/MyTypeService.cs new file mode 100644 index 00000000..903e92c2 --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/Forum/MyTypeService.cs @@ -0,0 +1,53 @@ +using Yi.BBS.Application.Contracts.Forum; +using NET.AutoWebApi.Setting; +using Yi.BBS.Application.Contracts.Forum.Dtos; +using Yi.BBS.Domain.Forum.Entities; +using Yi.Framework.Ddd.Services; +using Yi.Framework.Core.CurrentUsers; +using SqlSugar; +using Yi.Framework.Ddd.Dtos; +using Yi.Framework.Data.Filters; + +namespace Yi.BBS.Application.Forum +{ + /// + /// Label服务实现 + /// + [AppService] + public class MyTypeService : CrudAppService, + ILabelService, IAutoApiService + { + [Autowired] + private ICurrentUser _currentUser { get; set; } + + [Autowired] + private IDataFilter _dataFilter { get; set; } + + /// + /// 获取当前用户的主题类型 + /// + /// + /// + public Task> GetListCurrentAsync(MyTypeGetListInputVo input) + { + + _dataFilter.AddFilter(x => x.UserId == _currentUser.Id); + return base.GetListAsync(input); + } + + /// + /// 创建 + /// + /// + /// + public override async Task CreateAsync(MyTypeCreateInputVo input) + { + var entity = await MapToEntityAsync(input); + entity.Id = SnowflakeHelper.NextId; + entity.UserId = _currentUser.Id; + entity.IsDeleted = false; + var outputEntity = await _repository.InsertReturnEntityAsync(entity); + return await MapToGetOutputDtoAsync(outputEntity); + } + } +} diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/GlobalSetting/TempService.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/GlobalSetting/TempService.cs index d440a27e..48815354 100644 --- a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/GlobalSetting/TempService.cs +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Application/GlobalSetting/TempService.cs @@ -62,7 +62,7 @@ namespace Yi.BBS.Application.GlobalSetting { var dto = new List(); dto.Add(new ActionJwtDto { Router = "/index", ActionName = "首页" }); - //dto.Add(new ActionJwtDto { Router = "", ActionName = "" }); + //dto.Add(new ActionJwtDto { Router = "/admLable", ActionName = "标签管理" }); //dto.Add(new ActionJwtDto { Router = "", ActionName = "" }); //dto.Add(new ActionJwtDto { Router = "", ActionName = "" }); //dto.Add(new ActionJwtDto { Router = "", ActionName = "" }); diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain.Shared/Forum/ConstClasses/ArticleConst.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain.Shared/Forum/ConstClasses/ArticleConst.cs new file mode 100644 index 00000000..b44ef841 --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain.Shared/Forum/ConstClasses/ArticleConst.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.BBS.Domain.Shared.Forum.ConstClasses +{ + /// + /// 常量定义 + /// + + public class ArticleConst + { + public const string 文章不存在 = "传入的文章id不存在"; + } +} diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain.Shared/Forum/ConstClasses/LabelConst.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain.Shared/Forum/ConstClasses/LabelConst.cs new file mode 100644 index 00000000..e0fd6841 --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain.Shared/Forum/ConstClasses/LabelConst.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.BBS.Domain.Shared.Forum.ConstClasses +{ + /// + /// 常量定义 + /// + + public class LabelConst + { + } +} 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 new file mode 100644 index 00000000..70d5b188 --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Forum/Entities/ArticleEntity.cs @@ -0,0 +1,29 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Data.Entities; +using Yi.Framework.Ddd.Entities; + +namespace Yi.BBS.Domain.Forum.Entities +{ + [SugarTable("Article")] + public class ArticleEntity : IEntity, ISoftDelete + { + [SugarColumn(IsPrimaryKey = true)] + public long Id { get; set; } + public bool IsDeleted { get; set; } + + 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.Domain/Forum/Entities/DiscussMyTypeEntity.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Forum/Entities/DiscussMyTypeEntity.cs new file mode 100644 index 00000000..56440647 --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Forum/Entities/DiscussMyTypeEntity.cs @@ -0,0 +1,21 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Ddd.Entities; + +namespace Yi.BBS.Domain.Forum.Entities +{ + [SugarTable("DiscussMyType")] + public class DiscussMyTypeEntity : IEntity + { + [SugarColumn(IsPrimaryKey = true)] + public long Id { get; set; } + + public long DiscussId { get; set; } + + public long MyTypeId { get; set; } + } +} diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Forum/Entities/MyTypeEntity.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Forum/Entities/MyTypeEntity.cs new file mode 100644 index 00000000..3dee5b65 --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Forum/Entities/MyTypeEntity.cs @@ -0,0 +1,25 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Data.Entities; +using Yi.Framework.Ddd.Entities; + +namespace Yi.BBS.Domain.Forum.Entities +{ + [SugarTable("MyType")] + public class MyTypeEntity : IEntity, ISoftDelete + { + [SugarColumn(IsPrimaryKey = true)] + public long Id { get; set; } + public bool IsDeleted { get; set; } + + public string Name { get; set; } + public string? Color { get; set; } + public string? BackgroundColor { get; set; } + + public long UserId { get; set; } + } +} diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Forum/Repositories/IArticleRepository.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Forum/Repositories/IArticleRepository.cs new file mode 100644 index 00000000..c8056a9f --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Domain/Forum/Repositories/IArticleRepository.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; +using Yi.BBS.Domain.Forum.Entities; +using Yi.Framework.Ddd.Repositories; + +namespace Yi.BBS.Domain.Forum.Repositories +{ + public interface IArticleRepository:IRepository + { + Task> GetTreeAsync(Expression> where); + } +} diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Sqlsugar/Repositories/ArticleRepository.cs b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Sqlsugar/Repositories/ArticleRepository.cs new file mode 100644 index 00000000..0b23a30a --- /dev/null +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Sqlsugar/Repositories/ArticleRepository.cs @@ -0,0 +1,27 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; +using Yi.BBS.Domain.Forum.Entities; +using Yi.BBS.Domain.Forum.Repositories; +using Yi.Framework.Core.Sqlsugar.Repositories; +using Yi.Framework.Ddd.Repositories; + +namespace Yi.BBS.Sqlsugar.Repositories +{ + [AppService] + public class ArticleRepository : SqlsugarRepository, IArticleRepository + { + public ArticleRepository(ISqlSugarClient context) : base(context) + { + } + + public async Task> GetTreeAsync(Expression> where) + { + return await _DbQueryable.Where(where).ToTreeAsync(x => x.Children, x => x.ParentId, 0); + } + } +}