From 7ed7a70e84e738735d0116ae75c6e8c17c4c7e20 Mon Sep 17 00:00:00 2001 From: AgAngle <1323481023@qq.com> Date: Tue, 10 Sep 2024 14:40:06 +0800 Subject: [PATCH] =?UTF-8?q?fxi(=E5=8A=9F=E8=83=BD=E7=94=A8=E4=BE=8B):=20?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=AD=97=E6=AE=B5=E9=AB=98=E7=BA=A7?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E7=BB=93=E6=9E=9C=E6=9C=89=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --task=1016128 --user=陈建星 高级搜索-视图增删改查-后端 https://www.tapd.cn/55049933/s/1573254 --- .../metersphere/sdk/dto/CombineCondition.java | 11 +++- .../mapper/ExtFunctionalCaseMapper.xml | 6 ++ .../metersphere/system/mapper/BaseMapper.xml | 66 +++++++++++++++++-- .../system/service/UserViewService.java | 2 +- .../controller/UserViewControllerTests.java | 2 +- 5 files changed, 77 insertions(+), 10 deletions(-) diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/CombineCondition.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/CombineCondition.java index 161772cc00..ff59afefed 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/CombineCondition.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/CombineCondition.java @@ -27,12 +27,21 @@ public class CombineCondition { @NotNull private Boolean customField = false; + @Schema(description = "自定义字段的类型") + private String customFieldType; + @Schema(description = "操作符", allowableValues = {"IN", "NOT_IN", "BETWEEN", "GT", "LT", "COUNT_GT", "COUNT_LT", "EQUALS", "NOT_EQUALS", "CONTAINS", "NOT_CONTAINS", "EMPTY", "NOT_EMPTY"}) @EnumValue(enumClass = CombineConditionOperator.class) private String operator; public boolean valid() { + if (StringUtils.isBlank(name) || StringUtils.isBlank(operator)) { + return false; + } + if (StringUtils.equalsAny(operator, CombineConditionOperator.EMPTY.name(), CombineConditionOperator.NOT_EMPTY.name())) { + return true; + } if (value == null) { return false; } @@ -42,7 +51,7 @@ public class CombineCondition { if (value instanceof String valueStr && StringUtils.isBlank(valueStr)) { return false; } - return StringUtils.isNotBlank(name) && StringUtils.isNotBlank(operator); + return true; } public enum CombineConditionOperator { diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseMapper.xml b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseMapper.xml index c058e220ba..a709245b00 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseMapper.xml +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseMapper.xml @@ -315,6 +315,12 @@ + + + + + + functional_case.id in ( select case_id from functional_case_demand where diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/BaseMapper.xml b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/BaseMapper.xml index 3872ac45fc..67cfdafc3b 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/BaseMapper.xml +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/BaseMapper.xml @@ -46,7 +46,7 @@ - + @@ -59,10 +59,20 @@ field_id = #{condition.name} and - - - - + + + + + + + + + + + + + + @@ -71,6 +81,48 @@ + + + + + + JSON_CONTAINS(${column}, JSON_ARRAY(#{tag})) + + + + + JSON_CONTAINS(${column}, JSON_ARRAY(#{tag})) + + + + ${column} is null or ${column} = '[]' or + + !JSON_CONTAINS(${column}, JSON_ARRAY(#{tag})) + + + + ${column} is null or ${column} = '[]' or + + !JSON_CONTAINS(${column}, JSON_ARRAY(#{tag})) + + + + JSON_LENGTH(${column}) > #{condition.value} + + + ${column} is null or ${column} = '[]' or + JSON_LENGTH(${column}) < #{condition.value} + + + ${column} is null or ${column} = '[]' + + + ${column} is not null and ${column} = '[]' + + + + + @@ -120,10 +172,10 @@ JSON_LENGTH(${column}) < #{condition.value} - ${column} is null or ${column} #{condition.value} = '' + ${column} is null or ${column} = '' - ${column} is not null and ${column} #{condition.value} = '' + ${column} is not null and ${column} != '' ${column} = #{condition.value} diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserViewService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserViewService.java index 9310da8df3..d1b1b5272a 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserViewService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserViewService.java @@ -279,7 +279,7 @@ public class UserViewService { .andScopeIdEqualTo(scopeId) .andViewTypeEqualTo(viewType.name()); List customUserViews = userViewMapper.selectByExample(example).stream() - .sorted(Comparator.comparing(UserView::getPos)) + .sorted((a, b) -> Comparator.comparing(UserView::getPos).compare(b, a)) .collect(Collectors.toList()); UserViewListGroupedDTO groupedDTO = new UserViewListGroupedDTO(); diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/UserViewControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/UserViewControllerTests.java index 3791b02db9..ed34ddf8e9 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/UserViewControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/UserViewControllerTests.java @@ -181,7 +181,7 @@ public class UserViewControllerTests extends BaseTest { UserViewListGroupedDTO result = getResultData(mvcResult, UserViewListGroupedDTO.class); Assertions.assertEquals(result.getInternalViews().size(), 3); Assertions.assertEquals(result.getCustomViews().size(), 2); - Assertions.assertEquals(result.getCustomViews().get(0), BeanUtils.copyBean(new UserView(), addUserViewDTO)); + Assertions.assertEquals(result.getCustomViews().getLast(), BeanUtils.copyBean(new UserView(), addUserViewDTO)); } @Test