From 911df9742290ac436b5ed207694621d09a8fe1f0 Mon Sep 17 00:00:00 2001 From: Chopper Date: Tue, 22 Jun 2021 18:58:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E8=A7=84=E6=A0=BC=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods/entity/dto/SpecificationSearchParams.java | 6 +++--- .../goods/serviceimpl/SpecificationServiceImpl.java | 7 +++---- .../modules/order/cart/service/CartServiceImpl.java | 4 ++-- .../goods/CategorySpecificationManagerController.java | 11 +++++++---- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dto/SpecificationSearchParams.java b/framework/src/main/java/cn/lili/modules/goods/entity/dto/SpecificationSearchParams.java index 0b93badf..6160c66c 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dto/SpecificationSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dto/SpecificationSearchParams.java @@ -15,8 +15,8 @@ import lombok.Data; public class SpecificationSearchParams { - @ApiModelProperty(value = "规格名") - private String specName; + @ApiModelProperty(value = "规格id") + private String specId; @ApiModelProperty(value = "绑定分类") private String categoryPath; @@ -26,7 +26,7 @@ public class SpecificationSearchParams { public QueryWrapper queryWrapper() { QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.like(StringUtils.isNotEmpty(specName), "spec_name", specName); + queryWrapper.eq(StringUtils.isNotEmpty(specId), "spec_id", specId); queryWrapper.eq(deleteFlag != null, "delete_flag", deleteFlag); return queryWrapper; } diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/SpecificationServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/SpecificationServiceImpl.java index a74aa5df..cc99580b 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/SpecificationServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/SpecificationServiceImpl.java @@ -50,12 +50,11 @@ public class SpecificationServiceImpl extends ServiceImpl getSpecList(String specName) { + public List getSpecList(String specId) { QueryWrapper queryWrapper = new QueryWrapper(); - queryWrapper.eq(StringUtils.isNotEmpty(specName), "s.spec_name", specName); + queryWrapper.eq(StringUtils.isNotEmpty(specId), "s.spec_id", specId); queryWrapper.orderByDesc("s.create_time"); - queryWrapper.groupBy("s.id"); return this.baseMapper.findSpecList(queryWrapper); } @@ -103,7 +102,7 @@ public class SpecificationServiceImpl extends ServiceImpl getSpecificationPage(SpecificationSearchParams searchParams, PageVO pageVo) { - List specList = this.getSpecList(searchParams.getSpecName()); + List specList = this.getSpecList(searchParams.getSpecId()); IPage page = new Page<>(pageVo.getPageNumber(), pageVo.getPageSize(), specList.size()); page.setRecords(PageUtil.listToPage(pageVo, specList)); return page; diff --git a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java index 4739eb25..4ccfd098 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java @@ -150,7 +150,7 @@ public class CartServiceImpl implements CartService { tradeDTO.setPlatformCoupon(null); this.resetTradeDTO(tradeDTO); } catch (ServiceException se) { - throw se; + throw se; } catch (Exception e) { log.error("购物车渲染异常", e); throw new ServiceException(errorMessage); @@ -511,7 +511,7 @@ public class CartServiceImpl implements CartService { tradeDTO.setStoreRemark(tradeParams.getRemark()); tradeDTO.setParentOrderSn(tradeParams.getParentOrderSn()); //订单无收货地址校验 - if(tradeDTO.getMemberAddress()==null){ + if (tradeDTO.getMemberAddress() == null) { throw new ServiceException(ResultCode.MEMBER_ADDRESS_NOT_EXIST); } //将购物车信息写入缓存,后续逻辑调用校验 diff --git a/manager-api/src/main/java/cn/lili/controller/goods/CategorySpecificationManagerController.java b/manager-api/src/main/java/cn/lili/controller/goods/CategorySpecificationManagerController.java index 4dd65c6f..920a6d7f 100644 --- a/manager-api/src/main/java/cn/lili/controller/goods/CategorySpecificationManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/goods/CategorySpecificationManagerController.java @@ -1,6 +1,5 @@ package cn.lili.controller.goods; -import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.ResultUtil; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.goods.entity.dos.CategorySpecification; @@ -16,6 +15,7 @@ import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.util.ArrayList; import java.util.List; /** @@ -68,9 +68,12 @@ public class CategorySpecificationManagerController { //删除分类规格绑定信息 this.categorySpecificationService.remove(new QueryWrapper().eq("category_id", categoryId)); //绑定规格信息 - for (String specId : categorySpecs) { - CategorySpecification categoryBrand = new CategorySpecification(categoryId, specId); - categorySpecificationService.save(categoryBrand); + if (categorySpecs != null && categorySpecs.length > 0) { + List categorySpecifications = new ArrayList<>(); + for (String categorySpec : categorySpecs) { + categorySpecifications.add( new CategorySpecification(categoryId, categorySpec)); + } + categorySpecificationService.saveBatch(categorySpecifications); } return ResultUtil.success(); }