商品规格 value 的迁移
This commit is contained in:
@@ -2,10 +2,7 @@ package cn.iocoder.mall.managementweb.controller.product;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.attr.ProductAttrKeyCreateReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.attr.ProductAttrKeyPageReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.attr.ProductAttrKeyRespVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.attr.ProductAttrKeyUpdateReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.attr.*;
|
||||
import cn.iocoder.mall.managementweb.manager.product.ProductAttrKeyManager;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
@@ -24,7 +21,7 @@ import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/product-attr/")
|
||||
@Api(tags = "商品规格键")
|
||||
@Api(tags = "商品规格")
|
||||
@Validated
|
||||
public class ProductAttrController {
|
||||
|
||||
@@ -64,4 +61,31 @@ public class ProductAttrController {
|
||||
return success(productAttrKeyManager.pageProductAttrKey(pageVO));
|
||||
}
|
||||
|
||||
@PostMapping("/value/create")
|
||||
@ApiOperation("创建商品规格值")
|
||||
public CommonResult<Integer> createProductAttrValue(@Valid ProductAttrValueCreateReqVO createVO) {
|
||||
return success(productAttrKeyManager.createProductAttrValue(createVO));
|
||||
}
|
||||
|
||||
@PostMapping("/value/update")
|
||||
@ApiOperation("更新商品规格值")
|
||||
public CommonResult<Boolean> updateProductAttrValue(@Valid ProductAttrValueUpdateReqVO updateVO) {
|
||||
productAttrKeyManager.updateProductAttrValue(updateVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/value/get")
|
||||
@ApiOperation("获得商品规格值")
|
||||
@ApiImplicitParam(name = "productAttrValueId", value = "商品规格值编号", required = true)
|
||||
public CommonResult<ProductAttrValueRespVO> getProductAttrValue(@RequestParam("productAttrValueId") Integer productAttrValueId) {
|
||||
return success(productAttrKeyManager.getProductAttrValue(productAttrValueId));
|
||||
}
|
||||
|
||||
@GetMapping("/value/list")
|
||||
@ApiOperation("获得商品规格值列表")
|
||||
@ApiImplicitParam(name = "productAttrValueIds", value = "商品规格值编号列表", required = true)
|
||||
public CommonResult<List<ProductAttrValueRespVO>> listProductAttrValues(@RequestParam("productAttrValueIds") List<Integer> productAttrValueIds) {
|
||||
return success(productAttrKeyManager.listProductAttrValues(productAttrValueIds));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.iocoder.mall.managementweb.controller.product.vo.attr;
|
||||
|
||||
import cn.iocoder.common.framework.enums.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("商品规格值创建 Request VO")
|
||||
@Data
|
||||
public class ProductAttrValueCreateReqVO {
|
||||
|
||||
@ApiModelProperty(value = "规格键编号", required = true, example = "2")
|
||||
@NotNull(message = "规格键编号不能为空")
|
||||
private Integer attrKeyId;
|
||||
@ApiModelProperty(value = "规格值名字", required = true, example = "XXL")
|
||||
@NotEmpty(message = "规格值名字不能为空")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 CommonStatusEnum 枚举")
|
||||
@NotNull(message = "状态不能为空")
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.iocoder.mall.managementweb.controller.product.vo.attr;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.util.*;
|
||||
|
||||
@ApiModel("商品规格值 Response VO")
|
||||
@Data
|
||||
public class ProductAttrValueRespVO {
|
||||
|
||||
@ApiModelProperty(value = "规格值编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "规格键编号", required = true, example = "2")
|
||||
private Integer attrKeyId;
|
||||
@ApiModelProperty(value = "规格值名字", required = true, example = "XXL")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 CommonStatusEnum 枚举")
|
||||
private Integer status;
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.iocoder.mall.managementweb.controller.product.vo.attr;
|
||||
|
||||
import cn.iocoder.common.framework.enums.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("商品规格值更新 Request VO")
|
||||
@Data
|
||||
public class ProductAttrValueUpdateReqVO {
|
||||
|
||||
@ApiModelProperty(value = "规格值编号", required = true, example = "1")
|
||||
@NotNull(message = "规格值编号不能为空")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "规格值名字", required = true, example = "XXL")
|
||||
@NotEmpty(message = "规格值名字不能为空")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 CommonStatusEnum 枚举")
|
||||
@NotNull(message = "状态不能为空")
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package cn.iocoder.mall.managementweb.convert.product;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.attr.*;
|
||||
import cn.iocoder.mall.productservice.rpc.attr.dto.*;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ProductAttrConvert {
|
||||
|
||||
ProductAttrConvert INSTANCE = Mappers.getMapper(ProductAttrConvert.class);
|
||||
|
||||
ProductAttrKeyCreateReqDTO convert(ProductAttrKeyCreateReqVO bean);
|
||||
|
||||
ProductAttrKeyUpdateReqDTO convert(ProductAttrKeyUpdateReqVO bean);
|
||||
|
||||
ProductAttrKeyRespVO convert(ProductAttrKeyRespDTO bean);
|
||||
|
||||
List<ProductAttrKeyRespVO> convertList(List<ProductAttrKeyRespDTO> list);
|
||||
|
||||
PageResult<ProductAttrKeyRespVO> convertPage(PageResult<ProductAttrKeyRespDTO> page);
|
||||
|
||||
ProductAttrKeyPageReqDTO convert(ProductAttrKeyPageReqVO bean);
|
||||
|
||||
|
||||
ProductAttrValueCreateReqDTO convert(ProductAttrValueCreateReqVO bean);
|
||||
|
||||
ProductAttrValueUpdateReqDTO convert(ProductAttrValueUpdateReqVO bean);
|
||||
|
||||
ProductAttrValueRespVO convert(ProductAttrValueRespDTO bean);
|
||||
|
||||
List<ProductAttrValueRespVO> convertList02(List<ProductAttrValueRespDTO> list);
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package cn.iocoder.mall.managementweb.convert.product;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.attr.ProductAttrKeyCreateReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.attr.ProductAttrKeyPageReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.attr.ProductAttrKeyRespVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.attr.ProductAttrKeyUpdateReqVO;
|
||||
import cn.iocoder.mall.productservice.rpc.attr.dto.ProductAttrKeyCreateReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.attr.dto.ProductAttrKeyPageReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.attr.dto.ProductAttrKeyRespDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.attr.dto.ProductAttrKeyUpdateReqDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ProductAttrKeyConvert {
|
||||
|
||||
ProductAttrKeyConvert INSTANCE = Mappers.getMapper(ProductAttrKeyConvert.class);
|
||||
|
||||
ProductAttrKeyCreateReqDTO convert(ProductAttrKeyCreateReqVO bean);
|
||||
|
||||
ProductAttrKeyUpdateReqDTO convert(ProductAttrKeyUpdateReqVO bean);
|
||||
|
||||
ProductAttrKeyRespVO convert(ProductAttrKeyRespDTO bean);
|
||||
|
||||
List<ProductAttrKeyRespVO> convertList(List<ProductAttrKeyRespDTO> list);
|
||||
|
||||
PageResult<ProductAttrKeyRespVO> convertPage(PageResult<ProductAttrKeyRespDTO> page);
|
||||
|
||||
ProductAttrKeyPageReqDTO convert(ProductAttrKeyPageReqVO bean);
|
||||
|
||||
}
|
||||
@@ -2,13 +2,11 @@ package cn.iocoder.mall.managementweb.manager.product;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.attr.ProductAttrKeyCreateReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.attr.ProductAttrKeyPageReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.attr.ProductAttrKeyRespVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.attr.ProductAttrKeyUpdateReqVO;
|
||||
import cn.iocoder.mall.managementweb.convert.product.ProductAttrKeyConvert;
|
||||
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.dto.ProductAttrKeyRespDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.attr.dto.ProductAttrValueRespDTO;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -31,7 +29,7 @@ public class ProductAttrKeyManager {
|
||||
*/
|
||||
public Integer createProductAttrKey(ProductAttrKeyCreateReqVO createVO) {
|
||||
CommonResult<Integer> createProductAttrKeyResult = productAttrKeyRpc.createProductAttrKey(
|
||||
ProductAttrKeyConvert.INSTANCE.convert(createVO));
|
||||
ProductAttrConvert.INSTANCE.convert(createVO));
|
||||
createProductAttrKeyResult.checkError();
|
||||
return createProductAttrKeyResult.getData();
|
||||
}
|
||||
@@ -43,20 +41,10 @@ public class ProductAttrKeyManager {
|
||||
*/
|
||||
public void updateProductAttrKey(ProductAttrKeyUpdateReqVO updateVO) {
|
||||
CommonResult<Boolean> updateProductAttrKeyResult = productAttrKeyRpc.updateProductAttrKey(
|
||||
ProductAttrKeyConvert.INSTANCE.convert(updateVO));
|
||||
ProductAttrConvert.INSTANCE.convert(updateVO));
|
||||
updateProductAttrKeyResult.checkError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品规格键
|
||||
*
|
||||
* @param productAttrKeyId 商品规格键编号
|
||||
*/
|
||||
public void deleteProductAttrKey(Integer productAttrKeyId) {
|
||||
CommonResult<Boolean> deleteProductAttrKeyResult = productAttrKeyRpc.deleteProductAttrKey(productAttrKeyId);
|
||||
deleteProductAttrKeyResult.checkError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得商品规格键
|
||||
*
|
||||
@@ -66,7 +54,7 @@ public class ProductAttrKeyManager {
|
||||
public ProductAttrKeyRespVO getProductAttrKey(Integer productAttrKeyId) {
|
||||
CommonResult<ProductAttrKeyRespDTO> getProductAttrKeyResult = productAttrKeyRpc.getProductAttrKey(productAttrKeyId);
|
||||
getProductAttrKeyResult.checkError();
|
||||
return ProductAttrKeyConvert.INSTANCE.convert(getProductAttrKeyResult.getData());
|
||||
return ProductAttrConvert.INSTANCE.convert(getProductAttrKeyResult.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,7 +66,7 @@ public class ProductAttrKeyManager {
|
||||
public List<ProductAttrKeyRespVO> listProductAttrKeys(List<Integer> productAttrKeyIds) {
|
||||
CommonResult<List<ProductAttrKeyRespDTO>> listProductAttrKeyResult = productAttrKeyRpc.listProductAttrKeys(productAttrKeyIds);
|
||||
listProductAttrKeyResult.checkError();
|
||||
return ProductAttrKeyConvert.INSTANCE.convertList(listProductAttrKeyResult.getData());
|
||||
return ProductAttrConvert.INSTANCE.convertList(listProductAttrKeyResult.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,9 +77,57 @@ public class ProductAttrKeyManager {
|
||||
*/
|
||||
public PageResult<ProductAttrKeyRespVO> pageProductAttrKey(ProductAttrKeyPageReqVO pageVO) {
|
||||
CommonResult<PageResult<ProductAttrKeyRespDTO>> pageProductAttrKeyResult = productAttrKeyRpc.pageProductAttrKey(
|
||||
ProductAttrKeyConvert.INSTANCE.convert(pageVO));
|
||||
ProductAttrConvert.INSTANCE.convert(pageVO));
|
||||
pageProductAttrKeyResult.checkError();
|
||||
return ProductAttrKeyConvert.INSTANCE.convertPage(pageProductAttrKeyResult.getData());
|
||||
return ProductAttrConvert.INSTANCE.convertPage(pageProductAttrKeyResult.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建商品规格值
|
||||
*
|
||||
* @param createVO 创建商品规格值 VO
|
||||
* @return 商品规格值
|
||||
*/
|
||||
public Integer createProductAttrValue(ProductAttrValueCreateReqVO createVO) {
|
||||
CommonResult<Integer> createProductAttrValueResult = productAttrKeyRpc.createProductAttrValue(
|
||||
ProductAttrConvert.INSTANCE.convert(createVO));
|
||||
createProductAttrValueResult.checkError();
|
||||
return createProductAttrValueResult.getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品规格值
|
||||
*
|
||||
* @param updateVO 更新商品规格值 VO
|
||||
*/
|
||||
public void updateProductAttrValue(ProductAttrValueUpdateReqVO updateVO) {
|
||||
CommonResult<Boolean> updateProductAttrValueResult = productAttrKeyRpc.updateProductAttrValue(
|
||||
ProductAttrConvert.INSTANCE.convert(updateVO));
|
||||
updateProductAttrValueResult.checkError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得商品规格值
|
||||
*
|
||||
* @param productAttrValueId 商品规格值编号
|
||||
* @return 商品规格值
|
||||
*/
|
||||
public ProductAttrValueRespVO getProductAttrValue(Integer productAttrValueId) {
|
||||
CommonResult<ProductAttrValueRespDTO> getProductAttrValueResult = productAttrKeyRpc.getProductAttrValue(productAttrValueId);
|
||||
getProductAttrValueResult.checkError();
|
||||
return ProductAttrConvert.INSTANCE.convert(getProductAttrValueResult.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得商品规格值列表
|
||||
*
|
||||
* @param productAttrValueIds 商品规格值编号列表
|
||||
* @return 商品规格值列表
|
||||
*/
|
||||
public List<ProductAttrValueRespVO> listProductAttrValues(List<Integer> productAttrValueIds) {
|
||||
CommonResult<List<ProductAttrValueRespDTO>> listProductAttrValueResult = productAttrKeyRpc.listProductAttrValues(productAttrValueIds);
|
||||
listProductAttrValueResult.checkError();
|
||||
return ProductAttrConvert.INSTANCE.convertList02(listProductAttrValueResult.getData());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user