From a988dedfbf3245dde795f194e624ffb8753aef56 Mon Sep 17 00:00:00 2001 From: paulGao Date: Sat, 2 Apr 2022 18:42:03 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E8=8E=B7=E5=8F=96=E5=9C=B0=E5=9D=80=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/common/RegionController.java | 7 ++++++- .../modules/system/service/RegionService.java | 8 ++++++++ .../system/serviceimpl/RegionServiceImpl.java | 19 +++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/common-api/src/main/java/cn/lili/controller/common/RegionController.java b/common-api/src/main/java/cn/lili/controller/common/RegionController.java index f951f058..9abcfce3 100644 --- a/common-api/src/main/java/cn/lili/controller/common/RegionController.java +++ b/common-api/src/main/java/cn/lili/controller/common/RegionController.java @@ -2,9 +2,9 @@ package cn.lili.controller.common; import cn.lili.common.enums.ResultUtil; import cn.lili.common.vo.ResultMessage; -import cn.lili.modules.system.service.RegionService; import cn.lili.modules.system.entity.dos.Region; import cn.lili.modules.system.entity.vo.RegionVO; +import cn.lili.modules.system.service.RegionService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -38,6 +38,11 @@ public class RegionController { return ResultUtil.data(regionService.getRegion(cityCode,townName)); } + @GetMapping(value = "/name") + @ApiOperation(value = "根据名字获取地区地址id") + public ResultMessage getItemByLastName(String lastName) { + return ResultUtil.data(regionService.getItemByLastName(lastName)); + } @GetMapping(value = "/item/{id}") @ApiImplicitParam(name = "id", value = "地区ID", required = true, dataType = "String", paramType = "path") diff --git a/framework/src/main/java/cn/lili/modules/system/service/RegionService.java b/framework/src/main/java/cn/lili/modules/system/service/RegionService.java index 53261699..3696d7c3 100644 --- a/framework/src/main/java/cn/lili/modules/system/service/RegionService.java +++ b/framework/src/main/java/cn/lili/modules/system/service/RegionService.java @@ -36,6 +36,14 @@ public interface RegionService extends IService { @Cacheable(key = "#id") List getItem(String id); + /** + * 根据最后一级名称获取改所有上级地区id + * + * @param lastName 最后一级名称 + * @return 全部地区id + */ + String getItemByLastName(String lastName); + /** * 获取地址 * diff --git a/framework/src/main/java/cn/lili/modules/system/serviceimpl/RegionServiceImpl.java b/framework/src/main/java/cn/lili/modules/system/serviceimpl/RegionServiceImpl.java index 5b29279d..dfb8863e 100644 --- a/framework/src/main/java/cn/lili/modules/system/serviceimpl/RegionServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/system/serviceimpl/RegionServiceImpl.java @@ -61,6 +61,25 @@ public class RegionServiceImpl extends ServiceImpl impleme } } + /** + * 根据最后一级名称获取改所有上级地区id + * + * @param lastName 最后一级名称 + * @return 全部地区id + */ + @Override + public String getItemByLastName(String lastName) { + StringBuilder sql = new StringBuilder(); + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(Region::getName, lastName); + Region region = this.getOne(lambdaQueryWrapper, false); + if (region != null) { + sql.append(region.getPath()).append(",").append(region.getId()); + return sql.toString().replace(",0,",""); + } + return null; + } + @Override public List getItem(String id) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); From 8e30defa0e8531450e3ff04df7da573d49f6e4ea Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 6 Apr 2022 10:39:51 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BC=98=E5=8C=96es=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=EF=BC=8C=E5=85=A8=E5=88=86=E8=AF=8D=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E6=94=B9=E4=B8=BA2=E5=88=86=E8=AF=8D=E5=8C=B9?= =?UTF-8?q?=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/search/serviceimpl/EsGoodsSearchServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java index 85d669e0..63d53d13 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java @@ -562,7 +562,8 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { */ private List buildKeywordSearch(String keyword) { List filterFunctionBuilders = new ArrayList<>(); - MatchQueryBuilder goodsNameQuery = QueryBuilders.matchQuery("goodsName", keyword).operator(Operator.AND); + // operator 为 AND 时 需全部分词匹配。为 OR 时 需配置 minimumShouldMatch(最小分词匹配数)不设置默认为1 + MatchQueryBuilder goodsNameQuery = QueryBuilders.matchQuery("goodsName", keyword).operator(Operator.OR).minimumShouldMatch("2"); //分词匹配 filterFunctionBuilders.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(goodsNameQuery, ScoreFunctionBuilders.weightFactorFunction(10))); From 63b23fbe76026a591da7013408a2c16ac08ac63f Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 7 Apr 2022 16:06:23 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A7=92=E6=9D=80?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E7=9B=B8=E5=90=8C=E5=95=86=E5=93=81=E5=8F=82?= =?UTF-8?q?=E4=B8=8E=E6=97=B6=EF=BC=8C=E5=88=A0=E9=99=A4=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E5=95=86=E5=93=81=E4=BF=A1=E6=81=AF=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/promotion/serviceimpl/SeckillApplyServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java index 11665dcb..07572e9c 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java @@ -184,6 +184,7 @@ public class SeckillApplyServiceImpl extends ServiceImpl