package com.xly.web; import com.xly.service.FormResolverService; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.List; /** * FormCollect 的**下拉选项来源**端点:外键字段(客户/产品/物料…)的选项从对应表实时取。 * *

前端渲染 {@code type=fkselect} 字段时调 {@code GET /api/agent/form/options?table=elecustomer&q=..} * 拿候选名称填进下拉。安全:{@link FormResolverService#fkOptions} 只允许「在字段字典里作为外键目标出现过」的表, * 并按名称字段模糊匹配 + 租户过滤 + LIMIT,避免任意读表。 */ @RestController @RequestMapping("/api/agent/form") public class FormController { private final FormResolverService resolver; public FormController(FormResolverService resolver) { this.resolver = resolver; } @GetMapping("/options") public List options(@RequestParam("table") String table, @RequestParam(value = "q", required = false) String q, @RequestParam(value = "brandsid", required = false) String brandsid) { return resolver.fkOptions(table, brandsid, q); } }