更新nuget&&添加swagger
This commit is contained in:
1 parent
1229f3163d
commit
3c9863580b
16 files changed
+6964
-35
No files matched your search
@@ -79,6 +79,38 @@ public sealed class OperationsController(
|
|||||||
CancellationToken cancellationToken) =>
|
CancellationToken cancellationToken) =>
|
||||||
Ok(await healthService.CheckAsync(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")]
|
[HttpGet("audit-logs")]
|
||||||
public async Task<ActionResult<PagedResult<AuditLogItem>>> GetAuditLogs(
|
public async Task<ActionResult<PagedResult<AuditLogItem>>> GetAuditLogs(
|
||||||
[FromQuery] int page = 1,
|
[FromQuery] int page = 1,
|
||||||
@@ -523,6 +555,12 @@ public sealed class OperationsController(
|
|||||||
x.CreatedAt >= from,
|
x.CreatedAt >= from,
|
||||||
cancellationToken);
|
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)
|
private ActionResult? ValidatePaging(int page, int pageSize)
|
||||||
{
|
{
|
||||||
if (page is < 1 or > 100000 || pageSize is < 1 or > 100)
|
if (page is < 1 or > 100000 || pageSize is < 1 or > 100)
|
||||||
@@ -604,3 +642,7 @@ public sealed record OperationsSummary(
|
|||||||
public sealed record CreateBackupRequest([MaxLength(200)] string? Note);
|
public sealed record CreateBackupRequest([MaxLength(200)] string? Note);
|
||||||
|
|
||||||
public sealed record RestoreDrillRequest([Required] string Confirmation);
|
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>();
|
Set<BackgroundJobOutboxMessage>();
|
||||||
public DbSet<AppUpdateRelease> AppUpdateReleases =>
|
public DbSet<AppUpdateRelease> AppUpdateReleases =>
|
||||||
Set<AppUpdateRelease>();
|
Set<AppUpdateRelease>();
|
||||||
|
public DbSet<SystemFeatureSetting> SystemFeatureSettings =>
|
||||||
|
Set<SystemFeatureSetting>();
|
||||||
public DbSet<RefreshSession> RefreshSessions => Set<RefreshSession>();
|
public DbSet<RefreshSession> RefreshSessions => Set<RefreshSession>();
|
||||||
|
|
||||||
protected override void ConfigureConventions(
|
protected override void ConfigureConventions(
|
||||||
@@ -1451,6 +1453,12 @@ public sealed class AppDbContext(DbContextOptions<AppDbContext> options)
|
|||||||
entity.HasIndex(x => x.CreatedAt);
|
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 =>
|
builder.Entity<OfficialDocument>(entity =>
|
||||||
{
|
{
|
||||||
entity.Property(x => x.DocumentNumber).HasMaxLength(50);
|
entity.Property(x => x.DocumentNumber).HasMaxLength(50);
|
||||||
|
|||||||
Loaded 3 of 16 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user