商品规格 key 的迁移

This commit is contained in:
YunaiV
2020-07-28 23:15:20 +08:00
parent 75876682fb
commit 7dbbd412d8
32 changed files with 1010 additions and 174 deletions

View File

@@ -0,0 +1,67 @@
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.manager.product.ProductAttrKeyManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
import static cn.iocoder.common.framework.vo.CommonResult.success;
/**
* 商品规格键 Controller
*/
@RestController
@RequestMapping("/product-attr/")
@Api(tags = "商品规格键")
@Validated
public class ProductAttrController {
@Autowired
private ProductAttrKeyManager productAttrKeyManager;
@PostMapping("/key/create")
@ApiOperation("创建商品规格键")
public CommonResult<Integer> createProductAttrKey(@Valid ProductAttrKeyCreateReqVO createVO) {
return success(productAttrKeyManager.createProductAttrKey(createVO));
}
@PostMapping("/key/update")
@ApiOperation("更新商品规格键")
public CommonResult<Boolean> updateProductAttrKey(@Valid ProductAttrKeyUpdateReqVO updateVO) {
productAttrKeyManager.updateProductAttrKey(updateVO);
return success(true);
}
@GetMapping("/key/get")
@ApiOperation("获得商品规格键")
@ApiImplicitParam(name = "productAttrKeyId", value = "商品规格键编号", required = true)
public CommonResult<ProductAttrKeyRespVO> getProductAttrKey(@RequestParam("productAttrKeyId") Integer productAttrKeyId) {
return success(productAttrKeyManager.getProductAttrKey(productAttrKeyId));
}
@GetMapping("/key/list")
@ApiOperation("获得商品规格键列表")
@ApiImplicitParam(name = "productAttrKeyIds", value = "商品规格键编号列表", required = true)
public CommonResult<List<ProductAttrKeyRespVO>> listProductAttrKeys(@RequestParam("productAttrKeyIds") List<Integer> productAttrKeyIds) {
return success(productAttrKeyManager.listProductAttrKeys(productAttrKeyIds));
}
@GetMapping("/key/page")
@ApiOperation("获得商品规格键分页")
public CommonResult<PageResult<ProductAttrKeyRespVO>> pageProductAttrKey(ProductAttrKeyPageReqVO pageVO) {
return success(productAttrKeyManager.pageProductAttrKey(pageVO));
}
}

View File

@@ -61,10 +61,14 @@ public class ProductSpuController {
@GetMapping("/page")
@ApiOperation("获得商品 SPU 分页")
public CommonResult<PageResult<ProductSpuRespVO>> pageProductSpu(ProductSpuPageReqVO pageVO) {
//
//
//
// 全部:无搜索条件
// 在售中visible = true && hasQuantity = true
// 已售罄visible = true && hasQuantity = false
// 仓库中visible = false
return success(productSpuManager.pageProductSpu(pageVO));
}
// TODO 芋艿,删除功能暂时不做。主要原因是,关联的数据太多。删除带来的问题会比较大
}

View File

@@ -0,0 +1,24 @@
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 ProductAttrKeyCreateReqVO {
@ApiModelProperty(value = "规格键名称", required = true, example = "尺寸")
@NotEmpty(message = "规格键名称不能为空")
private String name;
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 CommonStatusEnum 枚举")
@NotNull(message = "状态不能为空")
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
private Integer status;
}

View File

@@ -0,0 +1,22 @@
package cn.iocoder.mall.managementweb.controller.product.vo.attr;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.validator.InEnum;
import cn.iocoder.common.framework.vo.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ApiModel("商品规格键分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
public class ProductAttrKeyPageReqVO extends PageParam {
@ApiModelProperty(value = "规格键名称", required = true, example = "尺寸", notes = "模糊匹配")
private String name;
@ApiModelProperty(value = "状态", example = "1", notes = "见 CommonStatusEnum 枚举")
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
private Integer status;
}

View File

@@ -0,0 +1,20 @@
package cn.iocoder.mall.managementweb.controller.product.vo.attr;
import lombok.*;
import io.swagger.annotations.*;
import java.util.*;
@ApiModel("商品规格键 Response VO")
@Data
public class ProductAttrKeyRespVO {
@ApiModelProperty(value = "规格键编号", required = true, example = "1")
private Integer id;
@ApiModelProperty(value = "规格键名称", required = true, example = "尺寸")
private String name;
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 CommonStatusEnum 枚举")
private Integer status;
@ApiModelProperty(value = "创建时间", required = true)
private Date createTime;
}

View File

@@ -0,0 +1,27 @@
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 ProductAttrKeyUpdateReqVO {
@ApiModelProperty(value = "规格键编号", required = true, example = "1")
@NotNull(message = "规格键编号不能为空")
private Integer id;
@ApiModelProperty(value = "规格键名称", required = true, example = "尺寸")
@NotEmpty(message = "规格键名称不能为空")
private String name;
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 CommonStatusEnum 枚举")
@NotNull(message = "状态不能为空")
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
private Integer status;
}

View File

@@ -0,0 +1,34 @@
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);
}

