This commit is contained in:
@@ -61,6 +61,14 @@ public class OapiFlowService {
|
||||
@Value("${flow-center.submitter-school-check.enabled:true}")
|
||||
private boolean submitterCheckEnabled;
|
||||
|
||||
/**
|
||||
* 办件进度嵌入页前端基址(flow-center 自身的对外前端地址,本方案新增的第一个前端地址配置:
|
||||
* 此前 UserMsg jumpPath 均为裸相对路径由接收方解析)。未配置即调签发 → fail-fast 业务异常,
|
||||
* 与 callback-url 同纪律——宁可不发也不发一个打不开的地址。
|
||||
*/
|
||||
@Value("${flow-center.embed.front-url:}")
|
||||
private String embedFrontUrl;
|
||||
|
||||
private final FlwDefRepository defRepository;
|
||||
private final FlwInstanceRepository instanceRepository;
|
||||
private final FlwTaskRepository taskRepository;
|
||||
@@ -324,6 +332,43 @@ public class OapiFlowService {
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 办件进度嵌入页换址(token 模式,与换图同构):同一 token 两处消费——嵌入页数据
|
||||
* /open/flow/embed/data 与流程图 /open/flow/diagram/img 均免签认领该 token。定位二选一:
|
||||
* instanceId(与办件直接复核)/ bizType+bizId(对账口径,办件不存在与 progress 同文案)。
|
||||
* 用户级可见性(本人/办理人/管理员)由子应用后端在调本端点前完成——oapi 层只认 schId。
|
||||
*/
|
||||
public OapiModels.EmbedUrlVo embedUrl(Long schId, Long instanceId, String bizType, String bizId, String mode) {
|
||||
// 配置缺失优先于办件定位:fail-fast 纪律要的是"无论如何都不发打不开的地址"
|
||||
if (embedFrontUrl == null || embedFrontUrl.trim().isEmpty()) {
|
||||
throw new BizException(ErrorCode.INTERNAL_SERVER_ERROR, "嵌入页地址未配置:flow-center.embed.front-url");
|
||||
}
|
||||
Long resolvedInstanceId;
|
||||
if (instanceId != null) {
|
||||
resolvedInstanceId = requireInstance(schId, instanceId).getId();
|
||||
} else {
|
||||
if (bizType == null || bizId == null) {
|
||||
throw new BizException(ErrorCode.PARAM_ERROR, "缺少必要参数:instanceId 或 bizType/bizId");
|
||||
}
|
||||
OapiModels.InstanceVo vo = instanceByBiz(schId, bizType, bizId);
|
||||
if (vo == null) {
|
||||
throw new BizException(ErrorCode.PARAM_ERROR, "办件不存在或不可见");
|
||||
}
|
||||
resolvedInstanceId = vo.getInstanceId();
|
||||
}
|
||||
// mode 与 DiagramTokenService 内部缺省同值("auto"),URL 里显式带上仅为前端展示冗余
|
||||
String normMode = mode == null || mode.trim().isEmpty() ? "auto" : mode.trim();
|
||||
String token = tokenService.issue(schId, resolvedInstanceId, null, normMode);
|
||||
String base = embedFrontUrl.trim();
|
||||
if (!base.endsWith("/")) {
|
||||
base = base + "/";
|
||||
}
|
||||
OapiModels.EmbedUrlVo out = new OapiModels.EmbedUrlVo();
|
||||
out.setPageUrl(base + "#/embed/instance?token=" + token + "&mode=" + normMode);
|
||||
out.setExpiresIn(DiagramTokenService.TTL_MS / 1000);
|
||||
return out;
|
||||
}
|
||||
|
||||
/** 进度/换图共用的办件定位(schId 收敛在次) */
|
||||
private FlwInstance requireInstance(Long schId, Long instanceId) {
|
||||
FlwInstance instance = instanceRepository.findById(instanceId)
|
||||
|
||||
Reference in New Issue
Block a user