From e8a5bf08ad3fa43e6bb6237210f2f7b7980eae51 Mon Sep 17 00:00:00 2001 From: wuchunlei Date: Sat, 27 Jan 2024 10:08:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=B4=E9=97=A8=E5=8C=BB=E8=BF=B0-=E5=AD=A6?= =?UTF-8?q?=E6=9C=AF=E4=BC=A0=E6=89=BF-=E4=BA=BA=E5=91=98=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MedicinalMaterialsController.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/peanut/modules/book/controller/MedicinalMaterialsController.java b/src/main/java/com/peanut/modules/book/controller/MedicinalMaterialsController.java index 0398d7da..a504c737 100644 --- a/src/main/java/com/peanut/modules/book/controller/MedicinalMaterialsController.java +++ b/src/main/java/com/peanut/modules/book/controller/MedicinalMaterialsController.java @@ -9,9 +9,6 @@ import com.peanut.modules.book.service.MedicinalDrugService; import com.peanut.modules.book.service.MedicinalMaterialsService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; -import org.jsoup.Jsoup; -import org.jsoup.nodes.Document; -import org.jsoup.select.Elements; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -47,9 +44,15 @@ public class MedicinalMaterialsController { if (StringUtils.isNotEmpty(params.get("effect").toString())){ wrapper.like(MedicinalMaterials::getEffect,params.get("effect")); } - wrapper.and(t->t.like(MedicinalMaterials::getProperty,params.get("taste")) - .or().like(MedicinalMaterials::getProperty,params.get("property")) - .or().like(MedicinalMaterials::getProperty,params.get("tropism"))); + if (StringUtils.isNotEmpty(params.get("taste").toString())){ + wrapper.like(MedicinalMaterials::getTaste,params.get("taste")); + } + if (StringUtils.isNotEmpty(params.get("property").toString())){ + wrapper.like(MedicinalMaterials::getProperty,params.get("property")); + } + if (StringUtils.isNotEmpty(params.get("tropism").toString())){ + wrapper.like(MedicinalMaterials::getTropism,params.get("tropism")); + } wrapper.orderByAsc(MedicinalMaterials::getSort); wrapper.orderByDesc(MedicinalMaterials::getHits); Page page = materialsService.page(new Page<>(