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 @SpringBootApplication
@EnableDiscoveryClient @EnableDiscoveryClient
@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc.spu"}) @EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc"})
public class ManagementWebApplication { public class ManagementWebApplication {
public static void main(String[] args) { public static void main(String[] args) {

View File

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

View File

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

View File

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