商品 SPU 开始迁移
This commit is contained in:
@@ -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.spu.ProductSpuCreateReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.spu.ProductSpuPageReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.spu.ProductSpuRespVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.spu.ProductSpuUpdateReqVO;
|
||||
import cn.iocoder.mall.managementweb.manager.product.ProductSpuManager;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 商品 SPU Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/product_spu")
|
||||
@Api(tags = "商品 SPU")
|
||||
@Validated
|
||||
public class ProductSpuController {
|
||||
|
||||
@Autowired
|
||||
private ProductSpuManager productSpuManager;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建商品 SPU")
|
||||
public CommonResult<Integer> createProductSpu(@Valid ProductSpuCreateReqVO createVO) {
|
||||
return success(productSpuManager.createProductSpu(createVO));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("更新商品 SPU")
|
||||
public CommonResult<Boolean> updateProductSpu(@Valid ProductSpuUpdateReqVO updateVO) {
|
||||
productSpuManager.updateProductSpu(updateVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得商品 SPU")
|
||||
@ApiImplicitParam(name = "productSpuId", value = "商品 SPU编号", required = true)
|
||||
public CommonResult<ProductSpuRespVO> getProductSpu(@RequestParam("productSpuId") Integer productSpuId) {
|
||||
return success(productSpuManager.getProductSpu(productSpuId));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得商品 SPU 列表")
|
||||
@ApiImplicitParam(name = "productSpuIds", value = "商品 SPU编号列表", required = true)
|
||||
public CommonResult<List<ProductSpuRespVO>> listProductSpus(@RequestParam("productSpuIds") List<Integer> productSpuIds) {
|
||||
return success(productSpuManager.listProductSpus(productSpuIds));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得商品 SPU 分页")
|
||||
public CommonResult<PageResult<ProductSpuRespVO>> pageProductSpu(ProductSpuPageReqVO pageVO) {
|
||||
return success(productSpuManager.pageProductSpu(pageVO));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package cn.iocoder.mall.managementweb.controller.product.vo.spu;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("商品 SPU创建 Request VO")
|
||||
@Data
|
||||
public class ProductSpuCreateReqVO {
|
||||
|
||||
@ApiModelProperty(value = "SPU 名字", required = true)
|
||||
@NotEmpty(message = "SPU 名字不能为空")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "卖点", required = true)
|
||||
@NotEmpty(message = "卖点不能为空")
|
||||
private String sellPoint;
|
||||
@ApiModelProperty(value = "描述", required = true)
|
||||
@NotEmpty(message = "描述不能为空")
|
||||
private String description;
|
||||
@ApiModelProperty(value = "分类编号", required = true)
|
||||
@NotNull(message = "分类编号不能为空")
|
||||
private Integer cid;
|
||||
@ApiModelProperty(value = "商品主图地址", required = true)
|
||||
@NotEmpty(message = "商品主图地址不能为空")
|
||||
private String picUrls;
|
||||
@ApiModelProperty(value = "是否上架商品", required = true)
|
||||
@NotNull(message = "是否上架商品不能为空")
|
||||
private Integer visible;
|
||||
@ApiModelProperty(value = "排序字段", required = true)
|
||||
@NotNull(message = "排序字段不能为空")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "价格", required = true)
|
||||
@NotNull(message = "价格不能为空")
|
||||
private Integer price;
|
||||
@ApiModelProperty(value = "库存数量", required = true)
|
||||
@NotNull(message = "库存数量不能为空")
|
||||
private Integer quantity;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package cn.iocoder.mall.managementweb.controller.product.vo.spu;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@ApiModel("商品 SPU分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ProductSpuPageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "SPU 名字", required = true)
|
||||
private String name;
|
||||
@ApiModelProperty(value = "卖点", required = true)
|
||||
private String sellPoint;
|
||||
@ApiModelProperty(value = "描述", required = true)
|
||||
private String description;
|
||||
@ApiModelProperty(value = "分类编号", required = true)
|
||||
private Integer cid;
|
||||
@ApiModelProperty(value = "商品主图地址", required = true)
|
||||
private String picUrls;
|
||||
@ApiModelProperty(value = "是否上架商品", required = true)
|
||||
private Integer visible;
|
||||
@ApiModelProperty(value = "排序字段", required = true)
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "价格", required = true)
|
||||
private Integer price;
|
||||
@ApiModelProperty(value = "库存数量", required = true)
|
||||
private Integer quantity;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package cn.iocoder.mall.managementweb.controller.product.vo.spu;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.util.*;
|
||||
|
||||
@ApiModel("商品 SPU Response VO")
|
||||
@Data
|
||||
public class ProductSpuRespVO {
|
||||
|
||||
@ApiModelProperty(value = "SPU 编号", required = true)
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "SPU 名字", required = true)
|
||||
private String name;
|
||||
@ApiModelProperty(value = "卖点", required = true)
|
||||
private String sellPoint;
|
||||
@ApiModelProperty(value = "描述", required = true)
|
||||
private String description;
|
||||
@ApiModelProperty(value = "分类编号", required = true)
|
||||
private Integer cid;
|
||||
@ApiModelProperty(value = "商品主图地址", required = true)
|
||||
private String picUrls;
|
||||
@ApiModelProperty(value = "是否上架商品", required = true)
|
||||
private Integer visible;
|
||||
@ApiModelProperty(value = "排序字段", required = true)
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "价格", required = true)
|
||||
private Integer price;
|
||||
@ApiModelProperty(value = "库存数量", required = true)
|
||||
private Integer quantity;
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
@ApiModelProperty(value = "最后更新时间", required = true)
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package cn.iocoder.mall.managementweb.controller.product.vo.spu;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("商品 SPU更新 Request VO")
|
||||
@Data
|
||||
public class ProductSpuUpdateReqVO {
|
||||
|
||||
@ApiModelProperty(value = "SPU 编号", required = true)
|
||||
@NotNull(message = "SPU 编号不能为空")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "SPU 名字", required = true)
|
||||
@NotEmpty(message = "SPU 名字不能为空")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "卖点", required = true)
|
||||
@NotEmpty(message = "卖点不能为空")
|
||||
private String sellPoint;
|
||||
@ApiModelProperty(value = "描述", required = true)
|
||||
@NotEmpty(message = "描述不能为空")
|
||||
private String description;
|
||||
@ApiModelProperty(value = "分类编号", required = true)
|
||||
@NotNull(message = "分类编号不能为空")
|
||||
private Integer cid;
|
||||
@ApiModelProperty(value = "商品主图地址", required = true)
|
||||
@NotEmpty(message = "商品主图地址不能为空")
|
||||
private String picUrls;
|
||||
@ApiModelProperty(value = "是否上架商品", required = true)
|
||||
@NotNull(message = "是否上架商品不能为空")
|
||||
private Integer visible;
|
||||
@ApiModelProperty(value = "排序字段", required = true)
|
||||
@NotNull(message = "排序字段不能为空")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "价格", required = true)
|
||||
@NotNull(message = "价格不能为空")
|
||||
private Integer price;
|
||||
@ApiModelProperty(value = "库存数量", required = true)
|
||||
@NotNull(message = "库存数量不能为空")
|
||||
private Integer quantity;
|
||||
|
||||
}
|
||||
@@ -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.spu.ProductSpuCreateReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.spu.ProductSpuPageReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.spu.ProductSpuRespVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.spu.ProductSpuUpdateReqVO;
|
||||
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuCreateReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuPageReqDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO;
|
||||
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuUpdateReqDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ProductSpuConvert {
|
||||
|
||||
ProductSpuConvert INSTANCE = Mappers.getMapper(ProductSpuConvert.class);
|
||||
|
||||
ProductSpuCreateReqDTO convert(ProductSpuCreateReqVO bean);
|
||||
|
||||
ProductSpuUpdateReqDTO convert(ProductSpuUpdateReqVO bean);
|
||||
|
||||
ProductSpuRespVO convert(ProductSpuRespDTO bean);
|
||||
|
||||
List<ProductSpuRespVO> convertList(List<ProductSpuRespDTO> list);
|
||||
|
||||
PageResult<ProductSpuRespVO> convertPage(PageResult<ProductSpuRespDTO> page);
|
||||
|
||||
ProductSpuPageReqDTO convert(ProductSpuPageReqVO bean);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
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.spu.ProductSpuCreateReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.spu.ProductSpuPageReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.spu.ProductSpuRespVO;
|
||||
import cn.iocoder.mall.managementweb.controller.product.vo.spu.ProductSpuUpdateReqVO;
|
||||
import cn.iocoder.mall.managementweb.convert.product.ProductSpuConvert;
|
||||
import cn.iocoder.mall.productservice.rpc.spu.ProductSpuRpc;
|
||||
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品 SPU Manager
|
||||
*/
|
||||
@Service
|
||||
public class ProductSpuManager {
|
||||
|
||||
@DubboReference(version = "${dubbo.consumer.ProductSpuRpc.version}")
|
||||
private ProductSpuRpc productSpuRpc;
|
||||
|
||||
/**
|
||||
* 创建商品 SPU
|
||||
*
|
||||
* @param createVO 创建商品 SPU VO
|
||||
* @return 商品 SPU
|
||||
*/
|
||||
public Integer createProductSpu(ProductSpuCreateReqVO createVO) {
|
||||
CommonResult<Integer> createProductSpuResult = productSpuRpc.createProductSpu(ProductSpuConvert.INSTANCE.convert(createVO));
|
||||
createProductSpuResult.checkError();
|
||||
return createProductSpuResult.getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品 SPU
|
||||
*
|
||||
* @param updateVO 更新商品 SPU VO
|
||||
*/
|
||||
public void updateProductSpu(ProductSpuUpdateReqVO updateVO) {
|
||||
CommonResult<Boolean> updateProductSpuResult = productSpuRpc.updateProductSpu(ProductSpuConvert.INSTANCE.convert(updateVO));
|
||||
updateProductSpuResult.checkError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得商品 SPU
|
||||
*
|
||||
* @param productSpuId 商品 SPU编号
|
||||
* @return 商品 SPU
|
||||
*/
|
||||
public ProductSpuRespVO getProductSpu(Integer productSpuId) {
|
||||
CommonResult<ProductSpuRespDTO> getProductSpuResult = productSpuRpc.getProductSpu(productSpuId);
|
||||
getProductSpuResult.checkError();
|
||||
return ProductSpuConvert.INSTANCE.convert(getProductSpuResult.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得商品 SPU列表
|
||||
*
|
||||
* @param productSpuIds 商品 SPU编号列表
|
||||
* @return 商品 SPU列表
|
||||
*/
|
||||
public List<ProductSpuRespVO> listProductSpus(List<Integer> productSpuIds) {
|
||||
CommonResult<List<ProductSpuRespDTO>> listProductSpuResult = productSpuRpc.listProductSpus(productSpuIds);
|
||||
listProductSpuResult.checkError();
|
||||
return ProductSpuConvert.INSTANCE.convertList(listProductSpuResult.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得商品 SPU分页
|
||||
*
|
||||
* @param pageVO 商品 SPU分页查询
|
||||
* @return 商品 SPU分页结果
|
||||
*/
|
||||
public PageResult<ProductSpuRespVO> pageProductSpu(ProductSpuPageReqVO pageVO) {
|
||||
CommonResult<PageResult<ProductSpuRespDTO>> pageProductSpuResult = productSpuRpc.pageProductSpu(ProductSpuConvert.INSTANCE.convert(pageVO));
|
||||
pageProductSpuResult.checkError();
|
||||
return ProductSpuConvert.INSTANCE.convertPage(pageProductSpuResult.getData());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user