mirror of
https://github.com/nsnail/NetAdmin.git
synced 2025-06-17 01:13:22 +08:00
refactor: ♻️ 框架代码同步
This commit is contained in:
parent
7c47c09838
commit
e5e1d6f50f
@ -2,6 +2,7 @@ using CsvHelper;
|
|||||||
using Microsoft.Net.Http.Headers;
|
using Microsoft.Net.Http.Headers;
|
||||||
using NetAdmin.Application.Repositories;
|
using NetAdmin.Application.Repositories;
|
||||||
using NetAdmin.Domain;
|
using NetAdmin.Domain;
|
||||||
|
using NetAdmin.Domain.Contexts;
|
||||||
using NetAdmin.Domain.DbMaps.Dependency;
|
using NetAdmin.Domain.DbMaps.Dependency;
|
||||||
using NetAdmin.Domain.DbMaps.Dependency.Fields;
|
using NetAdmin.Domain.DbMaps.Dependency.Fields;
|
||||||
using NetAdmin.Domain.Dto.Dependency;
|
using NetAdmin.Domain.Dto.Dependency;
|
||||||
@ -53,9 +54,7 @@ public abstract class RepositoryService<TEntity, TPrimary, TLogger>(BasicReposit
|
|||||||
{
|
{
|
||||||
var select = selector(query).WithNoLockNoWait().Take(Numbers.MAX_LIMIT_EXPORT);
|
var select = selector(query).WithNoLockNoWait().Take(Numbers.MAX_LIMIT_EXPORT);
|
||||||
|
|
||||||
object list = listExp == null
|
object list = listExp == null ? await select.ToListAsync().ConfigureAwait(false) : await select.ToListAsync(listExp).ConfigureAwait(false);
|
||||||
? await select.ToListAsync().ConfigureAwait(false)
|
|
||||||
: await select.ToListAsync(listExp).ConfigureAwait(false);
|
|
||||||
|
|
||||||
return await GetExportFileStreamAsync<TExport>(fileName, list).ConfigureAwait(false);
|
return await GetExportFileStreamAsync<TExport>(fileName, list).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@ -135,6 +134,25 @@ public abstract class RepositoryService<TEntity, TPrimary, TLogger>(BasicReposit
|
|||||||
return new FileStreamResult(stream, Chars.FLG_HTTP_HEADER_VALUE_APPLICATION_OCTET_STREAM);
|
return new FileStreamResult(stream, Chars.FLG_HTTP_HEADER_VALUE_APPLICATION_OCTET_STREAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Dictionary<string, object> IncludeToDictionary(TEntity entity, List<string> includeFields)
|
||||||
|
{
|
||||||
|
var ret = includeFields!.ToDictionary(
|
||||||
|
x => x, x => typeof(TEntity).GetProperty(x, BindingFlags.Public | BindingFlags.Instance)!.GetValue(entity));
|
||||||
|
if (entity is not IFieldModifiedUser) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
var userInfo = App.GetService<ContextUserInfo>();
|
||||||
|
if (userInfo == null) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret.Add(nameof(IFieldModifiedUser.ModifiedUserId), userInfo.Id);
|
||||||
|
ret.Add(nameof(IFieldModifiedUser.ModifiedUserName), userInfo.UserName);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
private IUpdate<TEntity> BuildUpdate(TEntity entity, List<string> includeFields, List<string> excludeFields, bool ignoreVersion)
|
private IUpdate<TEntity> BuildUpdate(TEntity entity, List<string> includeFields, List<string> excludeFields, bool ignoreVersion)
|
||||||
{
|
{
|
||||||
IUpdate<TEntity> updateExp;
|
IUpdate<TEntity> updateExp;
|
||||||
@ -145,9 +163,7 @@ public abstract class RepositoryService<TEntity, TPrimary, TLogger>(BasicReposit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
updateExp = Rpo.UpdateDiy.SetDto(includeFields!.ToDictionary(
|
updateExp = Rpo.UpdateDiy.SetDto(IncludeToDictionary(entity, includeFields));
|
||||||
x => x
|
|
||||||
, x => typeof(TEntity).GetProperty(x, BindingFlags.Public | BindingFlags.Instance)!.GetValue(entity)));
|
|
||||||
if (!ignoreVersion && entity is IFieldVersion ver) {
|
if (!ignoreVersion && entity is IFieldVersion ver) {
|
||||||
updateExp = updateExp.Where($"{nameof(IFieldVersion.Version)} = {ver.Version}");
|
updateExp = updateExp.Where($"{nameof(IFieldVersion.Version)} = {ver.Version}");
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public abstract record MutableEntity<T> : LiteMutableEntity<T>, IFieldCreatedUse
|
|||||||
[Column(CanInsert = false, Position = -1)]
|
[Column(CanInsert = false, Position = -1)]
|
||||||
[CsvIgnore]
|
[CsvIgnore]
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public long? ModifiedUserId { get; init; }
|
public virtual long? ModifiedUserId { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 修改者用户名
|
/// 修改者用户名
|
||||||
@ -55,5 +55,5 @@ public abstract record MutableEntity<T> : LiteMutableEntity<T>, IFieldCreatedUse
|
|||||||
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_31, CanInsert = false, Position = -1)]
|
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_31, CanInsert = false, Position = -1)]
|
||||||
[CsvIgnore]
|
[CsvIgnore]
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public string ModifiedUserName { get; init; }
|
public virtual string ModifiedUserName { get; init; }
|
||||||
}
|
}
|
@ -27,9 +27,11 @@ public sealed class SafetyShopHostMiddleware(RequestDelegate next)
|
|||||||
public static void OnStopping()
|
public static void OnStopping()
|
||||||
{
|
{
|
||||||
Stop();
|
Stop();
|
||||||
|
#if !DEBUG
|
||||||
while (Interlocked.Read(ref _connections) > 0) {
|
while (Interlocked.Read(ref _connections) > 0) {
|
||||||
Thread.Sleep(10);
|
Thread.Sleep(10);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
<Import Project="$(SolutionDir)/build/copy.pkg.xml.comment.files.targets"/>
|
<Import Project="$(SolutionDir)/build/copy.pkg.xml.comment.files.targets"/>
|
||||||
<Import Project="$(SolutionDir)/build/prebuild.targets"/>
|
<Import Project="$(SolutionDir)/build/prebuild.targets"/>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="NetAdmin.FreeSql.DbContext" Version="1.0.3" Label="refs"/>
|
<PackageReference Include="NetAdmin.FreeSql.DbContext" Version="1.0.6" Label="refs"/>
|
||||||
<PackageReference Include="NetAdmin.FreeSql.Provider.Sqlite" Version="1.0.3" Label="refs"/>
|
<PackageReference Include="NetAdmin.FreeSql.Provider.Sqlite" Version="1.0.6" Label="refs"/>
|
||||||
<PackageReference Include="Gurion" Version="1.2.5" Label="refs"/>
|
<PackageReference Include="Gurion" Version="1.2.5" Label="refs"/>
|
||||||
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="9.0.0"/>
|
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="9.0.0"/>
|
||||||
<PackageReference Include="Minio" Version="6.0.3"/>
|
<PackageReference Include="Minio" Version="6.0.3"/>
|
||||||
|
@ -60,7 +60,7 @@ export default {
|
|||||||
.sc-statistic-title {
|
.sc-statistic-title {
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
color: var(--el-color-info);
|
color: var(--el-color-info);
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 0.5rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,6 @@
|
|||||||
}
|
}
|
||||||
}) ?? []),
|
}) ?? []),
|
||||||
],
|
],
|
||||||
w100p: true,
|
|
||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
:label-width="10"
|
:label-width="10"
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
}
|
}
|
||||||
}) ?? []),
|
}) ?? []),
|
||||||
],
|
],
|
||||||
w100p: true,
|
|
||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
:label-width="9"
|
:label-width="9"
|
||||||
|
@ -35,7 +35,6 @@
|
|||||||
}
|
}
|
||||||
}) ?? []),
|
}) ?? []),
|
||||||
],
|
],
|
||||||
w100p: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: $t('登录用户名'),
|
title: $t('登录用户名'),
|
||||||
@ -50,7 +49,6 @@
|
|||||||
}
|
}
|
||||||
}) ?? []),
|
}) ?? []),
|
||||||
],
|
],
|
||||||
w100p: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: $t('客户端IP地址'),
|
title: $t('客户端IP地址'),
|
||||||
@ -65,7 +63,6 @@
|
|||||||
}
|
}
|
||||||
}) ?? []),
|
}) ?? []),
|
||||||
],
|
],
|
||||||
w100p: true,
|
|
||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
:label-width="10"
|
:label-width="10"
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
}
|
}
|
||||||
}) ?? []),
|
}) ?? []),
|
||||||
],
|
],
|
||||||
w100p: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: $t('请求服务'),
|
title: $t('请求服务'),
|
||||||
@ -51,7 +50,6 @@
|
|||||||
}
|
}
|
||||||
}) ?? []),
|
}) ?? []),
|
||||||
],
|
],
|
||||||
w100p: true,
|
|
||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
:label-width="10"
|
:label-width="10"
|
||||||
|
@ -68,7 +68,6 @@
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
w100p: true,
|
|
||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
:label-width="15"
|
:label-width="15"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user