From 02a26e9bb44ced556cbf3d139df7ae23b46b05d4 Mon Sep 17 00:00:00 2001 From: sam80180 Date: Mon, 25 Dec 2023 09:49:24 +0800 Subject: [PATCH] fix: fix device filter bug --- .../services/impl/DevicesServiceImpl.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/DevicesServiceImpl.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/DevicesServiceImpl.java index 93f2c216..cad1491d 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/DevicesServiceImpl.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/DevicesServiceImpl.java @@ -190,7 +190,7 @@ public Page findAll(List iOSVersion, List androidVersio if (androidVersion != null || iOSVersion != null || hmVersion != null) { chainWrapper.and(i -> { if (androidVersion != null) { - i.or().eq(Devices::getPlatform, 1).eq(Devices::getIsHm, 0) + i.or().eq(Devices::getPlatform, PlatformType.ANDROID).eq(Devices::getIsHm, 0) .and(j -> { for (String v : androidVersion) { j.or().likeRight(Devices::getVersion, v); @@ -198,14 +198,14 @@ public Page findAll(List iOSVersion, List androidVersio }); } if (iOSVersion != null) { - i.or().eq(Devices::getPlatform, 2).and(j -> { + i.or().eq(Devices::getPlatform, PlatformType.IOS).and(j -> { for (String v : iOSVersion) { j.or().likeRight(Devices::getVersion, v); } }); } if (hmVersion != null) { - i.or().eq(Devices::getPlatform, 1).eq(Devices::getIsHm, 1) + i.or().eq(Devices::getPlatform, PlatformType.ANDROID).eq(Devices::getIsHm, 1) .and(j -> { for (String v : hmVersion) { j.or().likeRight(Devices::getVersion, v); @@ -236,10 +236,9 @@ public Page findAll(List iOSVersion, List androidVersio } if (StringUtils.hasText(deviceInfo)) { - chainWrapper.like(Devices::getUdId, deviceInfo) - .or().like(Devices::getModel, deviceInfo) - .or().like(Devices::getChiName, deviceInfo) - .or().like(Devices::getNickName, deviceInfo); + chainWrapper.and(q -> { + q.like(Devices::getUdId, deviceInfo).or().like(Devices::getModel, deviceInfo).or().like(Devices::getNickName, deviceInfo).or().like(Devices::getChiName, deviceInfo); + }); } chainWrapper.last("order by case\n" +