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); } }