From 3003639596150ba6d763ab28423df4140750e9ee Mon Sep 17 00:00:00 2001 From: tiger_zhou Date: Fri, 8 Nov 2024 17:55:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/impl/FaultQueryRepository.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/club/joylink/xiannccda/repository/impl/FaultQueryRepository.java b/src/main/java/club/joylink/xiannccda/repository/impl/FaultQueryRepository.java index 6823a83..7e4d36f 100644 --- a/src/main/java/club/joylink/xiannccda/repository/impl/FaultQueryRepository.java +++ b/src/main/java/club/joylink/xiannccda/repository/impl/FaultQueryRepository.java @@ -6,10 +6,12 @@ import club.joylink.xiannccda.entity.FaultQuery; import club.joylink.xiannccda.exception.BusinessExceptionAssertEnum; import club.joylink.xiannccda.mapper.FaultQueryMapper; import club.joylink.xiannccda.repository.IFaultQueryRepository; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.StringPool; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.google.common.base.Splitter; import java.util.Objects; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -40,9 +42,11 @@ public class FaultQueryRepository extends ServiceImpl page(FaultQueryReqDTO reqDTO) { QueryWrapper qw = new QueryWrapper<>(); - qw.lambda().eq(Objects.nonNull(reqDTO.getLineId()), FaultQuery::getLineId, reqDTO.getLineId()) - .in(Objects.nonNull(reqDTO.getFaultType()), FaultQuery::getFaultType, reqDTO.getFaultType().split(StringPool.COMMA)) - .eq(StringUtils.isNotEmpty(reqDTO.getFaultName()), FaultQuery::getFaultNameShower, reqDTO.getFaultName()); + LambdaQueryWrapper lam = qw.lambda().eq(Objects.nonNull(reqDTO.getLineId()), FaultQuery::getLineId, reqDTO.getLineId()) + .like(StringUtils.isNotEmpty(reqDTO.getFaultName()), FaultQuery::getFaultNameShower, reqDTO.getFaultName()); + if (StringUtils.isNotEmpty(reqDTO.getFaultType())) { + lam.in(FaultQuery::getFaultType, Splitter.on(StringPool.COMMA).trimResults().splitToList(reqDTO.getFaultType())); + } return this.page(CommonPageRequest.defaultPage(), qw); } }