diff --git a/src/main/java/com/hxtec/polaris/controller/ProductManageController.java b/src/main/java/com/hxtec/polaris/controller/ProductManageController.java index ebeaa1fcfe77c73a944cef91a5b36351a8fbbe91..911526640389631cb791fa4837800159a10e5b55 100644 --- a/src/main/java/com/hxtec/polaris/controller/ProductManageController.java +++ b/src/main/java/com/hxtec/polaris/controller/ProductManageController.java @@ -76,19 +76,6 @@ public class ProductManageController { return Result.ok("success"); } - /** - * 根据分类获取spu信息 - * @param catalogId - * @return - */ - @GetMapping("spuList") - @ApiOperation(value="根据分类获取spu信息", notes="根据分类获取spu信息") - @ResponseBody - public Result spuList(String catalogId){ - List pmsProductInfos = spuService.spuList(catalogId); - return Result.ok(pmsProductInfos); - } - /** * 根据二级分类获取三级分类 @@ -151,8 +138,8 @@ public class ProductManageController { @GetMapping("getSpuListInfo") @ApiOperation(value="spu列表信息", notes="spu列表信息") @ResponseBody - public Result spuInfoList(Integer currentPage,Integer pageSize,String productName){ - PageInfo spuList=spuService.getSpuListInfo(currentPage,pageSize,productName); + public Result spuInfoList(Integer currentPage,Integer pageSize,String productName,String productCode,String catalogId){ + PageInfo spuList=spuService.getSpuListInfo(currentPage,pageSize,productName,productCode,catalogId); return Result.ok(spuList); } diff --git a/src/main/java/com/hxtec/polaris/service/ProductBaseService.java b/src/main/java/com/hxtec/polaris/service/ProductBaseService.java index 974d7f291fbdd8e2d50d2cd25ef6dc049499b906..025703c9fb8cf3d1a6d70df97df9e54bb8861278 100644 --- a/src/main/java/com/hxtec/polaris/service/ProductBaseService.java +++ b/src/main/java/com/hxtec/polaris/service/ProductBaseService.java @@ -22,13 +22,6 @@ public interface ProductBaseService { */ void saveSpuInfo(ShopProductBase pmsProductInfo); - /** - * 显示分类列表下的spu - * @param catalogId - * @return - */ - List spuList(String catalogId); - /** * 获取spu图片列表 * @param spuId @@ -36,5 +29,7 @@ public interface ProductBaseService { */ List spuImageList(String spuId); - PageInfo getSpuListInfo(Integer currentPage, Integer pageSize, String productName); + PageInfo getSpuListInfo(Integer currentPage, Integer pageSize, String productName,String productCode,String catalogId); + + } diff --git a/src/main/java/com/hxtec/polaris/service/impl/ProductBaseServiceImpl.java b/src/main/java/com/hxtec/polaris/service/impl/ProductBaseServiceImpl.java index e118854420603e923f02f1f366b04eb726121f0b..ecc2e747fdd1c68fab75e7263dbeddc3dfe54e02 100644 --- a/src/main/java/com/hxtec/polaris/service/impl/ProductBaseServiceImpl.java +++ b/src/main/java/com/hxtec/polaris/service/impl/ProductBaseServiceImpl.java @@ -8,6 +8,7 @@ import com.hxtec.polaris.mapper.ShopProductImageMapper; import com.hxtec.polaris.mapper.ShopProductSaleAttrMapper; import com.hxtec.polaris.mapper.ShopProductSaleAttrValueMapper; import com.hxtec.polaris.service.ProductBaseService; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import tk.mybatis.mapper.entity.Example; @@ -76,13 +77,6 @@ public class ProductBaseServiceImpl implements ProductBaseService { } - @Override - public List spuList(String catalogId) { - Example example=new Example(ShopProductVariant.class); - example.createCriteria().andEqualTo("categoryId",catalogId); - return spuMapper.selectByExample(example); - } - @Override public List spuImageList(String spuId) { Example example=new Example(ShopProductImage.class); @@ -91,12 +85,15 @@ public class ProductBaseServiceImpl implements ProductBaseService { } @Override - public PageInfo getSpuListInfo(Integer currentPage, Integer pageSize, String productName) { + public PageInfo getSpuListInfo(Integer currentPage, Integer pageSize, String productName,String productCode,String catalogId) { Example example=new Example(ShopProductBase.class); example.createCriteria() - .andLike("name",productName!=null?"%"+productName+"%":null); + .andEqualTo("categoryId",StringUtils.isNotEmpty(catalogId) ?catalogId:null) + .andLike("name", StringUtils.isNotEmpty(productName) ?"%"+productName+"%":null) + .andEqualTo("spu",StringUtils.isNotEmpty(productCode)?productCode:null); PageHelper.startPage(currentPage,pageSize); PageInfo pageInfo=new PageInfo<>(spuMapper.selectByExample(example)); return pageInfo; } + }