From d1592198307f701f9ed56b6b53800d5a6b18316f Mon Sep 17 00:00:00 2001 From: "zangch@mesnac.com" Date: Mon, 16 Mar 2026 13:39:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=90=9C=E7=B4=A2SQL?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E9=9B=86=E4=B8=8D=E4=B8=80=E8=87=B4=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E5=8F=8A=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - HwSearchMapper 统一 UNION 各分支的字符集和排序规则,避免历史表结构 collation 不一致时搜索兜底 SQL 直接失败 - `order`避免与关键字冲突 --- .../controller/TextSearchController.java | 2 + .../search/service/impl/SearchImpl.java | 13 ++- .../mapper/portal/HwSearchMapper.xml | 95 ++++++------------- .../mapper/portal/HwWebMenuMapper.xml | 6 +- .../mapper/portal/HwWebMenuMapper1.xml | 4 +- 5 files changed, 44 insertions(+), 76 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/search/controller/TextSearchController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/search/controller/TextSearchController.java index b8bd532..bfefa67 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/search/controller/TextSearchController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/search/controller/TextSearchController.java @@ -2,6 +2,7 @@ package com.ruoyi.web.controller.search.controller; import org.dromara.easyes.core.biz.EsPageInfo; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -26,6 +27,7 @@ import com.ruoyi.web.controller.search.service.ISearchService; * @author ruoyi */ @RestController +@ConditionalOnProperty(prefix = "ruoyi.search.admin-demo", name = "enabled", havingValue = "true") @RequestMapping("/search/fulltext") public class TextSearchController { diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/search/service/impl/SearchImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/search/service/impl/SearchImpl.java index 1f69fd7..c78e6d1 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/search/service/impl/SearchImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/search/service/impl/SearchImpl.java @@ -6,7 +6,7 @@ import jakarta.annotation.PostConstruct; import org.dromara.easyes.core.biz.EsPageInfo; import org.dromara.easyes.core.conditions.select.LambdaEsQueryWrapper; import org.dromara.easyes.core.conditions.update.LambdaEsUpdateWrapper; -import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.stereotype.Service; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.bean.BeanUtils; @@ -16,7 +16,6 @@ import com.ruoyi.web.controller.search.mapper.EsTextDocumentMapper; import com.ruoyi.web.controller.search.model.EsTextDocument; import com.ruoyi.web.controller.search.model.Search; import com.ruoyi.web.controller.search.service.ISearchService; -import lombok.RequiredArgsConstructor; /** * 实体模板Service业务层处理 @@ -24,13 +23,17 @@ import lombok.RequiredArgsConstructor; * @author ruoyi */ @Service -@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +@ConditionalOnProperty(prefix = "ruoyi.search.admin-demo", name = "enabled", havingValue = "true") public class SearchImpl implements ISearchService { private final EsTextDocumentMapper esTextDocumentMapper; + private final SysNoticeMapper noticeMapper; - @Autowired - private SysNoticeMapper noticeMapper; + public SearchImpl(EsTextDocumentMapper esTextDocumentMapper, SysNoticeMapper noticeMapper) + { + this.esTextDocumentMapper = esTextDocumentMapper; + this.noticeMapper = noticeMapper; + } /** * 项目启动时,初始化索引及数据 diff --git a/ruoyi-portal/src/main/resources/mapper/portal/HwSearchMapper.xml b/ruoyi-portal/src/main/resources/mapper/portal/HwSearchMapper.xml index 16127b8..bf6a459 100644 --- a/ruoyi-portal/src/main/resources/mapper/portal/HwSearchMapper.xml +++ b/ruoyi-portal/src/main/resources/mapper/portal/HwSearchMapper.xml @@ -19,37 +19,18 @@ - + insert into hw_web_menu web_menu_id, diff --git a/ruoyi-portal/src/main/resources/mapper/portal/HwWebMenuMapper1.xml b/ruoyi-portal/src/main/resources/mapper/portal/HwWebMenuMapper1.xml index 0fc78a7..f275706 100644 --- a/ruoyi-portal/src/main/resources/mapper/portal/HwWebMenuMapper1.xml +++ b/ruoyi-portal/src/main/resources/mapper/portal/HwWebMenuMapper1.xml @@ -48,7 +48,7 @@ where is_delete = '0' and web_menu_id = #{webMenuId} - + insert into hw_web_menu1 web_menu_id, @@ -107,4 +107,4 @@ #{webMenuId} - \ No newline at end of file +