ProductAttr改造

pull/4/head
zhuyang 2021-10-07 23:14:30 +08:00
parent 4f50845b66
commit a01d66a318
10 changed files with 255 additions and 174 deletions

View File

@ -7,7 +7,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc.spu"})
@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc"})
public class ManagementWebApplication {
public static void main(String[] args) {

View File

@ -1,7 +1,21 @@
### /product-attr/page 成功(全部)
GET {{baseUrl}}/product-attr/key/page?pageNo=1&pageSize=10
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 {{accessToken}}
Authorization: Bearer yudaoyuanma
###
POST http://127.0.0.1:18083/management-api/product-attr/key/create
Content-Type: application/x-www-form-urlencoded
Authorization: Bearer yudaoyuanma
name=桶&status=1
###
POST http://127.0.0.1:18083/management-api/product-attr/value/create
Content-Type: application/x-www-form-urlencoded
Authorization: Bearer yudaoyuanma
attrKeyId=12&name=大桶&status=1
###

View File

@ -4,10 +4,10 @@ import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.managementweb.controller.product.vo.attr.*;
import cn.iocoder.mall.managementweb.convert.product.ProductAttrConvert;
import cn.iocoder.mall.productservice.rpc.attr.ProductAttrRpc;
import cn.iocoder.mall.productservice.rpc.attr.ProductAttrFeign;
import cn.iocoder.mall.productservice.rpc.attr.dto.ProductAttrKeyRespDTO;
import cn.iocoder.mall.productservice.rpc.attr.dto.ProductAttrValueRespDTO;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@ -18,9 +18,8 @@ import java.util.List;
@Service
public class ProductAttrKeyManager {
@DubboReference(version = "${dubbo.consumer.ProductAttrRpc.version}")
private ProductAttrRpc productAttrKeyRpc;
@Autowired
private ProductAttrFeign productAttrFeign;
/**
*
*
@ -28,7 +27,7 @@ public class ProductAttrKeyManager {
* @return
*/
public Integer createProductAttrKey(ProductAttrKeyCreateReqVO createVO) {
CommonResult<Integer> createProductAttrKeyResult = productAttrKeyRpc.createProductAttrKey(
CommonResult<Integer> createProductAttrKeyResult = productAttrFeign.createProductAttrKey(
ProductAttrConvert.INSTANCE.convert(createVO));
createProductAttrKeyResult.checkError();
return createProductAttrKeyResult.getData();
@ -40,7 +39,7 @@ public class ProductAttrKeyManager {
* @param updateVO VO
*/
public void updateProductAttrKey(ProductAttrKeyUpdateReqVO updateVO) {
CommonResult<Boolean> updateProductAttrKeyResult = productAttrKeyRpc.updateProductAttrKey(
CommonResult<Boolean> updateProductAttrKeyResult = productAttrFeign.updateProductAttrKey(
ProductAttrConvert.INSTANCE.convert(updateVO));
updateProductAttrKeyResult.checkError();
}
@ -52,7 +51,7 @@ public class ProductAttrKeyManager {
* @return
*/
public ProductAttrKeyRespVO getProductAttrKey(Integer productAttrKeyId) {
CommonResult<ProductAttrKeyRespDTO> getProductAttrKeyResult = productAttrKeyRpc.getProductAttrKey(productAttrKeyId);
CommonResult<ProductAttrKeyRespDTO> getProductAttrKeyResult = productAttrFeign.getProductAttrKey(productAttrKeyId);
getProductAttrKeyResult.checkError();
return ProductAttrConvert.INSTANCE.convert(getProductAttrKeyResult.getData());
}
@ -64,7 +63,7 @@ public class ProductAttrKeyManager {
* @return
*/
public List<ProductAttrKeyRespVO> listProductAttrKeys(List<Integer> productAttrKeyIds) {
CommonResult<List<ProductAttrKeyRespDTO>> listProductAttrKeyResult = productAttrKeyRpc.listProductAttrKeys(productAttrKeyIds);
CommonResult<List<ProductAttrKeyRespDTO>> listProductAttrKeyResult = productAttrFeign.listProductAttrKeys(productAttrKeyIds);
listProductAttrKeyResult.checkError();
return ProductAttrConvert.INSTANCE.convertList(listProductAttrKeyResult.getData());
}
@ -76,7 +75,7 @@ public class ProductAttrKeyManager {
* @return
*/
public PageResult<ProductAttrKeyRespVO> pageProductAttrKey(ProductAttrKeyPageReqVO pageVO) {
CommonResult<PageResult<ProductAttrKeyRespDTO>> pageProductAttrKeyResult = productAttrKeyRpc.pageProductAttrKey(
CommonResult<PageResult<ProductAttrKeyRespDTO>> pageProductAttrKeyResult = productAttrFeign.pageProductAttrKey(
ProductAttrConvert.INSTANCE.convert(pageVO));
pageProductAttrKeyResult.checkError();
return ProductAttrConvert.INSTANCE.convertPage(pageProductAttrKeyResult.getData());
@ -89,7 +88,7 @@ public class ProductAttrKeyManager {
* @return
*/
public Integer createProductAttrValue(ProductAttrValueCreateReqVO createVO) {
CommonResult<Integer> createProductAttrValueResult = productAttrKeyRpc.createProductAttrValue(
CommonResult<Integer> createProductAttrValueResult = productAttrFeign.createProductAttrValue(
ProductAttrConvert.INSTANCE.convert(createVO));
createProductAttrValueResult.checkError();
return createProductAttrValueResult.getData();
@ -101,7 +100,7 @@ public class ProductAttrKeyManager {
* @param updateVO VO
*/
public void updateProductAttrValue(ProductAttrValueUpdateReqVO updateVO) {
CommonResult<Boolean> updateProductAttrValueResult = productAttrKeyRpc.updateProductAttrValue(
CommonResult<Boolean> updateProductAttrValueResult = productAttrFeign.updateProductAttrValue(
ProductAttrConvert.INSTANCE.convert(updateVO));
updateProductAttrValueResult.checkError();
}
@ -113,7 +112,7 @@ public class ProductAttrKeyManager {
* @return
*/
public ProductAttrValueRespVO getProductAttrValue(Integer productAttrValueId) {
CommonResult<ProductAttrValueRespDTO> getProductAttrValueResult = productAttrKeyRpc.getProductAttrValue(productAttrValueId);
CommonResult<ProductAttrValueRespDTO> getProductAttrValueResult = productAttrFeign.getProductAttrValue(productAttrValueId);
getProductAttrValueResult.checkError();
return ProductAttrConvert.INSTANCE.convert(getProductAttrValueResult.getData());
}
@ -125,7 +124,7 @@ public class ProductAttrKeyManager {
* @return
*/
public List<ProductAttrValueRespVO> listProductAttrValues(ProductAttrValueListQueryReqVO queryReqVO) {
CommonResult<List<ProductAttrValueRespDTO>> listProductAttrValueResult = productAttrKeyRpc.listProductAttrValues(
CommonResult<List<ProductAttrValueRespDTO>> listProductAttrValueResult = productAttrFeign.listProductAttrValues(
ProductAttrConvert.INSTANCE.convert(queryReqVO));
listProductAttrValueResult.checkError();
return ProductAttrConvert.INSTANCE.convertList02(listProductAttrValueResult.getData());

View File

@ -0,0 +1,94 @@
package cn.iocoder.mall.productservice.rpc.attr;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.productservice.rpc.attr.dto.*;
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;
/**
* Rpc
*/
@FeignClient(value = "product-service")
public interface ProductAttrFeign {
/**
*
*
* @param createDTO DTO
* @return
*/
@PostMapping(value = "/product/attr/createProductAttrKey")
CommonResult<Integer> createProductAttrKey(@RequestBody ProductAttrKeyCreateReqDTO createDTO);
/**
*
*
* @param updateDTO DTO
*/
@PostMapping(value = "/product/attr/updateProductAttrKey")
CommonResult<Boolean> updateProductAttrKey(@RequestBody ProductAttrKeyUpdateReqDTO updateDTO);
/**
*
*
* @param productAttrKeyId
* @return
*/
@GetMapping("/product/attr/getProductAttrKey")
CommonResult<ProductAttrKeyRespDTO> getProductAttrKey(@RequestParam("productAttrKeyId") Integer productAttrKeyId);
/**
*
*
* @param productAttrKeyIds
* @return
*/
@GetMapping("/product/attr/listProductAttrKeys")
CommonResult<List<ProductAttrKeyRespDTO>> listProductAttrKeys(@RequestParam("productAttrKeyIds") List<Integer> productAttrKeyIds);
/**
*
*
* @param pageDTO
* @return
*/
@PostMapping("/product/attr/pageProductAttrKey")
CommonResult<PageResult<ProductAttrKeyRespDTO>> pageProductAttrKey(@RequestBody ProductAttrKeyPageReqDTO pageDTO);
/**
*
*
* @param createDTO DTO
* @return
*/
@PostMapping("/product/attr/createProductAttrValue")
CommonResult<Integer> createProductAttrValue(@RequestBody ProductAttrValueCreateReqDTO createDTO);
/**
*
*
* @param updateDTO DTO
*/
@PostMapping("/product/attr/updateProductAttrValue")
CommonResult<Boolean> updateProductAttrValue(@RequestBody ProductAttrValueUpdateReqDTO updateDTO);
/**
*
*
* @param productAttrValueId
* @return
*/
@GetMapping("/product/attr/getProductAttrValue")
CommonResult<ProductAttrValueRespDTO> getProductAttrValue(@RequestParam("productAttrValueId") Integer productAttrValueId);
@PostMapping("/product/attr/listProductAttrValues")
CommonResult<List<ProductAttrValueRespDTO>> listProductAttrValues(@RequestBody ProductAttrValueListQueryReqDTO queryDTO);
}

View File

@ -1,84 +0,0 @@
package cn.iocoder.mall.productservice.rpc.attr;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.productservice.rpc.attr.dto.*;
import java.util.List;
/**
* Rpc
*/
public interface ProductAttrRpc {
/**
*
*
* @param createDTO DTO
* @return
*/
CommonResult<Integer> createProductAttrKey(ProductAttrKeyCreateReqDTO createDTO);
/**
*
*
* @param updateDTO DTO
*/
CommonResult<Boolean> updateProductAttrKey(ProductAttrKeyUpdateReqDTO updateDTO);
/**
*
*
* @param productAttrKeyId
* @return
*/
CommonResult<ProductAttrKeyRespDTO> getProductAttrKey(Integer productAttrKeyId);
/**
*
*
* @param productAttrKeyIds
* @return
*/
CommonResult<List<ProductAttrKeyRespDTO>> listProductAttrKeys(List<Integer> productAttrKeyIds);
/**
*
*
* @param pageDTO
* @return
*/
CommonResult<PageResult<ProductAttrKeyRespDTO>> pageProductAttrKey(ProductAttrKeyPageReqDTO pageDTO);
/**
*
*
* @param createDTO DTO
* @return
*/
CommonResult<Integer> createProductAttrValue(ProductAttrValueCreateReqDTO createDTO);
/**
*
*
* @param updateDTO DTO
*/
CommonResult<Boolean> updateProductAttrValue(ProductAttrValueUpdateReqDTO updateDTO);
/**
*
*
* @param productAttrValueId
* @return
*/
CommonResult<ProductAttrValueRespDTO> getProductAttrValue(Integer productAttrValueId);
/**
*
*
* @param queryDTO DTO
* @return
*/
CommonResult<List<ProductAttrValueRespDTO>> listProductAttrValues(ProductAttrValueListQueryReqDTO queryDTO);
}

View File

@ -0,0 +1,128 @@
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.attr.ProductAttrManager;
import cn.iocoder.mall.productservice.rpc.attr.dto.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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;
@RestController
@RequestMapping("/product/attr")
@Api("商品属性")
public class ProductAttrController {
@Autowired
private ProductAttrManager productAttrManager;
@PostMapping("/createProductAttrKey")
@ApiOperation("创建商品规格键")
CommonResult<Integer> createProductAttrKey(@RequestBody ProductAttrKeyCreateReqDTO createDTO){
return success(productAttrManager.createProductAttrKey(createDTO));
}
/**
*
*
* @param updateDTO DTO
*/
@PostMapping("/updateProductAttrKey")
@ApiOperation("更新商品规格键")
CommonResult<Boolean> updateProductAttrKey(@RequestBody ProductAttrKeyUpdateReqDTO updateDTO){
productAttrManager.updateProductAttrKey(updateDTO);
return success(true);
}
/**
*
*
* @param productAttrKeyId
* @return
*/
@GetMapping("/getProductAttrKey")
@ApiOperation("获得商品规格键")
CommonResult<ProductAttrKeyRespDTO> getProductAttrKey(@RequestParam("productAttrKeyId") Integer productAttrKeyId){
return success(productAttrManager.getProductAttrKey(productAttrKeyId));
}
/**
*
*
* @param productAttrKeyIds
* @return
*/
@GetMapping("/listProductAttrKeys")
@ApiOperation("获得商品规格键列表")
CommonResult<List<ProductAttrKeyRespDTO>> listProductAttrKeys(@RequestParam("productAttrKeyIds") List<Integer> productAttrKeyIds){
return success(productAttrManager.listProductAttrKeys(productAttrKeyIds));
}
/**
*
*
* @param pageDTO
* @return
*/
@PostMapping("/pageProductAttrKey")
@ApiOperation("获得商品规格键分页")
CommonResult<PageResult<ProductAttrKeyRespDTO>> pageProductAttrKey(@RequestBody ProductAttrKeyPageReqDTO pageDTO){
return success(productAttrManager.pageProductAttrKey(pageDTO));
}
/**
*
*
* @param createDTO DTO
* @return
*/
@PostMapping("/createProductAttrValue")
@ApiOperation("创建商品规格值")
CommonResult<Integer> createProductAttrValue(@RequestBody ProductAttrValueCreateReqDTO createDTO){
return success(productAttrManager.createProductAttrValue(createDTO));
}
/**
*
*
* @param updateDTO DTO
*/
@PostMapping("/updateProductAttrValue")
@ApiOperation("更新商品规格值")
CommonResult<Boolean> updateProductAttrValue(@RequestBody ProductAttrValueUpdateReqDTO updateDTO){
productAttrManager.updateProductAttrValue(updateDTO);
return success(true);
}
/**
*
*
* @param productAttrValueId
* @return
*/
@GetMapping("/getProductAttrValue")
@ApiOperation("获得商品规格值")
CommonResult<ProductAttrValueRespDTO> getProductAttrValue(@RequestParam("productAttrValueId") Integer productAttrValueId){
return success(productAttrManager.getProductAttrValue(productAttrValueId));
}
/**
*
*
* @param queryDTO DTO
* @return
*/
@PostMapping("/listProductAttrValues")
@ApiOperation("获得商品规格值列表")
CommonResult<List<ProductAttrValueRespDTO>> listProductAttrValues(@RequestBody ProductAttrValueListQueryReqDTO queryDTO){
return success(productAttrManager.listProductAttrValues(queryDTO));
}
}

View File

@ -1,70 +0,0 @@
package cn.iocoder.mall.productservice.rpc.attr;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.productservice.manager.attr.ProductAttrManager;
import cn.iocoder.mall.productservice.rpc.attr.dto.*;
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 ProductAttrRpcImpl implements ProductAttrRpc {
@Autowired
private ProductAttrManager productAttrManager;
@Override
public CommonResult<Integer> createProductAttrKey(ProductAttrKeyCreateReqDTO createDTO) {
return success(productAttrManager.createProductAttrKey(createDTO));
}
@Override
public CommonResult<Boolean> updateProductAttrKey(ProductAttrKeyUpdateReqDTO updateDTO) {
productAttrManager.updateProductAttrKey(updateDTO);
return success(true);
}
@Override
public CommonResult<ProductAttrKeyRespDTO> getProductAttrKey(Integer productAttrKeyId) {
return success(productAttrManager.getProductAttrKey(productAttrKeyId));
}
@Override
public CommonResult<List<ProductAttrKeyRespDTO>> listProductAttrKeys(List<Integer> productAttrKeyIds) {
return success(productAttrManager.listProductAttrKeys(productAttrKeyIds));
}
@Override
public CommonResult<PageResult<ProductAttrKeyRespDTO>> pageProductAttrKey(ProductAttrKeyPageReqDTO pageDTO) {
return success(productAttrManager.pageProductAttrKey(pageDTO));
}
@Override
public CommonResult<Integer> createProductAttrValue(ProductAttrValueCreateReqDTO createDTO) {
return success(productAttrManager.createProductAttrValue(createDTO));
}
@Override
public CommonResult<Boolean> updateProductAttrValue(ProductAttrValueUpdateReqDTO updateDTO) {
productAttrManager.updateProductAttrValue(updateDTO);
return success(true);
}
@Override
public CommonResult<ProductAttrValueRespDTO> getProductAttrValue(Integer productAttrValueId) {
return success(productAttrManager.getProductAttrValue(productAttrValueId));
}
@Override
public CommonResult<List<ProductAttrValueRespDTO>> listProductAttrValues(ProductAttrValueListQueryReqDTO queryDTO) {
return success(productAttrManager.listProductAttrValues(queryDTO));
}
}

View File

@ -8,7 +8,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc.spu"})
@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc"})
public class PromotionServiceApplication {
public static void main(String[] args) {

View File

@ -7,7 +7,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc.spu"})
@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc"})
public class SearchServiceApplication {
public static void main(String[] args) {

View File

@ -7,7 +7,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc.spu"})
@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc"})
public class ShopWebApplication {
public static void main(String[] args) {