package com.nanri.aiimage.config; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; /** * 任务异常证据件配置(v1.2 Phase 3/AC-13)。 * *
证据件落在**独立桶**:默认桶 nanri-ai-images 带 7 天整桶 ILM, * 与"证据单独保留、单独回收"的口径互相绑死;桶名必须显式写在 application.yml, * 不许只在代码里留默认值(部署漏配就变成隐形行为)。
*/ @Data @ConfigurationProperties(prefix = "aiimage.evidence") public class EvidenceProperties { /** 证据桶;默认 task-evidence,独立于业务桶。 */ private String bucket = "task-evidence"; /** 证据保留天数(本地与云端同口径,按天回收)。 */ private Integer retentionDays = 7; /** 对象 key 前缀;实际 key = 前缀 + taskId + "/" + UUID + 扩展名。 */ private String keyPrefix = "task-evidence/"; /** 单件证据上限(字节),超过直接拒绝,避免截图/大 JSON 打满桶。 */ private Long maxFileBytes = 64L * 1024 * 1024; /** 保留期回收 cron;默认每天 03:30。 */ private String retentionCron = "0 30 3 * * *"; public String bucketOrDefault() { return bucket == null || bucket.isBlank() ? "task-evidence" : bucket.trim(); } public int retentionDaysOrDefault() { return retentionDays == null || retentionDays < 1 ? 7 : retentionDays; } public String keyPrefixOrDefault() { String prefix = keyPrefix == null ? "" : keyPrefix.trim(); if (prefix.isEmpty()) { return "task-evidence/"; } return prefix.endsWith("/") ? prefix : prefix + "/"; } public long maxFileBytesOrDefault() { return maxFileBytes == null || maxFileBytes < 1 ? 64L * 1024 * 1024 : maxFileBytes; } }