Compare commits
2
Commits
31a75d3bca
...
27cad42d45
No files matched your search
@@ -905,6 +905,8 @@ public sealed partial class ApprovalsController(
|
||||
if (overdueHours is < 1 or > 8760)
|
||||
return ValidationProblem("等待时长必须在 1 到 8760 小时之间。");
|
||||
|
||||
var timelinessEnabled = await db.SystemFeatureSettings.AsNoTracking().AnyAsync(x => x.Key == "ApprovalTimeliness" && x.IsEnabled, ct);
|
||||
if (timelinessEnabled) oldestFirst = true;
|
||||
var cutoff = overdueHours.HasValue ? DateTime.UtcNow.AddHours(-overdueHours.Value) : (DateTime?)null;
|
||||
var take = checked(page * pageSize);
|
||||
var total = 0;
|
||||
@@ -1201,7 +1203,14 @@ public sealed partial class ApprovalsController(
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToArray();
|
||||
return Ok(new ApprovalPendingResult(pageItems, total, page, pageSize, counts));
|
||||
if (timelinessEnabled && pageItems.Length > 0)
|
||||
{
|
||||
var holidays = await db.AcademicCalendarEvents.AsNoTracking()
|
||||
.Where(x => x.IsEnabled && x.Source == AcademicCalendarEventSource.HolidayCn && x.IsOffDay != null)
|
||||
.ToListAsync(ct);
|
||||
pageItems = pageItems.Select(x => x with { DeadlineUtc = ApprovalTimeliness.DeadlineUtc(x.Time, holidays) }).ToArray();
|
||||
}
|
||||
return Ok(new ApprovalPendingResult(pageItems, total, page, pageSize, counts, timelinessEnabled));
|
||||
}
|
||||
|
||||
[HttpGet("pending/{type}/{id:guid}")]
|
||||
@@ -2004,7 +2013,7 @@ public sealed partial class ApprovalsController(
|
||||
ApprovalsErrorKeys.TryGetValue(detail, out var key) ? SharedResourceText.Get(localizer, key) : detail;
|
||||
}
|
||||
|
||||
public sealed record ApprovalItem(Guid Id, string Type, string Label, string Title, string Desc, DateTime Time, string College, string? Stage = null, Guid? SecondaryId = null);
|
||||
public sealed record ApprovalItem(Guid Id, string Type, string Label, string Title, string Desc, DateTime Time, string College, string? Stage = null, Guid? SecondaryId = null, DateTime? DeadlineUtc = null);
|
||||
public sealed class ApprovalReviewedItem
|
||||
{
|
||||
public Guid Id { get; init; }
|
||||
@@ -2015,7 +2024,7 @@ public sealed class ApprovalReviewedItem
|
||||
public bool? Approved { get; init; }
|
||||
}
|
||||
public sealed record ApprovalReviewedResult(IReadOnlyList<ApprovalReviewedItem> Items, int Total);
|
||||
public sealed record ApprovalPendingResult(IReadOnlyCollection<ApprovalItem> Items, int Total, int Page, int PageSize, IReadOnlyDictionary<string, int> Counts);
|
||||
public sealed record ApprovalPendingResult(IReadOnlyCollection<ApprovalItem> Items, int Total, int Page, int PageSize, IReadOnlyDictionary<string, int> Counts, bool TimelinessEnabled = false);
|
||||
public sealed record ApprovalRouteSettingRequest([Required] string ReviewerRole);
|
||||
public sealed record ApprovalProgressStep(string Kind, DateTime Time, string? Comment);
|
||||
public sealed record ApprovalProgressResponse(string Type, Guid Id, IReadOnlyList<ApprovalProgressStep> Steps, bool HistoryIncomplete = false);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Jiaowu.Api.Domain.Identity;
|
||||
using Jiaowu.Api.Domain.System;
|
||||
using Jiaowu.Api.Infrastructure.Configuration;
|
||||
using Jiaowu.Api.Infrastructure.Persistence;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
@@ -12,6 +13,23 @@ namespace Jiaowu.Api.Controllers;
|
||||
[Route("api/business-settings")]
|
||||
public sealed class BusinessSettingsController(AppDbContext db, BusinessSettingsReader reader) : ControllerBase
|
||||
{
|
||||
[HttpGet("approval-timeliness")]
|
||||
[Authorize(Roles = SystemRoles.SuperAdmin)]
|
||||
public async Task<IActionResult> GetApprovalTimeliness(CancellationToken ct) =>
|
||||
Ok(new { enabled = await db.SystemFeatureSettings.AsNoTracking().AnyAsync(x => x.Key == "ApprovalTimeliness" && x.IsEnabled, ct) });
|
||||
|
||||
[HttpPut("approval-timeliness")]
|
||||
[Authorize(Roles = SystemRoles.SuperAdmin)]
|
||||
public async Task<IActionResult> PutApprovalTimeliness(ApprovalTimelinessRequest request, CancellationToken ct)
|
||||
{
|
||||
var setting = await db.SystemFeatureSettings.SingleOrDefaultAsync(x => x.Key == "ApprovalTimeliness", ct);
|
||||
if (setting is null) { setting = new SystemFeatureSetting { Key = "ApprovalTimeliness" }; db.SystemFeatureSettings.Add(setting); }
|
||||
setting.IsEnabled = request.Enabled;
|
||||
setting.UpdatedAt = DateTime.UtcNow;
|
||||
await db.SaveChangesAsync(ct);
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
[HttpGet("branding")]
|
||||
[AllowAnonymous]
|
||||
public IActionResult Branding() => Ok(reader.Brand());
|
||||
@@ -59,3 +77,5 @@ public sealed record BusinessSettingsRequest(
|
||||
[Required, StringLength(100)] string IssuingOffice,
|
||||
[Required, StringLength(32)] string DocumentNumberPrefix,
|
||||
[Range(1, 180)] int GradeAppealWindowDays);
|
||||
|
||||
public sealed record ApprovalTimelinessRequest(bool Enabled);
|
||||
@@ -3,7 +3,7 @@ using Jiaowu.Api.Domain.Common;
|
||||
namespace Jiaowu.Api.Domain.Academic;
|
||||
|
||||
/// <summary>
|
||||
/// 校历中的独立日程。它仅用于展示和提醒,不参与任何业务流程的状态判断或截止限制。
|
||||
/// 校历中的独立日程。同步的节假日用于审批时限提示,其余日程用于展示和提醒。
|
||||
/// </summary>
|
||||
public sealed class AcademicCalendarEvent : EntityBase
|
||||
{
|
||||
|
||||
Loaded 3 of 8 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user