From 7a844be0773361411c292060d37d1bb14e24db05 Mon Sep 17 00:00:00 2001 From: sunflower2014 Date: Tue, 27 May 2025 22:30:13 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=8C=E4=B8=9A=E5=88=86=E7=B1=BB=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E8=8E=B7=E5=8F=96=E6=8E=A5=E5=8F=A3=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?parentid=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reference/admin/controller/IndustryController.java | 3 ++- .../jinrui/reference/core/mapper/IndustryMapper.java | 7 +++++-- .../jinrui/reference/core/service/IndustryService.java | 10 ++++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/admin/src/main/java/com/jinrui/reference/admin/controller/IndustryController.java b/admin/src/main/java/com/jinrui/reference/admin/controller/IndustryController.java index 79f5f0f..64b67a7 100644 --- a/admin/src/main/java/com/jinrui/reference/admin/controller/IndustryController.java +++ b/admin/src/main/java/com/jinrui/reference/admin/controller/IndustryController.java @@ -94,6 +94,7 @@ public class IndustryController { */ @GetMapping public PageObject queryIndustry(@RequestHeader("auth-token") String token, + @RequestParam(value = "parentId", required = false, defaultValue = "-1") long parentId, @RequestParam(value = "keyword", required = false) String keyword, @RequestParam(value = "page", required = false, defaultValue = "1") int page, @RequestParam(value = "size", required = false, defaultValue = "10") int size, @@ -123,7 +124,7 @@ public class IndustryController { return PageObject.failedPage(500, "服务端错误,请联系系统管理员!"); } - return industryService.queryIndustry(keyword, page, size, orderBy, direction); + return industryService.queryIndustry(parentId, keyword, page, size, orderBy, direction); } } diff --git a/core/src/main/java/com/jinrui/reference/core/mapper/IndustryMapper.java b/core/src/main/java/com/jinrui/reference/core/mapper/IndustryMapper.java index 06e23db..9b071fb 100644 --- a/core/src/main/java/com/jinrui/reference/core/mapper/IndustryMapper.java +++ b/core/src/main/java/com/jinrui/reference/core/mapper/IndustryMapper.java @@ -69,8 +69,11 @@ public interface IndustryMapper { @Select("") - List queryIndustry(@Param("keyword") String keyword, @Param("orderBy") String orderBy, @Param("direction") String direction); + List queryIndustry(@Param("parentId") Long parentId, @Param("keyword") String keyword, @Param("orderBy") String orderBy, @Param("direction") String direction); } diff --git a/core/src/main/java/com/jinrui/reference/core/service/IndustryService.java b/core/src/main/java/com/jinrui/reference/core/service/IndustryService.java index 5cecf8b..1c2d565 100644 --- a/core/src/main/java/com/jinrui/reference/core/service/IndustryService.java +++ b/core/src/main/java/com/jinrui/reference/core/service/IndustryService.java @@ -72,7 +72,7 @@ public class IndustryService { * @param size 分页参数 当前页长度 默认10条 * @return 标签搜索结果 */ - public PageObject queryIndustry(String keyword,int page, int size, String orderBy, String direction) { + public PageObject queryIndustry(long parentId, String keyword,int page, int size, String orderBy, String direction) { if (StringUtils.hasText(orderBy)) { switch (orderBy) { case "updateTime": { @@ -88,7 +88,13 @@ public class IndustryService { List industrys; try { - industrys = industryMapper.queryIndustry(keyword, orderBy, direction); + if (parentId == -1) { + industrys = industryMapper.queryIndustry(null, keyword, orderBy, direction); + } else { + industrys = industryMapper.queryIndustry(parentId, keyword, orderBy, direction); + + } + } catch (Exception e) { log.error("搜索行业分类出错!", e); return PageObject.failedPage(500, "服务端错误,请联系系统管理员!");