From d5ec1cf140b6274804ae6a6cb5fa043077a0d289 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Wed, 13 Dec 2023 15:02:26 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=A3=80=E6=9F=A5=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E5=92=8C=E9=A1=B9=E7=9B=AE=E5=85=B3=E7=B3=BB=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=89=B9=E9=87=8Fid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metersphere/system/mapper/ExtCheckOwnerMapper.java | 4 +++- .../io/metersphere/system/mapper/ExtCheckOwnerMapper.xml | 9 ++++++--- .../io/metersphere/system/security/CheckOwnerAspect.java | 8 +++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtCheckOwnerMapper.java b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtCheckOwnerMapper.java index 37a827288d..9bcf3c2d7c 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtCheckOwnerMapper.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtCheckOwnerMapper.java @@ -2,6 +2,8 @@ package io.metersphere.system.mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + public interface ExtCheckOwnerMapper { - boolean checkoutOwner(@Param("table") String resourceType, @Param("projectId") String projectId, @Param("id") String id); + boolean checkoutOwner(@Param("table") String resourceType, @Param("projectId") String projectId, @Param("ids") List ids); } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtCheckOwnerMapper.xml b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtCheckOwnerMapper.xml index 87a60db473..3218b45798 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtCheckOwnerMapper.xml +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtCheckOwnerMapper.xml @@ -2,9 +2,12 @@ \ No newline at end of file diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/security/CheckOwnerAspect.java b/backend/services/system-setting/src/main/java/io/metersphere/system/security/CheckOwnerAspect.java index 7bfddf13cf..ba9b6df944 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/security/CheckOwnerAspect.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/security/CheckOwnerAspect.java @@ -22,6 +22,7 @@ import org.springframework.expression.spel.support.StandardEvaluationContext; import org.springframework.stereotype.Component; import java.lang.reflect.Method; +import java.util.List; @Aspect @@ -68,7 +69,12 @@ public class CheckOwnerAspect { Expression titleExp = parser.parseExpression(resourceId); Object v = titleExp.getValue(context, Object.class); if (v instanceof String id) { - if (!extCheckOwnerMapper.checkoutOwner(resourceType, SessionUtils.getCurrentProjectId(), id)) { + if (!extCheckOwnerMapper.checkoutOwner(resourceType, SessionUtils.getCurrentProjectId(), List.of(id))) { + throw new MSException(Translator.get("check_owner_case")); + } + } + if (v instanceof List ids) { + if (!extCheckOwnerMapper.checkoutOwner(resourceType, SessionUtils.getCurrentProjectId(), ids)) { throw new MSException(Translator.get("check_owner_case")); } }