F2-6: candidateGroup URL 膨胀修复 + 角色缓存失效钩子

- flowable-service: 新增 POST /api/flow/tasks/todo 端点(TodoRequest body),
  避免 ceshi 236 角色 × 36 字符拼 GET URL 超 8KB 限制
- FlowableClient.todo() 改用 POST body 传 candidateGroups,
  新增 post() ParameterizedTypeReference 重载支持 List 返回类型
- AdminWriteController: 注入 RoleResolver,用户组成员增减调 evict(userId),
  用户组角色增减/删除调 evictAll(),确保权限变更后缓存及时失效
- platform-metadata/pom.xml 加 platform-auth 依赖
- AdminWriteControllerTest 适配 RoleResolver mock 参数
This commit is contained in:
2026-06-12 03:09:36 +08:00
parent 2f1f00a74a
commit 2dcc0c61bf
6 changed files with 61 additions and 23 deletions

View File

@@ -54,30 +54,18 @@ public class FlowableClient {
/**
* 当前用户待办(按 assignee + 候选组/候选用户;空集合表示不按该维度过滤)。
*
* <p>对应引擎 {@code TaskQuery.active().taskAssignee()/taskCandidateGroup()/taskCandidateUser()}。
* 三维任一为空则不下发该 query 参数(由 flowable-service 侧 {@code isBlank} 跳过)。
* <p>F2-6 JWT 瘦身:改用 POST body 传 candidateGroups,避免多角色用户(如 ceshi 236 个角色)
* URL 超 Tomcat 默认 8KB 限制。flowable-service 新增 POST /api/flow/tasks/todo 端点承接。
*/
public List<FlowTaskDto> todo(String assignee, List<String> candidateGroups, String candidateUser,
int firstResult, int maxResults) {
return get("待办", uri -> {
uri.path("/api/flow/tasks/todo");
if (notBlank(assignee)) {
uri.queryParam("assignee", assignee);
}
if (candidateGroups != null) {
for (String g : candidateGroups) {
if (notBlank(g)) {
uri.queryParam("candidateGroup", g);
}
}
}
if (notBlank(candidateUser)) {
uri.queryParam("candidateUser", candidateUser);
}
uri.queryParam("firstResult", firstResult);
uri.queryParam("maxResults", maxResults);
return uri.build();
});
Map<String, Object> body = new java.util.LinkedHashMap<>();
body.put("assignee", assignee);
body.put("candidateGroups", candidateGroups != null ? candidateGroups : List.of());
body.put("candidateUser", candidateUser);
body.put("firstResult", firstResult);
body.put("maxResults", maxResults);
return post("待办", "/api/flow/tasks/todo", body, TASK_LIST);
}
/** 当前用户已办(历史已完成任务,按 assignee)。 */
@@ -155,6 +143,14 @@ public class FlowableClient {
.body(respType));
}
private <T> T post(String op, String path, Object body, ParameterizedTypeReference<T> respType) {
return execute(op, () -> restClient.post()
.uri(path)
.body(body == null ? Map.of() : body)
.retrieve()
.body(respType));
}
/**
* 统一执行:连接级故障带退避重试 maxRetries 次,耗尽 → 503 语义;业务错(4xx/5xx)立即透传不重试。
*/