From 0e78857645839c34409e624699762dd205d026bc Mon Sep 17 00:00:00 2001 From: chenchun <454313500@qq.com> Date: Mon, 2 Jan 2023 00:09:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=8A=A8=E6=98=A0?= =?UTF-8?q?=E5=B0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Config/SwaggerDoc.xml | 1 - .../Controllers/StudentController.cs | 1 - .../yi-sqlsugar-dev.db | Bin 282624 -> 282624 bytes .../Helper/AssemblyHelper.cs | 32 ++++++++++++++---- .../Base/Crud/AbstractKeyCrudAppService.cs | 6 ++-- .../AutoMapperExtension.cs | 10 ++++-- 6 files changed, 36 insertions(+), 14 deletions(-) diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml index bb267175..655c8090 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml @@ -719,7 +719,6 @@ - diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/StudentController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/StudentController.cs index f98c18ba..dd351468 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/StudentController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/StudentController.cs @@ -57,7 +57,6 @@ namespace Brick.IFServer.Controllers /// /// /// - /// /// [HttpGet] public async Task>> GetLsit() diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db index ee93ef516bd5f65c33d1d80a08f252176604f31d..24c8ecac083402dc46b60b17098cda4a6559be72 100644 GIT binary patch delta 179 zcmZozAlR@#aDp_W{zMsPM*YTw)&$1Z1g6#m=B)`VOY}LI_4eKxo6>Fn80_jNqo x(Q3^I)TYWX{fF?}W#DKCl82E1hWzX?Xzv0iK0RWh{7gzuQ diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/AssemblyHelper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/AssemblyHelper.cs index ac95e268..c74ef1ff 100644 --- a/Yi.Framework.Net6/Yi.Framework.Common/Helper/AssemblyHelper.cs +++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/AssemblyHelper.cs @@ -1,4 +1,6 @@ -using System; +using AutoMapper; +using AutoMapper.Internal; +using System; using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -9,14 +11,32 @@ namespace Yi.Framework.Common.Helper { public class AssemblyHelper { - public static List GetClass(string assemblyFile, string className = null, string spaceName=null) + public static List GetClass(string assemblyFile, string className = null, string spaceName = null) { Assembly assembly = Assembly.Load(assemblyFile); - return assembly.GetTypes().Where(m => m.IsClass - && className == null?true:m.Name==className - && spaceName == null ? true :m.Namespace == spaceName + return assembly.GetTypes().Where(m => m.IsClass + && className == null ? true : m.Name == className + && spaceName == null ? true : m.Namespace == spaceName ).ToList(); } + public static List GetClassByBaseClassesAndInterfaces(string assemblyFile, Type type) + { + Assembly assembly = Assembly.Load(assemblyFile); + + List resList = new List(); + + List typeList = assembly.GetTypes().Where(m => m.IsClass).ToList(); + foreach (var t in typeList) + { + var data = t.BaseClassesAndInterfaces(); + if (data.Contains(type)) + { + resList.Add(t); + } + + } + return resList; + } } -} +} \ No newline at end of file diff --git a/Yi.Framework.Net6/Yi.Framework.Service/Base/Crud/AbstractKeyCrudAppService.cs b/Yi.Framework.Net6/Yi.Framework.Service/Base/Crud/AbstractKeyCrudAppService.cs index 429e74b4..00f1585d 100644 --- a/Yi.Framework.Net6/Yi.Framework.Service/Base/Crud/AbstractKeyCrudAppService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Service/Base/Crud/AbstractKeyCrudAppService.cs @@ -80,7 +80,7 @@ namespace Yi.Framework.Service.Base.Crud /// /// /// - public virtual async Task DeleteAsync(IEnumerable ids) + public virtual Task DeleteAsync(IEnumerable ids) { throw new NotImplementedException(); } @@ -110,9 +110,9 @@ namespace Yi.Framework.Service.Base.Crud /// /// /// - protected virtual async Task UpdateValidAsync(TEntity idEntity, TUpdateInput dto) + protected virtual Task UpdateValidAsync(TEntity idEntity, TUpdateInput dto) { - return; + return Task.CompletedTask; } /// diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/AspNetCoreExtensions/AutoMapperExtension.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/AspNetCoreExtensions/AutoMapperExtension.cs index b227fba3..78c02d9f 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/AspNetCoreExtensions/AutoMapperExtension.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/AspNetCoreExtensions/AutoMapperExtension.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Builder; +using AutoMapper; +using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; using System; using System.IO; @@ -15,8 +16,11 @@ namespace Yi.Framework.WebCore.AspNetCoreExtensions public static IServiceCollection AddAutoMapperService(this IServiceCollection services) { //这里会通过反射自动注入的,先临时这样 - services.AddAutoMapper(typeof(AutoMapperProfile),typeof(StudentProfile)); - + + var profileList = Common.Helper.AssemblyHelper.GetClassByBaseClassesAndInterfaces("Yi.Framework.DTOModel", typeof(Profile)); + profileList.Add(typeof(AutoMapperProfile)); + services.AddAutoMapper(profileList.ToArray()); + return services; } }