ProductBrand改造

pull/4/head
zhuyang 2021-10-07 23:30:17 +08:00
parent a01d66a318
commit b5b102d13f
4 changed files with 197 additions and 11 deletions

View File

@ -0,0 +1,20 @@
### /product-attr/page 成功(全部)
GET http://127.0.0.1:18083/management-api/product-attr/key/page?pageNo=1&pageSize=10
Content-Type: application/x-www-form-urlencoded
Authorization: Bearer yudaoyuanma
###
POST http://127.0.0.1:18083/management-api/product-brand/create
Content-Type: application/x-www-form-urlencoded
Authorization: Bearer yudaoyuanma
name=光明牌&description=光明牌电灯泡&status=1
###
GET http://127.0.0.1:18083/management-api/product-brand/get?productBrandId=3
Content-Type: application/x-www-form-urlencoded
Authorization: Bearer yudaoyuanma
###

View File

@ -7,9 +7,9 @@ import cn.iocoder.mall.managementweb.controller.product.vo.brand.ProductBrandPag
import cn.iocoder.mall.managementweb.controller.product.vo.brand.ProductBrandRespVO; import cn.iocoder.mall.managementweb.controller.product.vo.brand.ProductBrandRespVO;
import cn.iocoder.mall.managementweb.controller.product.vo.brand.ProductBrandUpdateReqVO; import cn.iocoder.mall.managementweb.controller.product.vo.brand.ProductBrandUpdateReqVO;
import cn.iocoder.mall.managementweb.convert.product.ProductBrandConvert; import cn.iocoder.mall.managementweb.convert.product.ProductBrandConvert;
import cn.iocoder.mall.productservice.rpc.brand.ProductBrandRpc; import cn.iocoder.mall.productservice.rpc.brand.ProductBrandFeign;
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandRespDTO; import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandRespDTO;
import org.apache.dubbo.config.annotation.Reference; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
@ -20,9 +20,8 @@ import java.util.List;
@Service @Service
public class ProductBrandManager { public class ProductBrandManager {
@Reference(version = "${dubbo.consumer.ProductBrandRpc.version}") @Autowired
private ProductBrandRpc productBrandRpc; ProductBrandFeign productBrandFeign;
/** /**
* *
* *
@ -30,7 +29,7 @@ public class ProductBrandManager {
* @return * @return
*/ */
public Integer createProductBrand(ProductBrandCreateReqVO createVO) { public Integer createProductBrand(ProductBrandCreateReqVO createVO) {
CommonResult<Integer> createProductBrandResult = productBrandRpc.createProductBrand(ProductBrandConvert.INSTANCE.convert(createVO)); CommonResult<Integer> createProductBrandResult = productBrandFeign.createProductBrand(ProductBrandConvert.INSTANCE.convert(createVO));
createProductBrandResult.checkError(); createProductBrandResult.checkError();
return createProductBrandResult.getData(); return createProductBrandResult.getData();
} }
@ -41,7 +40,7 @@ public class ProductBrandManager {
* @param updateVO VO * @param updateVO VO
*/ */
public void updateProductBrand(ProductBrandUpdateReqVO updateVO) { public void updateProductBrand(ProductBrandUpdateReqVO updateVO) {
CommonResult<Boolean> updateProductBrandResult = productBrandRpc.updateProductBrand(ProductBrandConvert.INSTANCE.convert(updateVO)); CommonResult<Boolean> updateProductBrandResult = productBrandFeign.updateProductBrand(ProductBrandConvert.INSTANCE.convert(updateVO));
updateProductBrandResult.checkError(); updateProductBrandResult.checkError();
} }
@ -51,7 +50,7 @@ public class ProductBrandManager {
* @param productBrandId * @param productBrandId
*/ */
public void deleteProductBrand(Integer productBrandId) { public void deleteProductBrand(Integer productBrandId) {
CommonResult<Boolean> deleteProductBrandResult = productBrandRpc.deleteProductBrand(productBrandId); CommonResult<Boolean> deleteProductBrandResult = productBrandFeign.deleteProductBrand(productBrandId);
deleteProductBrandResult.checkError(); deleteProductBrandResult.checkError();
} }
@ -62,7 +61,7 @@ public class ProductBrandManager {
* @return * @return
*/ */
public ProductBrandRespVO getProductBrand(Integer productBrandId) { public ProductBrandRespVO getProductBrand(Integer productBrandId) {
CommonResult<ProductBrandRespDTO> getProductBrandResult = productBrandRpc.getProductBrand(productBrandId); CommonResult<ProductBrandRespDTO> getProductBrandResult = productBrandFeign.getProductBrand(productBrandId);
getProductBrandResult.checkError(); getProductBrandResult.checkError();
return ProductBrandConvert.INSTANCE.convert(getProductBrandResult.getData()); return ProductBrandConvert.INSTANCE.convert(getProductBrandResult.getData());
} }
@ -74,7 +73,7 @@ public class ProductBrandManager {
* @return * @return
*/ */
public List<ProductBrandRespVO> listProductBrands(List<Integer> productBrandIds) { public List<ProductBrandRespVO> listProductBrands(List<Integer> productBrandIds) {
CommonResult<List<ProductBrandRespDTO>> listProductBrandResult = productBrandRpc.listProductBrands(productBrandIds); CommonResult<List<ProductBrandRespDTO>> listProductBrandResult = productBrandFeign.listProductBrands(productBrandIds);
listProductBrandResult.checkError(); listProductBrandResult.checkError();
return ProductBrandConvert.INSTANCE.convertList(listProductBrandResult.getData()); return ProductBrandConvert.INSTANCE.convertList(listProductBrandResult.getData());
} }
@ -86,7 +85,7 @@ public class ProductBrandManager {
* @return * @return
*/ */
public PageResult<ProductBrandRespVO> pageProductBrand(ProductBrandPageReqVO pageVO) { public PageResult<ProductBrandRespVO> pageProductBrand(ProductBrandPageReqVO pageVO) {
CommonResult<PageResult<ProductBrandRespDTO>> pageProductBrandResult = productBrandRpc.pageProductBrand(ProductBrandConvert.INSTANCE.convert(pageVO)); CommonResult<PageResult<ProductBrandRespDTO>> pageProductBrandResult = productBrandFeign.pageProductBrand(ProductBrandConvert.INSTANCE.convert(pageVO));
pageProductBrandResult.checkError(); pageProductBrandResult.checkError();
return ProductBrandConvert.INSTANCE.convertPage(pageProductBrandResult.getData()); return ProductBrandConvert.INSTANCE.convertPage(pageProductBrandResult.getData());
} }

View File

@ -0,0 +1,69 @@
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 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.List;
@FeignClient(value = "product-service")
public interface ProductBrandFeign {
/**
*
*
* @param createDTO DTO
* @return
*/
@PostMapping("/product/brand/createProductBrand")
CommonResult<Integer> createProductBrand(@RequestBody ProductBrandCreateReqDTO createDTO);
/**
*
*
* @param updateDTO DTO
*/
@PostMapping("/product/brand/updateProductBrand")
CommonResult<Boolean> updateProductBrand(@RequestBody ProductBrandUpdateReqDTO updateDTO);
/**
*
*
* @param productBrandId
*/
@GetMapping("/product/brand/deleteProductBrand")
CommonResult<Boolean> deleteProductBrand(@RequestParam("productBrandId") Integer productBrandId);
/**
*
*
* @param productBrandId
* @return
*/
@GetMapping("/product/brand/getProductBrand")
CommonResult<ProductBrandRespDTO> getProductBrand(@RequestParam("productBrandId")Integer productBrandId);
/**
*
*
* @param productBrandIds
* @return
*/
@GetMapping("/product/brand/listProductBrands")
CommonResult<List<ProductBrandRespDTO>> listProductBrands(@RequestParam("productBrandIds") List<Integer> productBrandIds);
/**
*
*
* @param pageDTO
* @return
*/
@PostMapping("/product/brand/pageProductBrand")
CommonResult<PageResult<ProductBrandRespDTO>> pageProductBrand(@RequestBody ProductBrandPageReqDTO pageDTO);
}

View File

@ -0,0 +1,98 @@
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.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 io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
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/brand")
@Api("商品品牌")
public class ProductBrandController {
@Autowired
private ProductBrandManager productBrandManager;
/**
*
*
* @param createDTO DTO
* @return
*/
@PostMapping("createProductBrand")
CommonResult<Integer> createProductBrand(@RequestBody ProductBrandCreateReqDTO createDTO){
return success(productBrandManager.createProductBrand(createDTO));
}
/**
*
*
* @param updateDTO DTO
*/
@PostMapping("updateProductBrand")
CommonResult<Boolean> updateProductBrand(@RequestBody ProductBrandUpdateReqDTO updateDTO){
productBrandManager.updateProductBrand(updateDTO);
return success(true);
}
/**
*
*
* @param productBrandId
*/
@GetMapping("deleteProductBrand")
CommonResult<Boolean> deleteProductBrand(@RequestParam("productBrandId") Integer productBrandId){
productBrandManager.deleteProductBrand(productBrandId);
return success(true);
}
/**
*
*
* @param productBrandId
* @return
*/
@GetMapping("getProductBrand")
CommonResult<ProductBrandRespDTO> getProductBrand(@RequestParam("productBrandId")Integer productBrandId){
return success(productBrandManager.getProductBrand(productBrandId));
}
/**
*
*
* @param productBrandIds
* @return
*/
@GetMapping("listProductBrands")
CommonResult<List<ProductBrandRespDTO>> listProductBrands(@RequestParam("productBrandIds") List<Integer> productBrandIds){
return success(productBrandManager.listProductBrands(productBrandIds));
}
/**
*
*
* @param pageDTO
* @return
*/
@PostMapping("pageProductBrand")
CommonResult<PageResult<ProductBrandRespDTO>> pageProductBrand(@RequestBody ProductBrandPageReqDTO pageDTO){
return success(productBrandManager.pageProductBrand(pageDTO));
}
}