fix(flow): 科室/成员端点补 requireId 边界防护——缺 id 回业务错而非 findById(null) 笼统 500(用户验收反馈 R2)
build / build-push (push) Successful in 2m54s

This commit is contained in:
chenxing
2026-10-10 22:43:01 +08:00
parent a06b610d9d
commit cd046782d9
@@ -12,6 +12,8 @@ import com.yunhai.flowcenter.service.FlowCallbackAdminService;
import com.yunhai.flowcenter.service.FlowDefAdminService;
import com.yunhai.flowcenter.service.FlowDiagramService;
import com.yunhai.flowcenter.service.FlowMapAdminService;
import com.yunhai.platform.apistd.BizException;
import com.yunhai.platform.utils.exception.ErrorCode;
import com.yunhai.platform.utils.model.BasePageResult;
import com.yunhai.platform.utils.model.BoaUser;
import lombok.RequiredArgsConstructor;
@@ -178,21 +180,21 @@ public class FlowAdminController {
@PostMapping("/dept/rename")
public com.yunhai.flowcenter.entity.FlwDept deptRename(BoaUser user, @RequestBody Map<String, Object> body) {
Long schId = adminGuard.requireAdmin(user, null);
return deptAdminService.rename(schId, longVal(body.get("id")), (String) body.get("deptName"));
return deptAdminService.rename(schId, requireId(body.get("id")), (String) body.get("deptName"));
}
/** 停用/启用科室(停用=解析不出办理人、发布校验拦新引用;成员不动) */
@PostMapping("/dept/status")
public void deptStatus(BoaUser user, @RequestBody Map<String, Object> body) {
Long schId = adminGuard.requireAdmin(user, null);
deptAdminService.setStatus(schId, longVal(body.get("id")), boolVal(body.get("enabled")));
deptAdminService.setStatus(schId, requireId(body.get("id")), boolVal(body.get("enabled")));
}
/** 删除科室(级联删成员;被流程引用的 deptKey 将解析失败——发布校验/办理时会拦) */
@PostMapping("/dept/delete")
public void deptDelete(BoaUser user, @RequestBody Map<String, Object> body) {
Long schId = adminGuard.requireAdmin(user, null);
deptAdminService.delete(schId, longVal(body.get("id")));
deptAdminService.delete(schId, requireId(body.get("id")));
}
@GetMapping("/dept/members")
@@ -214,13 +216,13 @@ public class FlowAdminController {
}
}
}
return deptAdminService.memberAdd(schId, longVal(body.get("deptId")), userIds);
return deptAdminService.memberAdd(schId, requireId(body.get("deptId")), userIds);
}
@PostMapping("/dept/memberRemove")
public void deptMemberRemove(BoaUser user, @RequestBody Map<String, Object> body) {
Long schId = adminGuard.requireAdmin(user, null);
deptAdminService.memberRemove(schId, longVal(body.get("memberId")));
deptAdminService.memberRemove(schId, requireId(body.get("memberId")));
}
/**
@@ -242,6 +244,15 @@ public class FlowAdminController {
return o == null ? null : Long.valueOf(String.valueOf(o));
}
/** 科室/成员行 id 缺失=调用方bug/脏请求:回业务错提示,不让 findById(null) 炸成笼统 500 */
private static Long requireId(Object o) {
Long v = longVal(o);
if (v == null) {
throw new BizException(ErrorCode.PARAM_ERROR, "缺少 id");
}
return v;
}
private static boolean boolVal(Object o) {
return o == null ? false : Boolean.parseBoolean(String.valueOf(o));
}