添加自动映射
This commit is contained in:
@@ -719,7 +719,6 @@
|
|||||||
<summary>
|
<summary>
|
||||||
查
|
查
|
||||||
</summary>
|
</summary>
|
||||||
<param name="id"></param>
|
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Brick.IFServer.Controllers.StudentController.Del(System.Collections.Generic.List{System.Guid})">
|
<member name="M:Brick.IFServer.Controllers.StudentController.Del(System.Collections.Generic.List{System.Guid})">
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ namespace Brick.IFServer.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// <20><>
|
/// <20><>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<Result<List<StudentListOutput>>> GetLsit()
|
public async Task<Result<List<StudentListOutput>>> GetLsit()
|
||||||
|
|||||||
Binary file not shown.
@@ -1,4 +1,6 @@
|
|||||||
using System;
|
using AutoMapper;
|
||||||
|
using AutoMapper.Internal;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
@@ -9,14 +11,32 @@ namespace Yi.Framework.Common.Helper
|
|||||||
{
|
{
|
||||||
public class AssemblyHelper
|
public class AssemblyHelper
|
||||||
{
|
{
|
||||||
public static List<Type> GetClass(string assemblyFile, string className = null, string spaceName=null)
|
public static List<Type> GetClass(string assemblyFile, string className = null, string spaceName = null)
|
||||||
{
|
{
|
||||||
Assembly assembly = Assembly.Load(assemblyFile);
|
Assembly assembly = Assembly.Load(assemblyFile);
|
||||||
return assembly.GetTypes().Where(m => m.IsClass
|
return assembly.GetTypes().Where(m => m.IsClass
|
||||||
&& className == null?true:m.Name==className
|
&& className == null ? true : m.Name == className
|
||||||
&& spaceName == null ? true :m.Namespace == spaceName
|
&& spaceName == null ? true : m.Namespace == spaceName
|
||||||
).ToList();
|
).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<Type> GetClassByBaseClassesAndInterfaces(string assemblyFile, Type type)
|
||||||
|
{
|
||||||
|
Assembly assembly = Assembly.Load(assemblyFile);
|
||||||
|
|
||||||
|
List<Type> resList = new List<Type>();
|
||||||
|
|
||||||
|
List<Type> 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,7 +80,7 @@ namespace Yi.Framework.Service.Base.Crud
|
|||||||
/// <param name="ids"></param>
|
/// <param name="ids"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <exception cref="NotImplementedException"></exception>
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
public virtual async Task DeleteAsync(IEnumerable<TKey> ids)
|
public virtual Task DeleteAsync(IEnumerable<TKey> ids)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
@@ -110,9 +110,9 @@ namespace Yi.Framework.Service.Base.Crud
|
|||||||
/// <param name="idEntity"></param>
|
/// <param name="idEntity"></param>
|
||||||
/// <param name="dto"></param>
|
/// <param name="dto"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected virtual async Task UpdateValidAsync(TEntity idEntity, TUpdateInput dto)
|
protected virtual Task UpdateValidAsync(TEntity idEntity, TUpdateInput dto)
|
||||||
{
|
{
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Microsoft.AspNetCore.Builder;
|
using AutoMapper;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -15,8 +16,11 @@ namespace Yi.Framework.WebCore.AspNetCoreExtensions
|
|||||||
public static IServiceCollection AddAutoMapperService(this IServiceCollection services)
|
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;
|
return services;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user