View File

@@ -0,0 +1,97 @@
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.productservice.rpc.attr.ProductAttrRpc;
import cn.iocoder.mall.productservice.rpc.attr.dto.ProductAttrKeyRespDTO;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 商品规格 Manager
*/
@Service
public class ProductAttrKeyManager {
@DubboReference(version = "${dubbo.consumer.ProductAttrRpc.version}")
private ProductAttrRpc productAttrKeyRpc;
/**
* 创建商品规格键
*
* @param createVO 创建商品规格键 VO
* @return 商品规格键
*/
public Integer createProductAttrKey(ProductAttrKeyCreateReqVO createVO) {
CommonResult<Integer> createProductAttrKeyResult = productAttrKeyRpc.createProductAttrKey(
ProductAttrKeyConvert.INSTANCE.convert(createVO));
createProductAttrKeyResult.checkError();
return createProductAttrKeyResult.getData();
}
/**
* 更新商品规格键
*
* @param updateVO 更新商品规格键 VO
*/
public void updateProductAttrKey(ProductAttrKeyUpdateReqVO updateVO) {
CommonResult<Boolean> updateProductAttrKeyResult = productAttrKeyRpc.updateProductAttrKey(
ProductAttrKeyConvert.INSTANCE.convert(updateVO));
updateProductAttrKeyResult.checkError();
}
/**
* 删除商品规格键
*
* @param productAttrKeyId 商品规格键编号
*/
public void deleteProductAttrKey(Integer productAttrKeyId) {
CommonResult<Boolean> deleteProductAttrKeyResult = productAttrKeyRpc.deleteProductAttrKey(productAttrKeyId);
deleteProductAttrKeyResult.checkError();
}
/**
* 获得商品规格键
*
* @param productAttrKeyId 商品规格键编号
* @return 商品规格键
*/
public ProductAttrKeyRespVO getProductAttrKey(Integer productAttrKeyId) {
CommonResult<ProductAttrKeyRespDTO> getProductAttrKeyResult = productAttrKeyRpc.getProductAttrKey(productAttrKeyId);
getProductAttrKeyResult.checkError();
return ProductAttrKeyConvert.INSTANCE.convert(getProductAttrKeyResult.getData());
}
/**
* 获得商品规格键列表
*
* @param productAttrKeyIds 商品规格键编号列表
* @return 商品规格键列表
*/
public List<ProductAttrKeyRespVO> listProductAttrKeys(List<Integer> productAttrKeyIds) {
CommonResult<List<ProductAttrKeyRespDTO>> listProductAttrKeyResult = productAttrKeyRpc.listProductAttrKeys(productAttrKeyIds);
listProductAttrKeyResult.checkError();
return ProductAttrKeyConvert.INSTANCE.convertList(listProductAttrKeyResult.getData());
}
/**
* 获得商品规格键分页
*
* @param pageVO 商品规格键分页查询
* @return 商品规格键分页结果
*/
public PageResult<ProductAttrKeyRespVO> pageProductAttrKey(ProductAttrKeyPageReqVO pageVO) {
CommonResult<PageResult<ProductAttrKeyRespDTO>> pageProductAttrKeyResult = productAttrKeyRpc.pageProductAttrKey(
ProductAttrKeyConvert.INSTANCE.convert(pageVO));
pageProductAttrKeyResult.checkError();
return ProductAttrKeyConvert.INSTANCE.convertPage(pageProductAttrKeyResult.getData());
}
}

View File

@@ -55,6 +55,8 @@ dubbo:
version: 1.0.0
ProductSpuRpc:
version: 1.0.0
ProductAttrRpc:
version: 1.0.0
# Swagger 配置项
swagger: