Merge branch 'master' into codex/shiyan
This commit is contained in:
commit
8880c4127e
17 files changed
+6997
-45
No files matched your search
@@ -79,6 +79,38 @@ public sealed class OperationsController(
|
||||
CancellationToken cancellationToken) =>
|
||||
Ok(await healthService.CheckAsync(cancellationToken));
|
||||
|
||||
[HttpGet("swagger")]
|
||||
public async Task<ActionResult<SwaggerDocumentationSettings>> GetSwaggerSettings(
|
||||
CancellationToken cancellationToken) =>
|
||||
Ok(new SwaggerDocumentationSettings(await IsSwaggerEnabledAsync(cancellationToken)));
|
||||
|
||||
[HttpPut("swagger")]
|
||||
public async Task<ActionResult<SwaggerDocumentationSettings>> UpdateSwaggerSettings(
|
||||
UpdateSwaggerDocumentationSettings request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var setting = await db.SystemFeatureSettings.SingleOrDefaultAsync(
|
||||
x => x.Key == SystemFeatureKeys.SwaggerDocumentation,
|
||||
cancellationToken);
|
||||
if (setting is null)
|
||||
{
|
||||
setting = new SystemFeatureSetting
|
||||
{
|
||||
Key = SystemFeatureKeys.SwaggerDocumentation,
|
||||
IsEnabled = request.IsEnabled
|
||||
};
|
||||
db.SystemFeatureSettings.Add(setting);
|
||||
}
|
||||
else
|
||||
{
|
||||
setting.IsEnabled = request.IsEnabled;
|
||||
setting.UpdatedAt = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
await db.SaveChangesAsync(cancellationToken);
|
||||
return Ok(new SwaggerDocumentationSettings(setting.IsEnabled));
|
||||
}
|
||||
|
||||
[HttpGet("audit-logs")]
|
||||
public async Task<ActionResult<PagedResult<AuditLogItem>>> GetAuditLogs(
|
||||
[FromQuery] int page = 1,
|
||||
@@ -519,9 +551,15 @@ public sealed class OperationsController(
|
||||
cancellationToken) +
|
||||
await db.ExamPublishJobs.AsNoTracking()
|
||||
.CountAsync(
|
||||
x => x.Status == ExamPublishJobStatus.Failed &&
|
||||
x.CreatedAt >= from,
|
||||
cancellationToken);
|
||||
x => x.Status == ExamPublishJobStatus.Failed &&
|
||||
x.CreatedAt >= from,
|
||||
cancellationToken);
|
||||
|
||||
private async Task<bool> IsSwaggerEnabledAsync(CancellationToken cancellationToken) =>
|
||||
await db.SystemFeatureSettings.AsNoTracking()
|
||||
.Where(x => x.Key == SystemFeatureKeys.SwaggerDocumentation)
|
||||
.Select(x => (bool?)x.IsEnabled)
|
||||
.SingleOrDefaultAsync(cancellationToken) ?? false;
|
||||
|
||||
private ActionResult? ValidatePaging(int page, int pageSize)
|
||||
{
|
||||
@@ -604,3 +642,7 @@ public sealed record OperationsSummary(
|
||||
public sealed record CreateBackupRequest([MaxLength(200)] string? Note);
|
||||
|
||||
public sealed record RestoreDrillRequest([Required] string Confirmation);
|
||||
|
||||
public sealed record SwaggerDocumentationSettings(bool IsEnabled);
|
||||
|
||||
public sealed record UpdateSwaggerDocumentationSettings(bool IsEnabled);
|
||||
@@ -0,0 +1,14 @@
|
||||
using Jiaowu.Api.Domain.Common;
|
||||
|
||||
namespace Jiaowu.Api.Domain.System;
|
||||
|
||||
public static class SystemFeatureKeys
|
||||
{
|
||||
public const string SwaggerDocumentation = "SwaggerDocumentation";
|
||||
}
|
||||
|
||||
public sealed class SystemFeatureSetting : EntityBase
|
||||
{
|
||||
public required string Key { get; set; }
|
||||
public bool IsEnabled { get; set; }
|
||||
}
|
||||
@@ -137,6 +137,8 @@ public sealed class AppDbContext(DbContextOptions<AppDbContext> options)
|
||||
Set<BackgroundJobOutboxMessage>();
|
||||
public DbSet<AppUpdateRelease> AppUpdateReleases =>
|
||||
Set<AppUpdateRelease>();
|
||||
public DbSet<SystemFeatureSetting> SystemFeatureSettings =>
|
||||
Set<SystemFeatureSetting>();
|
||||
public DbSet<RefreshSession> RefreshSessions => Set<RefreshSession>();
|
||||
|
||||
protected override void ConfigureConventions(
|
||||
@@ -1455,6 +1457,12 @@ public sealed class AppDbContext(DbContextOptions<AppDbContext> options)
|
||||
entity.HasIndex(x => x.CreatedAt);
|
||||
});
|
||||
|
||||
builder.Entity<SystemFeatureSetting>(entity =>
|
||||
{
|
||||
entity.Property(x => x.Key).HasMaxLength(100);
|
||||
entity.HasIndex(x => x.Key).IsUnique();
|
||||
});
|
||||
|
||||
builder.Entity<OfficialDocument>(entity =>
|
||||
{
|
||||
entity.Property(x => x.DocumentNumber).HasMaxLength(50);
|
||||
|
||||
Loaded 3 of 17 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user