feat: SDK 类型化门面接入(flow/cms 走服务目录)+ 教师组科室语义对齐 + F1-F3 存量

- FlowCenterClient/CmsSiteDirectoryImpl:服务目录命名目标(flowcenter/cms)优先,
  legacy svchall.flow/cms.base-url 回落(迁移期兼容)
- SvcModels.FlowSummaryVo extends SDK FlowDto(单一事实源)
- 含 2026-09-13/14 存量:bizUrl hash-query(F1)/IDHttp ctx 签名/apply 漏 schId/回填事务
This commit is contained in:
chenxing
2026-09-16 01:22:15 +08:00
parent 000d0591fa
commit 8aeb40f119
10 changed files with 84 additions and 156 deletions
@@ -15,8 +15,9 @@ import java.util.Map;
/**
* 平台代理域接口(Notice/CMS BaseApiController 同款契约):GetUserInfo / GetUserMod。
* GetUserInfo 直接返回 CAS 会话注入的 BoaUser;GetUserMod 经 Tier1 SDK 取当前用户在
* 本应用(appKey 按 yh.open 身份)下已授权模块并组树,是前端左侧菜单与页头用户信息的数据源。
* GetUserInfo 直接返回 CAS 会话注入的 BoaUser;GetUserMod 经 Tier1 SDK 取当前用户在本应用
* (appKey 按 yh.open 身份)下的已授权模块<b>树</b>(层级由用户中心 BoaModule.children 下发),
* 是前端左侧菜单与页头用户信息的数据源。
* 返回裸对象,由统一响应包装为 {code, msg, data}。
*/
@RestController
@@ -29,7 +30,7 @@ public class BaseApiController {
return authUserWithDept;
}
/** 当前用户已授权模块列表(左侧菜单树) */
/** 当前用户已授权模块树(左侧菜单) */
@GetMapping("GetUserMod")
public List<Map<String, Object>> getUserMod(BoaUser authUserWithDept) {
Integer schId = authUserWithDept.getCurrentRole() != null
@@ -38,16 +39,19 @@ public class BaseApiController {
if (modules == null || modules.isEmpty()) {
return Collections.emptyList();
}
return buildModuleTree(modules);
// 用户中心已按 BoaModule.children 下发模块树:本地不再重组层级,仅做前端字段改名映射
return toFrontendTree(modules);
}
/** 扁平模块列表组树(Notice UserCenterService.buildModuleTree 同构:modId/page/children) */
private static List<Map<String, Object>> buildModuleTree(List<BoaModule> modules) {
Map<Integer, BoaModule> moduleMap = new LinkedHashMap<>();
for (BoaModule m : modules) {
moduleMap.put(m.getId(), m);
/**
* BoaModule 树 → 前端 layout 期望的字段形状(递归,<b>只改名不组树</b>;Notice 同款口径)。<br>
* 层级与兄弟顺序均由用户中心决定(customId 升序),本侧不重排;叶子 children 为空列表。
*/
private static List<Map<String, Object>> toFrontendTree(List<BoaModule> modules) {
List<Map<String, Object>> result = new ArrayList<>();
if (modules == null || modules.isEmpty()) {
return result;
}
Map<Integer, Map<String, Object>> nodeMap = new LinkedHashMap<>();
for (BoaModule m : modules) {
Map<String, Object> node = new LinkedHashMap<>();
node.put("id", m.getId());
@@ -59,22 +63,9 @@ public class BaseApiController {
node.put("icon", m.getIcon() != null ? m.getIcon() : "");
node.put("orderNumber", m.getSortNo() != null ? m.getSortNo() : 0);
node.put("usable", true);
node.put("children", new ArrayList<>());
nodeMap.put(m.getId(), node);
node.put("children", toFrontendTree(m.getChildren()));
result.add(node);
}
List<Map<String, Object>> roots = new ArrayList<>();
for (BoaModule m : modules) {
Map<String, Object> node = nodeMap.get(m.getId());
int parentId = m.getParentId() != null ? m.getParentId() : 0;
if (parentId == 0 || !moduleMap.containsKey(parentId)) {
roots.add(node);
} else {
@SuppressWarnings("unchecked")
List<Map<String, Object>> children =
(List<Map<String, Object>>) nodeMap.get(parentId).get("children");
children.add(node);
}
}
return roots;
return result;
}
}
@@ -451,11 +451,9 @@ public final class SvcModels {
// ===== 流程(管理端回显) =====
/** 字段单一事实源=SDK 门面 DTO(可直接作 YschFlowOpenApi 泛型出入参) */
@Data
public static class FlowSummaryVo {
private String flowGuid;
private String name;
private Integer version;
private String nodeSummary;
@lombok.EqualsAndHashCode(callSuper = true)
public static class FlowSummaryVo extends com.yunhai.platform.openapi.dto.FlowDto.FlowSummary {
}
}
@@ -23,11 +23,14 @@ import java.util.Map;
* {@code GET /oapi/site/list},结果按 schId 缓存 5 分钟(CMS 侧缓存纪律的镜像:站点列表
* 低频变化,失效走 TTL)。解析不到/fail 时 fail-closed(权限校验绝不放行)。
*
* <p>必须走 YschOpenCall 而非共享 IDHttp:CMS 部署带 context-path(/cms),共享拦截器的
* basePath 取自 {@code yh.open.base-path}(本应用=/userbase),剥不掉 /cms 前缀,签名
* <p>必须走 YschOpenCall 而非共享 IDHttp:CMS 部署带 context-path(本地 {@code /cms}、
* 内网部署态 {@code /yschcms}),共享拦截器的
* basePath 取自 {@code yh.open.base-path}(本应用=/userbase),剥不掉这层前缀,签名
* target 与服务端不一致会 401;YschOpenCall 的 per-target base-path 按提供方 context-path
* 剥离,与 {@code AppAuthFilter} 对齐(同 Notice FlowCenterClient 范式)。
* {@code svchall.cms.base-url} 可配带/不带 context-path 两种形态,构造时拆成 host+basePath。
* 剥离,与 {@code AppAuthFilter} 对齐(同 Notice FlowCenterClient 范式)。<br>
* 目标地址主路径=服务目录命名目标 {@code cms}({@code yh.open.services.cms} 完整 URL,
* CMS 未晋升枚举故按名直调,《子应用配置优化方案》§4.2(5));目录未配置时回落 legacy 键
* {@code svchall.cms.base-url}(可配带/不带 context-path 两种形态,构造时拆成 host+basePath)。
*/
@Slf4j
@Component
@@ -39,12 +42,21 @@ public class CmsSiteDirectoryImpl implements SiteDirectory {
.expireAfterWrite(Duration.ofMinutes(5))
.build();
/** 服务目录命名目标(cms 未晋升枚举,按名直调);目录未配置时为 null=走 legacy ad-hoc spec */
private static final String DIRECTORY_KEY = "cms";
private final YschOpenCall openCall;
private final TargetSpec cmsSpec;
private final boolean directoryResolved;
public CmsSiteDirectoryImpl(YschOpenCall openCall,
@Value("${svchall.cms.base-url}") String cmsBaseUrl) {
this.openCall = openCall;
this.directoryResolved = openCall.hasTarget(DIRECTORY_KEY);
if (directoryResolved) {
this.cmsSpec = null;
return;
}
String base = trimTrailing(cmsBaseUrl == null ? "" : cmsBaseUrl.trim());
URI uri = URI.create(base);
String host = uri.getScheme() + "://" + uri.getRawAuthority();
@@ -105,6 +117,9 @@ public class CmsSiteDirectoryImpl implements SiteDirectory {
Map<String, String> query = schId == null
? Collections.emptyMap()
: Collections.singletonMap("schId", String.valueOf(schId));
if (directoryResolved) {
return openCall.getList(DIRECTORY_KEY, "/oapi/site/list", query, SvcModels.SiteOptionVo.class);
}
return openCall.getList(cmsSpec, "/oapi/site/list", query, SvcModels.SiteOptionVo.class);
}
@@ -23,11 +23,11 @@ import java.util.Map;
* /oapi/flow/**(flow-center 的 RequireAppSignFilter 验本应用 appKey)。flow-center 未部署时
* enabled=false,方法全部抛"流程中心未接入"。
*
* <p>必须走 YschOpenCall 而非共享 IDHttp:flow-center 生产部署带 context-path(/flow-center),
* 共享拦截器的 basePath 取自 {@code yh.open.base-path}(本应用=/userbase),剥不掉该前缀,签名
* target 与服务端不一致会 401;YschOpenCall 的 per-target base-path 按提供方 context-path 剥离
* (同 {@link CmsSiteDirectoryImpl})。{@code svchall.flow.base-url} 可配带/不带 context-path
* 两种形态,构造时拆成 host+basePath。
* <p>主路径走 SDK 类型化门面 {@code YschFlowOpenApi}(服务目录 key=flowcenter:
* yh.call.targets &gt; yh.open.services &gt; 枚举 base-host 兜底,《子应用配置优化方案》§4.2
* 零专属地址配置);目录未显式配置时回落 legacy 键 {@code svchall.flow.base-url}(ad-hoc
* TargetSpec,可配带/不带 context-path 两种形态,构造时拆成 host+basePath,迁移期兼容)。
* 两条路径的 per-target base-path 剥离语义一致(同 {@link CmsSiteDirectoryImpl})。
*/
@Slf4j
@Component
@@ -37,6 +37,8 @@ public class FlowCenterClient implements FlowClient {
private final ObjectMapper objectMapper;
private final boolean enabled;
private final TargetSpec flowSpec;
/** 服务目录显式配置了 flowcenter(targets/services)则主路径走门面命名目标 */
private final boolean directoryResolved;
public FlowCenterClient(YschOpenCall openCall, ObjectMapper objectMapper,
@Value("${svchall.flow.enabled:false}") boolean enabled,
@@ -49,6 +51,11 @@ public class FlowCenterClient implements FlowClient {
String host = uri.getScheme() + "://" + uri.getRawAuthority();
String path = uri.getRawPath() == null ? "" : uri.getRawPath();
this.flowSpec = TargetSpec.of(host, path);
this.directoryResolved = openCall.hasTarget(
com.yunhai.platform.openapi.PlatformService.FLOWCENTER.key());
if (directoryResolved) {
com.yunhai.platform.openapi.client.YschFlowOpenApi.setCall(openCall);
}
}
@Override
@@ -66,6 +73,10 @@ public class FlowCenterClient implements FlowClient {
@Override
public List<SvcModels.FlowSummaryVo> listFlows(Long schId) {
requireEnabled();
if (directoryResolved) {
return com.yunhai.platform.openapi.client.YschFlowOpenApi.listFlows(
schId, SvcModels.FlowSummaryVo.class);
}
return openCall.getList(flowSpec, "/oapi/flow/list",
Collections.singletonMap("schId", String.valueOf(schId)), SvcModels.FlowSummaryVo.class);
}
@@ -73,6 +84,10 @@ public class FlowCenterClient implements FlowClient {
@Override
public SvcModels.FlowSummaryVo getFlow(Long schId, String flowGuid) {
requireEnabled();
if (directoryResolved) {
return com.yunhai.platform.openapi.client.YschFlowOpenApi.getFlow(
schId, flowGuid, SvcModels.FlowSummaryVo.class);
}
return openCall.get(flowSpec, "/oapi/flow/" + flowGuid,
Collections.singletonMap("schId", String.valueOf(schId)), SvcModels.FlowSummaryVo.class);
}