ProductCategory改造
This commit is contained in:
parent
b5b102d13f
commit
50d8aac20f
@ -1,7 +1,15 @@
|
||||
### /product-category/tree 成功
|
||||
GET {{baseUrl}}/product-category/tree
|
||||
GET http://127.0.0.1:18083/management-api/product-category/tree
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer {{accessToken}}
|
||||
dubbo-tag: {{dubboTag}}
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
###
|
||||
|
||||
POST http://127.0.0.1:18083/management-api/product-category/create
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
pid=0&name=美食&description=吃喝拉撒&sort=7&status=1
|
||||
|
||||
|
||||
###
|
@ -6,11 +6,11 @@ import cn.iocoder.mall.managementweb.controller.product.vo.category.ProductCateg
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.category.ProductCategoryUpdateReqVO;
|
||||
import cn.iocoder.mall.managementweb.convert.product.ProductCategoryConvert;
|
||||
import cn.iocoder.mall.productservice.enums.category.ProductCategoryIdEnum;
|
||||
import cn.iocoder.mall.productservice.rpc.category.ProductCategoryRpc;
|
||||
import cn.iocoder.mall.productservice.rpc.category.ProductCategoryFeign;
|
||||
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryListQueryReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryRespDTO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
@ -22,10 +22,10 @@ import java.util.stream.Collectors;
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ProductCategoryManager {
|
||||
|
||||
|
||||
@Reference(version = "${dubbo.consumer.ProductCategoryRpc.version}")
|
||||
private ProductCategoryRpc productCategoryRpc;
|
||||
|
||||
@Autowired
|
||||
private ProductCategoryFeign productCategoryFeign;
|
||||
/**
|
||||
* 创建商品分类表
|
||||
*
|
||||
@ -33,7 +33,7 @@ public class ProductCategoryManager {
|
||||
* @return 商品分类表
|
||||
*/
|
||||
public Integer createProductCategory(ProductCategoryCreateReqVO createVO) {
|
||||
CommonResult<Integer> createProductCategoryResult = productCategoryRpc.createProductCategory(ProductCategoryConvert.INSTANCE.convert(createVO));
|
||||
CommonResult<Integer> createProductCategoryResult = productCategoryFeign.createProductCategory(ProductCategoryConvert.INSTANCE.convert(createVO));
|
||||
createProductCategoryResult.checkError();
|
||||
return createProductCategoryResult.getData();
|
||||
}
|
||||
@ -44,7 +44,7 @@ public class ProductCategoryManager {
|
||||
* @param updateVO 更新商品分类表 VO
|
||||
*/
|
||||
public void updateProductCategory(ProductCategoryUpdateReqVO updateVO) {
|
||||
CommonResult<Boolean> updateProductCategoryResult = productCategoryRpc.updateProductCategory(ProductCategoryConvert.INSTANCE.convert(updateVO));
|
||||
CommonResult<Boolean> updateProductCategoryResult = productCategoryFeign.updateProductCategory(ProductCategoryConvert.INSTANCE.convert(updateVO));
|
||||
updateProductCategoryResult.checkError();
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ public class ProductCategoryManager {
|
||||
* @param productCategoryId 商品分类表编号
|
||||
*/
|
||||
public void deleteProductCategory(Integer productCategoryId) {
|
||||
CommonResult<Boolean> deleteProductCategoryResult = productCategoryRpc.deleteProductCategory(productCategoryId);
|
||||
CommonResult<Boolean> deleteProductCategoryResult = productCategoryFeign.deleteProductCategory(productCategoryId);
|
||||
deleteProductCategoryResult.checkError();
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ public class ProductCategoryManager {
|
||||
*/
|
||||
public List<ProductCategoryTreeNodeRespVO> treeProductCategory() {
|
||||
// 获得商品分类全列表
|
||||
CommonResult<List<ProductCategoryRespDTO>> listProductCategories = productCategoryRpc.listProductCategories(new ProductCategoryListQueryReqDTO());
|
||||
CommonResult<List<ProductCategoryRespDTO>> listProductCategories = productCategoryFeign.listProductCategories(new ProductCategoryListQueryReqDTO());
|
||||
listProductCategories.checkError();
|
||||
// 构建菜单树
|
||||
return buildProductCategoryTree(listProductCategories.getData());
|
||||
|
@ -1,63 +0,0 @@
|
||||
package cn.iocoder.mall.productservice.rpc.brand;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandCreateReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandPageReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandRespDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandUpdateReqDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品品牌 Rpc 接口
|
||||
*/
|
||||
public interface ProductBrandRpc {
|
||||
|
||||
/**
|
||||
* 创建商品品牌
|
||||
*
|
||||
* @param createDTO 创建商品品牌 DTO
|
||||
* @return 商品品牌编号
|
||||
*/
|
||||
CommonResult<Integer> createProductBrand(ProductBrandCreateReqDTO createDTO);
|
||||
|
||||
/**
|
||||
* 更新商品品牌
|
||||
*
|
||||
* @param updateDTO 更新商品品牌 DTO
|
||||
*/
|
||||
CommonResult<Boolean> updateProductBrand(ProductBrandUpdateReqDTO updateDTO);
|
||||
|
||||
/**
|
||||
* 删除商品品牌
|
||||
*
|
||||
* @param productBrandId 商品品牌编号
|
||||
*/
|
||||
CommonResult<Boolean> deleteProductBrand(Integer productBrandId);
|
||||
|
||||
/**
|
||||
* 获得商品品牌
|
||||
*
|
||||
* @param productBrandId 商品品牌编号
|
||||
* @return 商品品牌
|
||||
*/
|
||||
CommonResult<ProductBrandRespDTO> getProductBrand(Integer productBrandId);
|
||||
|
||||
/**
|
||||
* 获得商品品牌列表
|
||||
*
|
||||
* @param productBrandIds 商品品牌编号列表
|
||||
* @return 商品品牌列表
|
||||
*/
|
||||
CommonResult<List<ProductBrandRespDTO>> listProductBrands(List<Integer> productBrandIds);
|
||||
|
||||
/**
|
||||
* 获得商品品牌分页
|
||||
*
|
||||
* @param pageDTO 商品品牌分页查询
|
||||
* @return 商品品牌分页结果
|
||||
*/
|
||||
CommonResult<PageResult<ProductBrandRespDTO>> pageProductBrand(ProductBrandPageReqDTO pageDTO);
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package cn.iocoder.mall.productservice.rpc.category;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryCreateReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryListQueryReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryRespDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryUpdateReqDTO;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@FeignClient(value = "product-service")
|
||||
public interface ProductCategoryFeign {
|
||||
|
||||
/**
|
||||
* 创建商品分类
|
||||
*
|
||||
* @param createDTO 创建商品分类 DTO
|
||||
* @return 商品分类编号
|
||||
*/
|
||||
@PostMapping("/product/category/createProductCategory")
|
||||
CommonResult<Integer> createProductCategory(@RequestBody ProductCategoryCreateReqDTO createDTO);
|
||||
/**
|
||||
* 更新商品分类
|
||||
*
|
||||
* @param updateDTO 更新商品分类 DTO
|
||||
*/
|
||||
@PostMapping("/product/category/updateProductCategory")
|
||||
CommonResult<Boolean> updateProductCategory(@RequestBody ProductCategoryUpdateReqDTO updateDTO);
|
||||
|
||||
/**
|
||||
* 删除商品分类
|
||||
*
|
||||
* @param productCategoryId 商品分类编号
|
||||
*/
|
||||
@GetMapping("/product/category/deleteProductCategory")
|
||||
CommonResult<Boolean> deleteProductCategory(@RequestParam("productCategoryId") Integer productCategoryId);
|
||||
/**
|
||||
* 获得商品分类
|
||||
*
|
||||
* @param productCategoryId 商品分类编号
|
||||
* @return 商品分类
|
||||
*/
|
||||
@GetMapping("/product/category/getProductCategory")
|
||||
CommonResult<ProductCategoryRespDTO> getProductCategory(@RequestParam("productCategoryId")Integer productCategoryId);
|
||||
/**
|
||||
* 获得商品分类列表
|
||||
*
|
||||
* @param productCategoryIds 商品分类编号列表
|
||||
* @return 商品分类列表
|
||||
*/
|
||||
@GetMapping("/product/category/listProductCategoriesByIds")
|
||||
CommonResult<List<ProductCategoryRespDTO>> listProductCategoriesByIds(@RequestParam("productCategoryIds")Collection<Integer> productCategoryIds);
|
||||
|
||||
/**
|
||||
* 获得符合条件的商品分类列表
|
||||
*
|
||||
* @return 商品分类列表
|
||||
*/
|
||||
@PostMapping("/product/category/listProductCategories")
|
||||
CommonResult<List<ProductCategoryRespDTO>> listProductCategories(@RequestBody ProductCategoryListQueryReqDTO listQueryReqDTO);
|
||||
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
package cn.iocoder.mall.productservice.rpc.category;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryCreateReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryListQueryReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryRespDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryUpdateReqDTO;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品分类 Rpc 接口
|
||||
*/
|
||||
public interface ProductCategoryRpc {
|
||||
|
||||
/**
|
||||
* 创建商品分类
|
||||
*
|
||||
* @param createDTO 创建商品分类 DTO
|
||||
* @return 商品分类编号
|
||||
*/
|
||||
CommonResult<Integer> createProductCategory(ProductCategoryCreateReqDTO createDTO);
|
||||
|
||||
/**
|
||||
* 更新商品分类
|
||||
*
|
||||
* @param updateDTO 更新商品分类 DTO
|
||||
*/
|
||||
CommonResult<Boolean> updateProductCategory(ProductCategoryUpdateReqDTO updateDTO);
|
||||
|
||||
/**
|
||||
* 删除商品分类
|
||||
*
|
||||
* @param productCategoryId 商品分类编号
|
||||
*/
|
||||
CommonResult<Boolean> deleteProductCategory(Integer productCategoryId);
|
||||
|
||||
/**
|
||||
* 获得商品分类
|
||||
*
|
||||
* @param productCategoryId 商品分类编号
|
||||
* @return 商品分类
|
||||
*/
|
||||
CommonResult<ProductCategoryRespDTO> getProductCategory(Integer productCategoryId);
|
||||
|
||||
/**
|
||||
* 获得商品分类列表
|
||||
*
|
||||
* @param productCategoryIds 商品分类编号列表
|
||||
* @return 商品分类列表
|
||||
*/
|
||||
CommonResult<List<ProductCategoryRespDTO>> listProductCategories(Collection<Integer> productCategoryIds);
|
||||
|
||||
/**
|
||||
* 获得符合条件的商品分类列表
|
||||
*
|
||||
* @return 商品分类列表
|
||||
*/
|
||||
CommonResult<List<ProductCategoryRespDTO>> listProductCategories(ProductCategoryListQueryReqDTO listQueryReqDTO);
|
||||
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
package cn.iocoder.mall.productservice.controller;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.productservice.manager.brand.ProductBrandManager;
|
||||
import cn.iocoder.mall.productservice.manager.category.ProductCategoryManager;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandCreateReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandPageReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandRespDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandUpdateReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryCreateReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryListQueryReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryRespDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryUpdateReqDTO;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* Title:
|
||||
* Description:
|
||||
*
|
||||
* @author zhuyang
|
||||
* @version 1.0 2021/10/7
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/product/category")
|
||||
@Api("商品品牌")
|
||||
public class ProductCategoryController {
|
||||
@Autowired
|
||||
private ProductCategoryManager productCategoryManager;
|
||||
|
||||
|
||||
/**
|
||||
* 创建商品分类
|
||||
*
|
||||
* @param createDTO 创建商品分类 DTO
|
||||
* @return 商品分类编号
|
||||
*/
|
||||
@PostMapping("createProductCategory")
|
||||
CommonResult<Integer> createProductCategory(@RequestBody ProductCategoryCreateReqDTO createDTO){
|
||||
return success(productCategoryManager.createProductCategory(createDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品分类
|
||||
*
|
||||
* @param updateDTO 更新商品分类 DTO
|
||||
*/
|
||||
@PostMapping("updateProductCategory")
|
||||
CommonResult<Boolean> updateProductCategory(@RequestBody ProductCategoryUpdateReqDTO updateDTO){
|
||||
productCategoryManager.updateProductCategory(updateDTO);
|
||||
return success(true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品分类
|
||||
*
|
||||
* @param productCategoryId 商品分类编号
|
||||
*/
|
||||
@GetMapping("deleteProductCategory")
|
||||
CommonResult<Boolean> deleteProductCategory(@RequestParam("productCategoryId") Integer productCategoryId){
|
||||
productCategoryManager.deleteProductCategory(productCategoryId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得商品分类
|
||||
*
|
||||
* @param productCategoryId 商品分类编号
|
||||
* @return 商品分类
|
||||
*/
|
||||
@GetMapping("getProductCategory")
|
||||
CommonResult<ProductCategoryRespDTO> getProductCategory(@RequestParam("productCategoryId")Integer productCategoryId){
|
||||
return success(productCategoryManager.getProductCategory(productCategoryId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得商品分类列表
|
||||
*
|
||||
* @param productCategoryIds 商品分类编号列表
|
||||
* @return 商品分类列表
|
||||
*/
|
||||
@GetMapping("listProductCategoriesByIds")
|
||||
CommonResult<List<ProductCategoryRespDTO>> listProductCategoriesByIds(@RequestParam("productCategoryIds")Collection<Integer> productCategoryIds){
|
||||
return success(productCategoryManager.listProductCategories(productCategoryIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得符合条件的商品分类列表
|
||||
*
|
||||
* @return 商品分类列表
|
||||
*/
|
||||
@PostMapping("listProductCategories")
|
||||
CommonResult<List<ProductCategoryRespDTO>> listProductCategories(@RequestBody ProductCategoryListQueryReqDTO listQueryReqDTO){
|
||||
return success(productCategoryManager.listProductCategories(listQueryReqDTO));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
package cn.iocoder.mall.productservice.rpc.brand;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.productservice.manager.brand.ProductBrandManager;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandCreateReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandPageReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandRespDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandUpdateReqDTO;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 商品品牌 Rpc 实现类
|
||||
*/
|
||||
@DubboService
|
||||
public class ProductBrandRpcImpl implements ProductBrandRpc {
|
||||
|
||||
@Autowired
|
||||
private ProductBrandManager productBrandManager;
|
||||
|
||||
@Override
|
||||
public CommonResult<Integer> createProductBrand(ProductBrandCreateReqDTO createDTO) {
|
||||
return success(productBrandManager.createProductBrand(createDTO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> updateProductBrand(ProductBrandUpdateReqDTO updateDTO) {
|
||||
productBrandManager.updateProductBrand(updateDTO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> deleteProductBrand(Integer productBrandId) {
|
||||
productBrandManager.deleteProductBrand(productBrandId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<ProductBrandRespDTO> getProductBrand(Integer productBrandId) {
|
||||
return success(productBrandManager.getProductBrand(productBrandId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<List<ProductBrandRespDTO>> listProductBrands(List<Integer> productBrandIds) {
|
||||
return success(productBrandManager.listProductBrands(productBrandIds));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<PageResult<ProductBrandRespDTO>> pageProductBrand(ProductBrandPageReqDTO pageDTO) {
|
||||
return success(productBrandManager.pageProductBrand(pageDTO));
|
||||
}
|
||||
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
package cn.iocoder.mall.productservice.rpc.category;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.productservice.manager.category.ProductCategoryManager;
|
||||
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryCreateReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryListQueryReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryRespDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryUpdateReqDTO;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 商品分类 Rpc 实现类
|
||||
*/
|
||||
@DubboService
|
||||
public class ProductCategoryRpcImpl implements ProductCategoryRpc {
|
||||
|
||||
@Autowired
|
||||
private ProductCategoryManager productCategoryManager;
|
||||
|
||||
@Override
|
||||
public CommonResult<Integer> createProductCategory(ProductCategoryCreateReqDTO createDTO) {
|
||||
return success(productCategoryManager.createProductCategory(createDTO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> updateProductCategory(ProductCategoryUpdateReqDTO updateDTO) {
|
||||
productCategoryManager.updateProductCategory(updateDTO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> deleteProductCategory(Integer productCategoryId) {
|
||||
productCategoryManager.deleteProductCategory(productCategoryId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<ProductCategoryRespDTO> getProductCategory(Integer productCategoryId) {
|
||||
return success(productCategoryManager.getProductCategory(productCategoryId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<List<ProductCategoryRespDTO>> listProductCategories(Collection<Integer> productCategoryIds) {
|
||||
return success(productCategoryManager.listProductCategories(productCategoryIds));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<List<ProductCategoryRespDTO>> listProductCategories(ProductCategoryListQueryReqDTO listQueryReqDTO) {
|
||||
return success(productCategoryManager.listProductCategories(listQueryReqDTO));
|
||||
}
|
||||
|
||||
}
|
@ -3,7 +3,7 @@ package cn.iocoder.mall.searchservice.manager.product;
|
||||
import cn.iocoder.common.framework.util.CollectionUtils;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.productservice.rpc.category.ProductCategoryRpc;
|
||||
import cn.iocoder.mall.productservice.rpc.category.ProductCategoryFeign;
|
||||
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryRespDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.sku.ProductSkuRpc;
|
||||
import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO;
|
||||
@ -35,9 +35,9 @@ public class SearchProductManager {
|
||||
|
||||
@DubboReference(version = "${dubbo.consumer.ProductSkuRpc.version}")
|
||||
private ProductSkuRpc productSkuRpc;
|
||||
@DubboReference(version = "${dubbo.consumer.ProductCategoryRpc.version}")
|
||||
private ProductCategoryRpc productCategoryRpc;
|
||||
|
||||
@Autowired
|
||||
private ProductCategoryFeign productCategoryFeign;
|
||||
@Autowired
|
||||
private ProductSpuFeign productSpuFeign;
|
||||
|
||||
@ -110,7 +110,7 @@ public class SearchProductManager {
|
||||
}
|
||||
// 获得商品分类
|
||||
CommonResult<ProductCategoryRespDTO> getProductCategoryResult =
|
||||
productCategoryRpc.getProductCategory(productSpuResult.getData().getCid());
|
||||
productCategoryFeign.getProductCategory(productSpuResult.getData().getCid());
|
||||
getProductCategoryResult.checkError();
|
||||
if (getProductCategoryResult.getData() == null) {
|
||||
log.error("[saveProduct][商品 SPU({}) 的分类({}) 不存在]", id, productSpuResult.getData().getCid());
|
||||
|
@ -2,12 +2,12 @@ package cn.iocoder.mall.shopweb.service.product;
|
||||
|
||||
import cn.iocoder.common.framework.enums.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.productservice.rpc.category.ProductCategoryRpc;
|
||||
import cn.iocoder.mall.productservice.rpc.category.ProductCategoryFeign;
|
||||
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryListQueryReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryRespDTO;
|
||||
import cn.iocoder.mall.shopweb.controller.product.vo.category.ProductCategoryRespVO;
|
||||
import cn.iocoder.mall.shopweb.convert.product.ProductCategoryConvert;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@ -20,11 +20,12 @@ import java.util.List;
|
||||
@Validated
|
||||
public class ProductCategoryManager {
|
||||
|
||||
@DubboReference(version = "${dubbo.consumer.ProductCategoryRpc.version}")
|
||||
private ProductCategoryRpc productCategoryRpc;
|
||||
|
||||
@Autowired
|
||||
private ProductCategoryFeign productCategoryFeign;
|
||||
|
||||
public List<ProductCategoryRespVO> listProductCategories(Integer pid) {
|
||||
CommonResult<List<ProductCategoryRespDTO>> listProductCategoriesResult = productCategoryRpc.listProductCategories(
|
||||
CommonResult<List<ProductCategoryRespDTO>> listProductCategoriesResult = productCategoryFeign.listProductCategories(
|
||||
new ProductCategoryListQueryReqDTO().setPid(pid).setStatus(CommonStatusEnum.ENABLE.getValue()));
|
||||
listProductCategoriesResult.checkError();
|
||||
return ProductCategoryConvert.INSTANCE.convertList(listProductCategoriesResult.getData());
|
||||
|
@ -4,7 +4,7 @@ import cn.iocoder.common.framework.util.CollectionUtils;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.productservice.enums.spu.ProductSpuDetailFieldEnum;
|
||||
import cn.iocoder.mall.productservice.rpc.category.ProductCategoryRpc;
|
||||
import cn.iocoder.mall.productservice.rpc.category.ProductCategoryFeign;
|
||||
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryRespDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.spu.ProductSpuFeign;
|
||||
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuDetailRespDTO;
|
||||
@ -37,9 +37,9 @@ public class ProductSpuManager {
|
||||
@DubboReference(version = "${dubbo.consumer.SearchProductRpc.version}")
|
||||
private SearchProductRpc searchProductRpc;
|
||||
|
||||
@DubboReference(version = "${dubbo.consumer.ProductCategoryRpc.version}")
|
||||
private ProductCategoryRpc productCategoryRpc;
|
||||
|
||||
@Autowired
|
||||
private ProductCategoryFeign productCategoryFeign;
|
||||
@Autowired
|
||||
private ProductSpuFeign productSpuFeign;
|
||||
|
||||
@ -62,7 +62,7 @@ public class ProductSpuManager {
|
||||
conditionRespVO.setCategories(Collections.emptyList());
|
||||
} else {
|
||||
CommonResult<List<ProductCategoryRespDTO>> listProductCategoriesResult =
|
||||
productCategoryRpc.listProductCategories(getSearchProductConditionResult.getData().getCids());
|
||||
productCategoryFeign.listProductCategoriesByIds(getSearchProductConditionResult.getData().getCids());
|
||||
listProductCategoriesResult.checkError();
|
||||
conditionRespVO.setCategories(ProductSpuConvert.INSTANCE.convertList(listProductCategoriesResult.getData()));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user