feat: strengthen P0 security and operations

This commit is contained in:
2026-08-01 11:20:02 +08:00
parent f776056834
commit 84c2b0b21d
77 changed files with 24185 additions and 355 deletions

View File

@@ -3,23 +3,34 @@ using Tiku.Domain.Operations;
namespace Tiku.Application.Jobs;
public sealed class BackgroundJobException(string code, string message) : Exception(message)
{
public string Code { get; } = code;
}
public sealed record CreateBackgroundJobCommand(
Guid TenantId,
string JobType,
JsonElement Payload,
DateTimeOffset? RunAfter = null,
int MaxRetries = 3);
int MaxRetries = 3,
string? IdempotencyKey = null,
bool IsSystemJob = false);
public sealed record BackgroundJobItem(
Guid Id,
Guid TenantId,
string JobType,
string? IdempotencyKey,
BackgroundJobStatus Status,
int RetryCount,
int MaxRetries,
DateTimeOffset? RunAfter,
DateTimeOffset? StartedAt,
DateTimeOffset? CompletedAt,
DateTimeOffset? CancellationRequestedAt,
Guid? CancellationRequestedBy,
string? CancellationReason,
string? LastError,
Guid? OutputAssetId,
JsonElement Result);
@@ -48,4 +59,29 @@ public interface IBackgroundJobService
string? jobType = null,
int limit = 50,
CancellationToken cancellationToken = default);
Task<BackgroundJobItem?> GetAsync(
Guid jobId,
Guid? tenantId,
CancellationToken cancellationToken = default);
Task<IReadOnlyCollection<BackgroundJobItem>> ListPlatformAsync(
Guid? tenantId = null,
string? jobType = null,
BackgroundJobStatus? status = null,
int limit = 100,
CancellationToken cancellationToken = default);
Task<BackgroundJobItem> RequestCancellationAsync(
Guid jobId,
Guid? tenantId,
Guid actorUserId,
string reason,
CancellationToken cancellationToken = default);
Task<BackgroundJobItem> RetryAsync(
Guid jobId,
Guid? tenantId,
Guid actorUserId,
CancellationToken cancellationToken = default);
}