fix: 🐛 时区问题 (#107)

[skip ci]
This commit is contained in:
2024-04-26 10:55:36 +08:00
committed by GitHub
parent d83cab1c3e
commit 59c85cef21
9 changed files with 20 additions and 15 deletions

View File

@ -112,7 +112,7 @@ public sealed class JobService(DefaultRepository<Sys_Job> rpo, IJobRecordService
Filters = [
new DynamicFilterInfo {
Field = nameof(QueryJobReq.NextExecTime)
, Value = DateTime.UtcNow
, Value = DateTime.Now
, Operator = DynamicFilterOperators.LessThan
}
, new DynamicFilterInfo {
@ -139,7 +139,7 @@ public sealed class JobService(DefaultRepository<Sys_Job> rpo, IJobRecordService
? null
: await UpdateAsync(job.Adapt<UpdateJobReq>() with {
Status = JobStatues.Running
, LastExecTime = DateTime.UtcNow
, LastExecTime = DateTime.Now
})
.ConfigureAwait(false);
}
@ -239,7 +239,8 @@ public sealed class JobService(DefaultRepository<Sys_Job> rpo, IJobRecordService
private static DateTime? GetNextExecTime(string cron)
{
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)

View File

@ -32,7 +32,7 @@ public sealed class ToolsService : ServiceBase<IToolsService>, IToolsService
/// <inheritdoc />
public Task<DateTime> GetServerUtcTimeAsync()
{
return Task.FromResult(DateTime.UtcNow);
return Task.FromResult(DateTime.Now);
}
/// <inheritdoc />

View File

@ -107,7 +107,7 @@ public sealed class VerifyCodeService(DefaultRepository<Sys_VerifyCode> rpo, IEv
#if !DEBUG
// 有发送记录且小于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次);
}
#endif
@ -152,7 +152,7 @@ public sealed class VerifyCodeService(DefaultRepository<Sys_VerifyCode> rpo, IEv
var lastSent = await GetLastSentAsync(req.DestDevice).ConfigureAwait(false);
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;
}
@ -188,8 +188,11 @@ public sealed class VerifyCodeService(DefaultRepository<Sys_VerifyCode> rpo, IEv
private ISelect<Sys_VerifyCode> QueryInternal(QueryReq<QueryVerifyCodeReq> req)
{
var ret = Rpo.Select.WhereDynamicFilter(req.DynamicFilter).WhereDynamic(req.Filter);
if (req.Order == Orders.Random) {
return ret.OrderByRandom();
switch (req.Order) {
case Orders.None:
return ret;
case Orders.Random:
return ret.OrderByRandom();
}
ret = ret.OrderByPropertyNameIf(req.Prop?.Length > 0, req.Prop, req.Order == Orders.Ascending);