From 0121c546f4521e2eab7e55843d00d347f11804f1 Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 24 Jun 2021 09:20:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=86=E7=B1=BB=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E4=BF=AE=E6=94=B9=E7=B4=A2=E5=BC=95=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E5=90=8E=E6=B2=A1=E6=9C=89=E5=90=8C=E6=AD=A5=E5=88=B0=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=8F=82=E6=95=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods/service/GoodsParamsService.java | 15 +++++++++++ .../serviceimpl/GoodsParamsServiceImpl.java | 27 ++++++++++++++++++- .../goods/ParameterManagerController.java | 10 ++++++- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/goods/service/GoodsParamsService.java b/framework/src/main/java/cn/lili/modules/goods/service/GoodsParamsService.java index c0ea0bd1..bd8195fc 100644 --- a/framework/src/main/java/cn/lili/modules/goods/service/GoodsParamsService.java +++ b/framework/src/main/java/cn/lili/modules/goods/service/GoodsParamsService.java @@ -23,6 +23,21 @@ public interface GoodsParamsService extends IService { */ void addParams(List paramList, String goodsId); + /** + * 更新商品参数是否索引 + * + * @param paramId 参数id + * @param isIndex 是否索引 + */ + void updateParametersIsIndex(String paramId, Integer isIndex); + + /** + * 根据参数id删除已经设置的商品参数 + * + * @param paramId 参数id + */ + void deleteByParamId(String paramId); + /** * 获取商品关联参数 * diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsParamsServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsParamsServiceImpl.java index 4fae7285..fc3d10ca 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsParamsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsParamsServiceImpl.java @@ -10,9 +10,10 @@ import cn.lili.modules.goods.service.CategoryParameterGroupService; import cn.lili.modules.goods.service.GoodsParamsService; import cn.lili.modules.goods.service.ParametersService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -60,6 +61,30 @@ public class GoodsParamsServiceImpl extends ServiceImpl updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.eq(GoodsParams::getParamId, paramId); + updateWrapper.set(GoodsParams::getIsIndex, isIndex); + this.update(updateWrapper); + } + + /** + * 根据参数id删除已经设置的商品参数 + * + * @param paramId 参数id + */ + @Override + public void deleteByParamId(String paramId) { + this.remove(new QueryWrapper().eq("param_id", paramId)); + } + @Override public List getGoodsParamsByGoodsId(String goodsId) { return this.list(new LambdaQueryWrapper().eq(GoodsParams::getGoodsId, goodsId)); diff --git a/manager-api/src/main/java/cn/lili/controller/goods/ParameterManagerController.java b/manager-api/src/main/java/cn/lili/controller/goods/ParameterManagerController.java index 2d746b23..8555e5c9 100644 --- a/manager-api/src/main/java/cn/lili/controller/goods/ParameterManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/goods/ParameterManagerController.java @@ -1,10 +1,11 @@ package cn.lili.controller.goods; import cn.lili.common.enums.ResultCode; -import cn.lili.common.exception.ServiceException; import cn.lili.common.enums.ResultUtil; +import cn.lili.common.exception.ServiceException; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.goods.entity.dos.Parameters; +import cn.lili.modules.goods.service.GoodsParamsService; import cn.lili.modules.goods.service.ParametersService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -28,6 +29,9 @@ public class ParameterManagerController { @Autowired private ParametersService parametersService; + @Autowired + private GoodsParamsService goodsParamsService; + @ApiOperation(value = "添加参数") @PostMapping public ResultMessage save(@Valid Parameters parameters) { @@ -44,6 +48,9 @@ public class ParameterManagerController { public ResultMessage update(@Valid Parameters parameters) { if (parametersService.updateById(parameters)) { + if (parameters.getIsIndex() != null) { + goodsParamsService.updateParametersIsIndex(parameters.getId(), parameters.getIsIndex()); + } return ResultUtil.data(parameters); } throw new ServiceException(ResultCode.PARAMETER_UPDATE_ERROR); @@ -54,6 +61,7 @@ public class ParameterManagerController { @DeleteMapping(value = "/{id}") public ResultMessage delById(@PathVariable String id) { parametersService.removeById(id); + goodsParamsService.deleteByParamId(id); return ResultUtil.success(); }