package com.example.rzgb.research; import com.example.rzgb.common.ApiException; import jakarta.validation.constraints.*; import java.util.*; /** * D3 结构化参数。选择值只是候选 ID,必须再次与任务保存的候选核对, * 不能相信浏览器直接提交的“已确认”布尔值或任意企业全称。 */ public record ResearchRequest(@Size(max=2) List<@NotBlank @Size(max=128) String> companies, @Size(max=5) Map<@Size(max=32) String, @Size(max=128) String> selections, Mode mode, @Size(max=36) String fileId, @Size(max=36) String parentId, @Size(max=64) String targetProjectId, @Size(max=32) String focus, @Min(0) @Max(25) int acknowledgedCalls) { public enum Mode { QUICK, FULL } public ResearchRequest { companies = companies == null ? List.of() : List.copyOf(companies); selections = selections == null ? Map.of() : Map.copyOf(selections); mode = mode == null ? Mode.QUICK : mode; } public void validate(boolean company) { if (company && (companies.isEmpty() || fileId != null)) throw new ApiException(400,"INVALID_RESEARCH","企业调研需填写一家或两家企业;文件仅用于投标项目"); if (focus != null && !Set.of("customer","profile","partners","performance","competitors","public").contains(focus)) throw new ApiException(400,"INVALID_FOCUS","调研范围仅支持目标客户、画像、伙伴、业绩、竞对或公开资料"); } }