Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac9fd706f9 | ||
|
|
8b4d551af8 | ||
|
|
3445531972 |
@@ -11,8 +11,8 @@ namespace SimApi.Configs
|
|||||||
public bool EnableSimApiStorage { get; set; } = false;
|
public bool EnableSimApiStorage { get; set; } = false;
|
||||||
public bool EnableForwardHeaders { get; set; } = true;
|
public bool EnableForwardHeaders { get; set; } = true;
|
||||||
public bool EnableLowerUrl { get; set; } = true;
|
public bool EnableLowerUrl { get; set; } = true;
|
||||||
public SimApiDocOptions SimApiDocOptions { get; set; } = new();
|
public SimApiDocOptions SimApiDocOptions { get; set; } = new SimApiDocOptions();
|
||||||
public SimApiStorageOptions SimApiStorageOptions { get; set; } = new();
|
public SimApiStorageOptions SimApiStorageOptions { get; set; } = new SimApiStorageOptions();
|
||||||
|
|
||||||
|
|
||||||
public void ConfigureSimApiDoc(Action<SimApiDocOptions> options = null)
|
public void ConfigureSimApiDoc(Action<SimApiDocOptions> options = null)
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ namespace SimApi.Helpers
|
|||||||
public class SimApiStorage
|
public class SimApiStorage
|
||||||
{
|
{
|
||||||
private MinioClient Mc { get; }
|
private MinioClient Mc { get; }
|
||||||
|
|
||||||
|
public MinioClient Client => Mc;
|
||||||
|
|
||||||
private string ServeUrl { get; }
|
private string ServeUrl { get; }
|
||||||
private string Bucket { get; }
|
private string Bucket { get; }
|
||||||
private IHttpContextAccessor HttpContextAccessor { get; }
|
private IHttpContextAccessor HttpContextAccessor { get; }
|
||||||
|
|||||||
@@ -33,6 +33,30 @@ namespace SimApi.Models
|
|||||||
UpdateTime();
|
UpdateTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void MapData<TS>(TS source, string[] mapFields)
|
||||||
|
{
|
||||||
|
//获取要赋值的源数据不为null的项目
|
||||||
|
var sourceProps = source.GetType().GetProperties().Where(x => x.GetValue(source) != null)
|
||||||
|
.Select(x => new {x.Name, x.PropertyType})
|
||||||
|
.ToDictionary(x => x.Name, x => x.PropertyType);
|
||||||
|
|
||||||
|
//获取目标对象的属性信息
|
||||||
|
var targetProps = GetType().GetProperties().Select(x => new {x.Name, x.PropertyType})
|
||||||
|
.ToDictionary(x => x.Name, x => x.PropertyType);
|
||||||
|
foreach (var sp in sourceProps)
|
||||||
|
{
|
||||||
|
//检查源对象不为空的属性是否在目标对象中存在
|
||||||
|
if (targetProps.ContainsKey(sp.Key) && sp.Value == targetProps[sp.Key] &&
|
||||||
|
mapFields.Contains(sp.Key))
|
||||||
|
{
|
||||||
|
GetType().GetProperty(sp.Key)?
|
||||||
|
.SetValue(this, source.GetType().GetProperty(sp.Key)?.GetValue(source));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateTime();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新update时间
|
/// 更新update时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user