mirror of
https://github.com/nsnail/NetAdmin.git
synced 2025-04-23 14:42:51 +08:00
parent
d83cab1c3e
commit
59c85cef21
@ -8,9 +8,9 @@
|
|||||||
"Description": "NetAdmin - 系统组件",
|
"Description": "NetAdmin - 系统组件",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Group": "Biz",
|
"Group": "Adm",
|
||||||
"Title": "业务服务",
|
"Title": "管理服务",
|
||||||
"Description": "NetAdmin - 业务服务",
|
"Description": "NetAdmin - 管理服务",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Group": "Tpl",
|
"Group": "Tpl",
|
||||||
|
@ -19,7 +19,7 @@ public abstract record LiteImmutableEntity : LiteImmutableEntity<long>
|
|||||||
public abstract record LiteImmutableEntity<T> : EntityBase, IFieldPrimary<T>, IFieldCreatedTime
|
public abstract record LiteImmutableEntity<T> : EntityBase, IFieldPrimary<T>, IFieldCreatedTime
|
||||||
{
|
{
|
||||||
/// <inheritdoc cref="IFieldCreatedTime.CreatedTime" />
|
/// <inheritdoc cref="IFieldCreatedTime.CreatedTime" />
|
||||||
[Column(ServerTime = DateTimeKind.Utc, CanUpdate = false, Position = -1)]
|
[Column(ServerTime = DateTimeKind.Local, CanUpdate = false, Position = -1)]
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public virtual DateTime CreatedTime { get; init; }
|
public virtual DateTime CreatedTime { get; init; }
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ public abstract record LiteMutableEntity<T> : LiteImmutableEntity<T>, IFieldModi
|
|||||||
public override T Id { get; init; }
|
public override T Id { get; init; }
|
||||||
|
|
||||||
/// <inheritdoc cref="IFieldModifiedTime.ModifiedTime" />
|
/// <inheritdoc cref="IFieldModifiedTime.ModifiedTime" />
|
||||||
[Column(ServerTime = DateTimeKind.Utc, CanInsert = false, Position = -1)]
|
[Column(ServerTime = DateTimeKind.Local, CanInsert = false, Position = -1)]
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public virtual DateTime? ModifiedTime { get; init; }
|
public virtual DateTime? ModifiedTime { get; init; }
|
||||||
}
|
}
|
@ -6,6 +6,7 @@ using NetAdmin.Host.Utils;
|
|||||||
using StackExchange.Redis;
|
using StackExchange.Redis;
|
||||||
using Yitter.IdGenerator;
|
using Yitter.IdGenerator;
|
||||||
using FreeSqlBuilder = NetAdmin.Infrastructure.Utils.FreeSqlBuilder;
|
using FreeSqlBuilder = NetAdmin.Infrastructure.Utils.FreeSqlBuilder;
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
using Spectre.Console;
|
using Spectre.Console;
|
||||||
#endif
|
#endif
|
||||||
|
@ -25,7 +25,7 @@ public sealed class SqlAuditor : ISingleton
|
|||||||
public SqlAuditor(ILogger<SqlAuditor> logger)
|
public SqlAuditor(ILogger<SqlAuditor> logger)
|
||||||
{
|
{
|
||||||
// 设置服务器时间偏差
|
// 设置服务器时间偏差
|
||||||
_timeOffset = DateTime.UtcNow.Subtract(App.GetService<IFreeSql>().Ado.QuerySingle(() => DateTime.UtcNow));
|
_timeOffset = DateTime.Now.Subtract(App.GetService<IFreeSql>().Ado.QuerySingle(() => DateTime.Now));
|
||||||
|
|
||||||
logger.Info($"{Ln.数据库服务器时钟偏移} {_timeOffset}");
|
logger.Info($"{Ln.数据库服务器时钟偏移} {_timeOffset}");
|
||||||
}
|
}
|
||||||
|
@ -56,10 +56,10 @@
|
|||||||
"RoutePrefix": "swagger",
|
"RoutePrefix": "swagger",
|
||||||
"XmlComments": [
|
"XmlComments": [
|
||||||
"FreeSql.xml",
|
"FreeSql.xml",
|
||||||
"NetAdmin.Application.xml",
|
|
||||||
"NetAdmin.AdmServer.Application.xml",
|
"NetAdmin.AdmServer.Application.xml",
|
||||||
"NetAdmin.AdmServer.Cache.xml",
|
"NetAdmin.AdmServer.Cache.xml",
|
||||||
"NetAdmin.AdmServer.Host.xml",
|
"NetAdmin.AdmServer.Host.xml",
|
||||||
|
"NetAdmin.Application.xml",
|
||||||
"NetAdmin.Cache.xml",
|
"NetAdmin.Cache.xml",
|
||||||
"NetAdmin.Domain.xml",
|
"NetAdmin.Domain.xml",
|
||||||
"NetAdmin.Host.xml",
|
"NetAdmin.Host.xml",
|
||||||
|
@ -112,7 +112,7 @@ public sealed class JobService(DefaultRepository<Sys_Job> rpo, IJobRecordService
|
|||||||
Filters = [
|
Filters = [
|
||||||
new DynamicFilterInfo {
|
new DynamicFilterInfo {
|
||||||
Field = nameof(QueryJobReq.NextExecTime)
|
Field = nameof(QueryJobReq.NextExecTime)
|
||||||
, Value = DateTime.UtcNow
|
, Value = DateTime.Now
|
||||||
, Operator = DynamicFilterOperators.LessThan
|
, Operator = DynamicFilterOperators.LessThan
|
||||||
}
|
}
|
||||||
, new DynamicFilterInfo {
|
, new DynamicFilterInfo {
|
||||||
@ -139,7 +139,7 @@ public sealed class JobService(DefaultRepository<Sys_Job> rpo, IJobRecordService
|
|||||||
? null
|
? null
|
||||||
: await UpdateAsync(job.Adapt<UpdateJobReq>() with {
|
: await UpdateAsync(job.Adapt<UpdateJobReq>() with {
|
||||||
Status = JobStatues.Running
|
Status = JobStatues.Running
|
||||||
, LastExecTime = DateTime.UtcNow
|
, LastExecTime = DateTime.Now
|
||||||
})
|
})
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@ -239,7 +239,8 @@ public sealed class JobService(DefaultRepository<Sys_Job> rpo, IJobRecordService
|
|||||||
private static DateTime? GetNextExecTime(string cron)
|
private static DateTime? GetNextExecTime(string cron)
|
||||||
{
|
{
|
||||||
return CronExpression.Parse(cron, CronFormat.IncludeSeconds)
|
return CronExpression.Parse(cron, CronFormat.IncludeSeconds)
|
||||||
.GetNextOccurrence(DateTime.UtcNow, TimeZoneInfo.Utc);
|
.GetNextOccurrence(DateTime.UtcNow, TimeZoneInfo.Local)
|
||||||
|
?.ToLocalTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ISelect<Sys_Job> QueryInternal(QueryReq<QueryJobReq> req)
|
private ISelect<Sys_Job> QueryInternal(QueryReq<QueryJobReq> req)
|
||||||
|
@ -32,7 +32,7 @@ public sealed class ToolsService : ServiceBase<IToolsService>, IToolsService
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public Task<DateTime> GetServerUtcTimeAsync()
|
public Task<DateTime> GetServerUtcTimeAsync()
|
||||||
{
|
{
|
||||||
return Task.FromResult(DateTime.UtcNow);
|
return Task.FromResult(DateTime.Now);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
@ -107,7 +107,7 @@ public sealed class VerifyCodeService(DefaultRepository<Sys_VerifyCode> rpo, IEv
|
|||||||
|
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
// 有发送记录,且小于1分钟,不允许
|
// 有发送记录,且小于1分钟,不允许
|
||||||
if (lastSent != null && (DateTime.UtcNow - lastSent.CreatedTime).TotalMinutes < 1) {
|
if (lastSent != null && (DateTime.Now - lastSent.CreatedTime).TotalMinutes < 1) {
|
||||||
throw new NetAdminInvalidOperationException(Ln._1分钟内只能发送1次);
|
throw new NetAdminInvalidOperationException(Ln._1分钟内只能发送1次);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -152,7 +152,7 @@ public sealed class VerifyCodeService(DefaultRepository<Sys_VerifyCode> rpo, IEv
|
|||||||
var lastSent = await GetLastSentAsync(req.DestDevice).ConfigureAwait(false);
|
var lastSent = await GetLastSentAsync(req.DestDevice).ConfigureAwait(false);
|
||||||
|
|
||||||
if (lastSent is not { Status: VerifyCodeStatues.Sent } || req.Code != lastSent.Code ||
|
if (lastSent is not { Status: VerifyCodeStatues.Sent } || req.Code != lastSent.Code ||
|
||||||
(DateTime.UtcNow - lastSent.CreatedTime).TotalMinutes > 10) {
|
(DateTime.Now - lastSent.CreatedTime).TotalMinutes > 10) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +188,10 @@ public sealed class VerifyCodeService(DefaultRepository<Sys_VerifyCode> rpo, IEv
|
|||||||
private ISelect<Sys_VerifyCode> QueryInternal(QueryReq<QueryVerifyCodeReq> req)
|
private ISelect<Sys_VerifyCode> QueryInternal(QueryReq<QueryVerifyCodeReq> req)
|
||||||
{
|
{
|
||||||
var ret = Rpo.Select.WhereDynamicFilter(req.DynamicFilter).WhereDynamic(req.Filter);
|
var ret = Rpo.Select.WhereDynamicFilter(req.DynamicFilter).WhereDynamic(req.Filter);
|
||||||
if (req.Order == Orders.Random) {
|
switch (req.Order) {
|
||||||
|
case Orders.None:
|
||||||
|
return ret;
|
||||||
|
case Orders.Random:
|
||||||
return ret.OrderByRandom();
|
return ret.OrderByRandom();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user