package com.baiyue.audit.dto; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.PositiveOrZero; import jakarta.validation.constraints.Size; import java.time.Instant; /** * 内部审计写入请求契约,承载操作对象、租户与用户、请求链路、执行结果及脱敏快照。 */ @Schema(name = "AuditIngestRequest", description = "Internal business audit event / 内部业务审计事件") public record AuditIngestRequest( @Schema(description = "Global idempotency event ID / 全局幂等事件ID", example = "b150c69d-8813-46b7-9a7c-81bfa5b91021") @Size(max = 64) String eventId, @Schema(description = "Event code / 事件编码", example = "WAREHOUSE_UPDATE", requiredMode = Schema.RequiredMode.REQUIRED) @NotBlank @Size(max = 64) String eventType, @Schema(description = "Resource type / 资源类型", example = "WAREHOUSE", requiredMode = Schema.RequiredMode.REQUIRED) @NotBlank @Size(max = 64) String resourceType, @Schema(description = "Resource identifier / 资源标识", example = "190000000000000001") @Size(max = 128) String resourceId, @Schema(description = "Bilingual event description / 中英文事件描述", example = "Update warehouse / 更新仓库") @Size(max = 255) String description, @Schema(description = "Request ID / 请求 ID", example = "req-20260728-001") @Size(max = 128) String requestId, @Schema(description = "Distributed trace ID / 分布式链路 ID", example = "trace-20260728-001") @Size(max = 128) String traceId, @Schema(description = "Business data tenant ID / 业务数据租户 ID", example = "10001") Long tenantId, @Schema(description = "Operator tenant ID / 操作人所属租户 ID", example = "0") Long operatorTenantId, @Schema(description = "Operator user ID / 操作人用户 ID", example = "90001") Long userId, @Schema(description = "Operator username / 操作人用户名", example = "platform.admin") @Size(max = 128) String username, @Schema(description = "Application scope / 应用权限域", example = "PLATFORM") @Size(max = 64) String appCode, @Schema(description = "Client type / 客户端类型", example = "WEB") @Size(max = 32) String clientType, @Schema(description = "HTTP method / HTTP 方法", example = "PUT") @Size(max = 16) String httpMethod, @Schema(description = "Request URI / 请求 URI", example = "/api/platform/v1/warehouse-admin/190000000000000001") @Size(max = 512) String requestUri, @Schema(description = "Client IP / 客户端 IP", example = "10.0.0.10") @Size(max = 64) String clientIp, @Schema(description = "Request duration in milliseconds / 请求耗时(毫秒)", example = "35") @PositiveOrZero long durationMs, @Schema(description = "Whether the business operation succeeded / 业务操作是否成功", example = "true") boolean success, @Schema(description = "Error code when failed / 失败时错误码", example = "WAREHOUSE_NOT_FOUND") @Size(max = 64) String errorCode, @Schema(description = "Sanitized error message / 脱敏后的错误信息", example = "Warehouse not found / 仓库不存在") @Size(max = 512) String errorMessage, @Schema(description = "Sanitized JSON snapshot before change / 变更前脱敏 JSON 快照", example = "{\"status\":\"INACTIVE\"}") String beforeData, @Schema(description = "Sanitized JSON snapshot after change / 变更后脱敏 JSON 快照", example = "{\"status\":\"ACTIVE\"}") String afterData, @Schema(description = "Event occurrence time in UTC / 事件发生时间(UTC)", example = "2026-07-28T07:30:00Z", requiredMode = Schema.RequiredMode.REQUIRED) @NotNull Instant occurredAt, @Schema(description = "Source service name / 来源服务名称", example = "warehouse-service") @Size(max = 64) String serviceName ) { }