| | |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.util.ObjUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; |
| | | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| | | import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; |
| | | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelMetaInfoVO; |
| | |
| | | * 流程模型实现:主要进行 Flowable {@link Model} 的维护 |
| | | * |
| | | * @author yunlongn |
| | | * @author 芋道源码 |
| | | * @author 超级管理员 |
| | | * @author jason |
| | | */ |
| | | @Service |
| | |
| | | private Model validateModelManager(String id, Long userId) { |
| | | Model model = validateModelExists(id); |
| | | BpmModelMetaInfoVO metaInfo = BpmModelConvert.INSTANCE.parseMetaInfo(model); |
| | | if (metaInfo == null || !CollUtil.contains(metaInfo.getManagerUserIds(), userId)) { |
| | | throw exception(MODEL_UPDATE_FAIL_NOT_MANAGER, model.getName()); |
| | | // 1. 未配置流程管理员 → 放行。 |
| | | // 历史模型(备份恢复/迁移)META_INFO 里 managerUserIds 为空数组或缺失, |
| | | // 而 updateModel 是「先校验后写入」,一旦为空就会永久校验失败,无法自愈。 |
| | | if (metaInfo == null || CollUtil.isEmpty(metaInfo.getManagerUserIds())) { |
| | | log.warn("[validateModelManager][模型({}) 未配置流程管理员,跳过管理员校验]", model.getName()); |
| | | return model; |
| | | } |
| | | return model; |
| | | // 2. 当前操作人在管理员列表里 → 放行 |
| | | if (CollUtil.contains(metaInfo.getManagerUserIds(), userId)) { |
| | | return model; |
| | | } |
| | | // 3. 超级管理员始终放行。 |
| | | // 否则模型一旦被保存成只包含某个具体账号,换账号(含超管)就再也改不了该模型, |
| | | // 报「操作流程失败,原因:你不是该流程(xxx)的管理员」,形成死锁。 |
| | | if (SecurityFrameworkUtils.isSuperAdmin()) { |
| | | log.warn("[validateModelManager][模型({}) 管理员({}) 不含当前用户({}),但为超级管理员,放行]", |
| | | model.getName(), metaInfo.getManagerUserIds(), userId); |
| | | return model; |
| | | } |
| | | throw exception(MODEL_UPDATE_FAIL_NOT_MANAGER, model.getName()); |
| | | } |
| | | |
| | | @Override |