From b4e07b27e2197bb08591565269b6833ed0ccda34 Mon Sep 17 00:00:00 2001 From: buaixuexideshitongxue <2936013465@qq.com> Date: Fri, 26 Dec 2025 11:05:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=89=E8=AE=BF=E6=B6=89=E8=AF=89--=E5=9F=BA?= =?UTF-8?q?=E7=A1=80=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 22 +++++++++++++ .../supervision/repository/base/BaseDAO.java | 31 ++++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b898501..dde4465 100644 --- a/pom.xml +++ b/pom.xml @@ -31,6 +31,28 @@ + + org.projectlombok + lombok + true + + + + + org.mapstruct + mapstruct + 1.5.5.Final + + + + + org.mapstruct + mapstruct-processor + 1.5.5.Final + provided + + + com.google.guava guava diff --git a/src/main/java/com/biutag/supervision/repository/base/BaseDAO.java b/src/main/java/com/biutag/supervision/repository/base/BaseDAO.java index c750b96..53d4f0a 100644 --- a/src/main/java/com/biutag/supervision/repository/base/BaseDAO.java +++ b/src/main/java/com/biutag/supervision/repository/base/BaseDAO.java @@ -1,11 +1,14 @@ package com.biutag.supervision.repository.base; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.google.common.collect.Lists; import org.springframework.dao.DuplicateKeyException; +import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -20,6 +23,7 @@ public abstract class BaseDAO { /** * 整合单个和批量 + * * @param single * @param batch * @param wrapper @@ -48,11 +52,36 @@ public abstract class BaseDAO { } } + public void setBatchLikeQuery(String single, Collection batch, LambdaQueryWrapper qw, SFunction column) { + // 单值 like + if (StrUtil.isNotBlank(single)) { + qw.like(column, single); + return; + } + + // 多值 like(OR) + if (CollectionUtil.isNotEmpty(batch)) { + qw.and(w -> { + boolean first = true; + for (String val : batch) { + if (StrUtil.isBlank(val)) continue; + if (first) { + w.like(column, val); + first = false; + } else { + w.or().like(column, val); + } + } + }); + } + } + /** * 批量添加 20一组 - * @return + * * @param + * @return */ protected void innerBatchInsert(HBaseMapper mapper, List entities, String message) { try {