diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductSpuController.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductSpuController.java new file mode 100644 index 000000000..deb9ad365 --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductSpuController.java @@ -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 createProductSpu(@Valid ProductSpuCreateReqVO createVO) { + return success(productSpuManager.createProductSpu(createVO)); + } + + @PostMapping("/update") + @ApiOperation("更新商品 SPU") + public CommonResult updateProductSpu(@Valid ProductSpuUpdateReqVO updateVO) { + productSpuManager.updateProductSpu(updateVO); + return success(true); + } + + @GetMapping("/get") + @ApiOperation("获得商品 SPU") + @ApiImplicitParam(name = "productSpuId", value = "商品 SPU编号", required = true) + public CommonResult getProductSpu(@RequestParam("productSpuId") Integer productSpuId) { + return success(productSpuManager.getProductSpu(productSpuId)); + } + + @GetMapping("/list") + @ApiOperation("获得商品 SPU 列表") + @ApiImplicitParam(name = "productSpuIds", value = "商品 SPU编号列表", required = true) + public CommonResult> listProductSpus(@RequestParam("productSpuIds") List productSpuIds) { + return success(productSpuManager.listProductSpus(productSpuIds)); + } + + @GetMapping("/page") + @ApiOperation("获得商品 SPU 分页") + public CommonResult> pageProductSpu(ProductSpuPageReqVO pageVO) { + return success(productSpuManager.pageProductSpu(pageVO)); + } + +} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/spu/ProductSpuCreateReqVO.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/spu/ProductSpuCreateReqVO.java new file mode 100644 index 000000000..4fdfca20e --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/spu/ProductSpuCreateReqVO.java @@ -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; + +} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/spu/ProductSpuPageReqVO.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/spu/ProductSpuPageReqVO.java new file mode 100644 index 000000000..cadfcea8c --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/spu/ProductSpuPageReqVO.java @@ -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; + +} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/spu/ProductSpuRespVO.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/spu/ProductSpuRespVO.java new file mode 100644 index 000000000..95836b790 --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/spu/ProductSpuRespVO.java @@ -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; + +} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/spu/ProductSpuUpdateReqVO.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/spu/ProductSpuUpdateReqVO.java new file mode 100644 index 000000000..0498a9a66 --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/spu/ProductSpuUpdateReqVO.java @@ -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; + +} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/product/ProductSpuConvert.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/product/ProductSpuConvert.java new file mode 100644 index 000000000..19cc7c6bf --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/product/ProductSpuConvert.java @@ -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 convertList(List list); + + PageResult convertPage(PageResult page); + + ProductSpuPageReqDTO convert(ProductSpuPageReqVO bean); + +} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductSpuManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductSpuManager.java new file mode 100644 index 000000000..8655f307a --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductSpuManager.java @@ -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 createProductSpuResult = productSpuRpc.createProductSpu(ProductSpuConvert.INSTANCE.convert(createVO)); + createProductSpuResult.checkError(); + return createProductSpuResult.getData(); + } + + /** + * 更新商品 SPU + * + * @param updateVO 更新商品 SPU VO + */ + public void updateProductSpu(ProductSpuUpdateReqVO updateVO) { + CommonResult updateProductSpuResult = productSpuRpc.updateProductSpu(ProductSpuConvert.INSTANCE.convert(updateVO)); + updateProductSpuResult.checkError(); + } + + /** + * 获得商品 SPU + * + * @param productSpuId 商品 SPU编号 + * @return 商品 SPU + */ + public ProductSpuRespVO getProductSpu(Integer productSpuId) { + CommonResult getProductSpuResult = productSpuRpc.getProductSpu(productSpuId); + getProductSpuResult.checkError(); + return ProductSpuConvert.INSTANCE.convert(getProductSpuResult.getData()); + } + + /** + * 获得商品 SPU列表 + * + * @param productSpuIds 商品 SPU编号列表 + * @return 商品 SPU列表 + */ + public List listProductSpus(List productSpuIds) { + CommonResult> listProductSpuResult = productSpuRpc.listProductSpus(productSpuIds); + listProductSpuResult.checkError(); + return ProductSpuConvert.INSTANCE.convertList(listProductSpuResult.getData()); + } + + /** + * 获得商品 SPU分页 + * + * @param pageVO 商品 SPU分页查询 + * @return 商品 SPU分页结果 + */ + public PageResult pageProductSpu(ProductSpuPageReqVO pageVO) { + CommonResult> pageProductSpuResult = productSpuRpc.pageProductSpu(ProductSpuConvert.INSTANCE.convert(pageVO)); + pageProductSpuResult.checkError(); + return ProductSpuConvert.INSTANCE.convertPage(pageProductSpuResult.getData()); + } + +} diff --git a/management-web-app/src/main/resources/application.yml b/management-web-app/src/main/resources/application.yml index 08e950052..caeaea2e3 100644 --- a/management-web-app/src/main/resources/application.yml +++ b/management-web-app/src/main/resources/application.yml @@ -53,6 +53,8 @@ dubbo: version: 1.0.0 ProductBrandRpc: version: 1.0.0 + ProductSpuRpc: + version: 1.0.0 # Swagger 配置项 swagger: diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/spu/ProductSpuRpc.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/spu/ProductSpuRpc.java new file mode 100644 index 000000000..14c58e230 --- /dev/null +++ b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/spu/ProductSpuRpc.java @@ -0,0 +1,56 @@ +package cn.iocoder.mall.productservice.rpc.spu; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +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 java.util.List; + +/** +* 商品 SPU Rpc 接口 +*/ +public interface ProductSpuRpc { + + /** + * 创建商品 SPU + * + * @param createDTO 创建商品 SPU DTO + * @return 商品 SPU编号 + */ + CommonResult createProductSpu(ProductSpuCreateReqDTO createDTO); + + /** + * 更新商品 SPU + * + * @param updateDTO 更新商品 SPU DTO + */ + CommonResult updateProductSpu(ProductSpuUpdateReqDTO updateDTO); + + /** + * 获得商品 SPU + * + * @param productSpuId 商品 SPU 编号 + * @return 商品 SPU + */ + CommonResult getProductSpu(Integer productSpuId); + + /** + * 获得商品 SPU列表 + * + * @param productSpuIds 商品 SPU 编号列表 + * @return 商品 SPU 列表 + */ + CommonResult> listProductSpus(List productSpuIds); + + /** + * 获得商品 SPU分页 + * + * @param pageDTO 商品 SPU分页查询 + * @return 商品 SPU分页结果 + */ + CommonResult> pageProductSpu(ProductSpuPageReqDTO pageDTO); + +} diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/spu/dto/ProductSpuCreateReqDTO.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/spu/dto/ProductSpuCreateReqDTO.java new file mode 100644 index 000000000..2395162da --- /dev/null +++ b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/spu/dto/ProductSpuCreateReqDTO.java @@ -0,0 +1,63 @@ +package cn.iocoder.mall.productservice.rpc.spu.dto; + +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.List; + +/** +* 商品 SPU 创建 Request DTO +*/ +@Data +@Accessors(chain = true) +public class ProductSpuCreateReqDTO { + + /** + * SPU 名字 + */ + @NotEmpty(message = "SPU 名字不能为空") + private String name; + /** + * 卖点 + */ + @NotEmpty(message = "卖点不能为空") + private String sellPoint; + /** + * 描述 + */ + @NotEmpty(message = "描述不能为空") + private String description; + /** + * 分类编号 + */ + @NotNull(message = "分类编号不能为空") + private Integer cid; + /** + * 商品主图地址 + */ + @NotEmpty(message = "商品主图地址不能为空") + private List picUrls; + /** + * 是否上架商品 + */ + @NotNull(message = "是否上架商品不能为空") + private Integer visible; + /** + * 排序字段 + */ + @NotNull(message = "排序字段不能为空") + private Integer sort; + /** + * 价格 + */ + @NotNull(message = "价格不能为空") + private Integer price; + /** + * 库存数量 + */ + @NotNull(message = "库存数量不能为空") + private Integer quantity; + +} diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/spu/dto/ProductSpuPageReqDTO.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/spu/dto/ProductSpuPageReqDTO.java new file mode 100644 index 000000000..d0d6600be --- /dev/null +++ b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/spu/dto/ProductSpuPageReqDTO.java @@ -0,0 +1,25 @@ +package cn.iocoder.mall.productservice.rpc.spu.dto; + +import cn.iocoder.common.framework.vo.PageParam; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** +* 商品 SPU 分页 Request DTO +*/ +@Data +@EqualsAndHashCode(callSuper = true) +@Accessors(chain = true) +public class ProductSpuPageReqDTO extends PageParam { + + /** + * SPU 名字 + */ + private String name; + /** + * 是否有库存 + */ + private Boolean hasQuantity; + +} diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/spu/dto/ProductSpuRespDTO.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/spu/dto/ProductSpuRespDTO.java new file mode 100644 index 000000000..f38cfe003 --- /dev/null +++ b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/spu/dto/ProductSpuRespDTO.java @@ -0,0 +1,61 @@ +package cn.iocoder.mall.productservice.rpc.spu.dto; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; +import java.util.List; + +/** +* 商品 SPU 信息 Response DTO +*/ +@Data +@Accessors(chain = true) +public class ProductSpuRespDTO { + + /** + * 商品 SPU 编号 + */ + private Integer id; + /** + * SPU 名字 + */ + private String name; + /** + * 卖点 + */ + private String sellPoint; + /** + * 描述 + */ + private String description; + /** + * 分类编号 + */ + private Integer cid; + /** + * 商品主图地址 + */ + private List picUrls; + /** + * 是否上架商品 + */ + private Integer visible; + /** + * 排序字段 + */ + private Integer sort; + /** + * 价格 + */ + private Integer price; + /** + * 库存数量 + */ + private Integer quantity; + /** + * 创建时间 + */ + private Date createTime; + +} diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/spu/dto/ProductSpuUpdateReqDTO.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/spu/dto/ProductSpuUpdateReqDTO.java new file mode 100644 index 000000000..cfc281799 --- /dev/null +++ b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/spu/dto/ProductSpuUpdateReqDTO.java @@ -0,0 +1,68 @@ +package cn.iocoder.mall.productservice.rpc.spu.dto; + +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.List; + +/** +* 商品 SPU 更新 Request DTO +*/ +@Data +@Accessors(chain = true) +public class ProductSpuUpdateReqDTO { + + /** + * 商品 SPU 编号 + */ + @NotNull(message = "商品 SPU 编号不能为空") + private Integer id; + /** + * SPU 名字 + */ + @NotEmpty(message = "SPU 名字不能为空") + private String name; + /** + * 卖点 + */ + @NotEmpty(message = "卖点不能为空") + private String sellPoint; + /** + * 描述 + */ + @NotEmpty(message = "描述不能为空") + private String description; + /** + * 分类编号 + */ + @NotNull(message = "分类编号不能为空") + private Integer cid; + /** + * 商品主图地址 + */ + @NotEmpty(message = "商品主图地址不能为空") + private List picUrls; + /** + * 是否上架商品 + */ + @NotNull(message = "是否上架商品不能为空") + private Integer visible; + /** + * 排序字段 + */ + @NotNull(message = "排序字段不能为空") + private Integer sort; + /** + * 价格 + */ + @NotNull(message = "价格不能为空") + private Integer price; + /** + * 库存数量 + */ + @NotNull(message = "库存数量不能为空") + private Integer quantity; + +} diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/convert/spu/ProductSpuConvert.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/convert/spu/ProductSpuConvert.java new file mode 100644 index 000000000..bc2b0e042 --- /dev/null +++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/convert/spu/ProductSpuConvert.java @@ -0,0 +1,46 @@ +package cn.iocoder.mall.productservice.convert.spu; + +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.productservice.dal.mysql.dataobject.spu.ProductSpuDO; +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 cn.iocoder.mall.productservice.service.spu.bo.ProductSpuBO; +import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuCreateBO; +import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuPageBO; +import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuUpdateBO; +import com.baomidou.mybatisplus.core.metadata.IPage; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +@Mapper +public interface ProductSpuConvert { + + ProductSpuConvert INSTANCE = Mappers.getMapper(ProductSpuConvert.class); + + ProductSpuDO convert(ProductSpuCreateBO bean); + + ProductSpuBO convert(ProductSpuDO bean); + + ProductSpuDO convert(ProductSpuUpdateBO bean); + + List convertList(List list); + + PageResult convertPage(IPage page); + + ProductSpuCreateBO convert(ProductSpuCreateReqDTO bean); + + ProductSpuUpdateBO convert(ProductSpuUpdateReqDTO bean); + + ProductSpuRespDTO convert(ProductSpuBO bean); + + List convertList02(List list); + + ProductSpuPageBO convert(ProductSpuPageReqDTO bean); + + PageResult convertPage(PageResult page); + +} diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/spu/ProductSkuDO.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/dataobject/spu/ProductSkuDO.java similarity index 90% rename from product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/spu/ProductSkuDO.java rename to product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/dataobject/spu/ProductSkuDO.java index bf800bb52..9f7d7e66c 100644 --- a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/spu/ProductSkuDO.java +++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/dataobject/spu/ProductSkuDO.java @@ -1,7 +1,6 @@ -package cn.iocoder.mall.product.biz.dataobject.spu; +package cn.iocoder.mall.productservice.dal.mysql.dataobject.spu; import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO; -import cn.iocoder.mall.product.biz.dataobject.attr.ProductAttrDO; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; diff --git a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/spu/ProductSpuDO.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/dataobject/spu/ProductSpuDO.java similarity index 91% rename from product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/spu/ProductSpuDO.java rename to product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/dataobject/spu/ProductSpuDO.java index d75731c04..7e9dfb4f3 100644 --- a/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/dataobject/spu/ProductSpuDO.java +++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/dataobject/spu/ProductSpuDO.java @@ -1,7 +1,8 @@ -package cn.iocoder.mall.product.biz.dataobject.spu; +package cn.iocoder.mall.productservice.dal.mysql.dataobject.spu; import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; /** @@ -10,6 +11,7 @@ import lombok.experimental.Accessors; * TODO 芋艿,后面增加商品普通参数。例如说,正面材料,背面材料,屏幕尺寸。 */ @Data +@EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class ProductSpuDO extends DeletableDO { diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/mapper/spu/ProductSpuMapper.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/mapper/spu/ProductSpuMapper.java new file mode 100644 index 000000000..dadd89d0c --- /dev/null +++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/mapper/spu/ProductSpuMapper.java @@ -0,0 +1,27 @@ +package cn.iocoder.mall.productservice.dal.mysql.mapper.spu; + +import cn.iocoder.mall.mybatis.core.query.QueryWrapperX; +import cn.iocoder.mall.productservice.dal.mysql.dataobject.spu.ProductSpuDO; +import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuPageBO; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.stereotype.Repository; + +@Repository +public interface ProductSpuMapper extends BaseMapper { + + default IPage selectPage(ProductSpuPageBO pageBO) { + QueryWrapperX query = new QueryWrapperX().likeIfPresent("name", pageBO.getName()); + // 库存过滤 + if (pageBO.getHasQuantity() != null) { + if (pageBO.getHasQuantity()) { + query.gt("quantity", 0); + } else { + query.eq("quantity", 0); + } + } + return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()), query); + } + +} diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/manager/spu/ProductSpuManager.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/manager/spu/ProductSpuManager.java new file mode 100644 index 000000000..7cd5f8228 --- /dev/null +++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/manager/spu/ProductSpuManager.java @@ -0,0 +1,77 @@ +package cn.iocoder.mall.productservice.manager.spu; + +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.productservice.convert.spu.ProductSpuConvert; +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 cn.iocoder.mall.productservice.service.spu.ProductSpuService; +import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuBO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** +* 商品 SPU Manager +*/ +@Service +public class ProductSpuManager { + + @Autowired + private ProductSpuService productSpuService; + + /** + * 创建商品 SPU + * + * @param createDTO 创建商品 SPU DTO + * @return 商品 SPU + */ + public Integer createProductSpu(ProductSpuCreateReqDTO createDTO) { + ProductSpuBO productSpuBO = productSpuService.createProductSpu(ProductSpuConvert.INSTANCE.convert(createDTO)); + return productSpuBO.getId(); + } + + /** + * 更新商品 SPU + * + * @param updateDTO 更新商品 SPU DTO + */ + public void updateProductSpu(ProductSpuUpdateReqDTO updateDTO) { + productSpuService.updateProductSpu(ProductSpuConvert.INSTANCE.convert(updateDTO)); + } + + /** + * 获得商品 SPU + * + * @param productSpuId 商品 SPU编号 + * @return 商品 SPU + */ + public ProductSpuRespDTO getProductSpu(Integer productSpuId) { + ProductSpuBO productSpuBO = productSpuService.getProductSpu(productSpuId); + return ProductSpuConvert.INSTANCE.convert(productSpuBO); + } + + /** + * 获得商品 SPU列表 + * + * @param productSpuIds 商品 SPU编号列表 + * @return 商品 SPU列表 + */ + public List listProductSpus(List productSpuIds) { + List productSpuBOs = productSpuService.listProductSpus(productSpuIds); + return ProductSpuConvert.INSTANCE.convertList02(productSpuBOs); + } + + /** + * 获得商品 SPU分页 + * + * @param pageDTO 商品 SPU分页查询 + * @return 商品 SPU分页结果 + */ + public PageResult pageProductSpu(ProductSpuPageReqDTO pageDTO) { + PageResult pageResultBO = productSpuService.pageProductSpu(ProductSpuConvert.INSTANCE.convert(pageDTO)); + return ProductSpuConvert.INSTANCE.convertPage(pageResultBO); + } +} diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/spu/ProductSpuRpcImpl.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/spu/ProductSpuRpcImpl.java new file mode 100644 index 000000000..cb289c1fd --- /dev/null +++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/spu/ProductSpuRpcImpl.java @@ -0,0 +1,52 @@ +package cn.iocoder.mall.productservice.rpc.spu; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.productservice.manager.spu.ProductSpuManager; +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.apache.dubbo.config.annotation.Service; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.List; + +import static cn.iocoder.common.framework.vo.CommonResult.success; + +/** +* 商品 SPU Rpc 实现类 +*/ +@Service(version = "${dubbo.provider.ProductSpuRpc.version}") +public class ProductSpuRpcImpl implements ProductSpuRpc { + + @Autowired + private ProductSpuManager productSpuManager; + + @Override + public CommonResult createProductSpu(ProductSpuCreateReqDTO createDTO) { + return success(productSpuManager.createProductSpu(createDTO)); + } + + @Override + public CommonResult updateProductSpu(ProductSpuUpdateReqDTO updateDTO) { + productSpuManager.updateProductSpu(updateDTO); + return success(true); + } + + @Override + public CommonResult getProductSpu(Integer productSpuId) { + return success(productSpuManager.getProductSpu(productSpuId)); + } + + @Override + public CommonResult> listProductSpus(List productSpuIds) { + return success(productSpuManager.listProductSpus(productSpuIds)); + } + + @Override + public CommonResult> pageProductSpu(ProductSpuPageReqDTO pageDTO) { + return success(productSpuManager.pageProductSpu(pageDTO)); + } + +} diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/spu/ProductSpuService.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/spu/ProductSpuService.java new file mode 100644 index 000000000..773e5a9d3 --- /dev/null +++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/spu/ProductSpuService.java @@ -0,0 +1,94 @@ +package cn.iocoder.mall.productservice.service.spu; + +import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.productservice.convert.spu.ProductSpuConvert; +import cn.iocoder.mall.productservice.dal.mysql.dataobject.spu.ProductSpuDO; +import cn.iocoder.mall.productservice.dal.mysql.mapper.spu.ProductSpuMapper; +import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuBO; +import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuCreateBO; +import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuPageBO; +import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuUpdateBO; +import com.baomidou.mybatisplus.core.metadata.IPage; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.validation.Valid; +import java.util.List; + +import static cn.iocoder.mall.productservice.enums.ProductErrorCodeConstants.PRODUCT_SPU_NOT_EXISTS; + +/** +* 商品 SPU Service +*/ +@Service +@Validated +public class ProductSpuService { + + @Autowired + private ProductSpuMapper productSpuMapper; + + /** + * 创建商品 SPU + * + * @param createBO 创建商品 SPU BO + * @return 商品 SPU + */ + public ProductSpuBO createProductSpu(@Valid ProductSpuCreateBO createBO) { + // 插入到数据库 + ProductSpuDO productSpuDO = ProductSpuConvert.INSTANCE.convert(createBO); + productSpuMapper.insert(productSpuDO); + // 返回 + return ProductSpuConvert.INSTANCE.convert(productSpuDO); + } + + /** + * 更新商品 SPU + * + * @param updateBO 更新商品 SPU BO + */ + public void updateProductSpu(@Valid ProductSpuUpdateBO updateBO) { + // 校验更新的商品 SPU是否存在 + if (productSpuMapper.selectById(updateBO.getId()) == null) { + throw ServiceExceptionUtil.exception(PRODUCT_SPU_NOT_EXISTS); + } + // 更新到数据库 + ProductSpuDO updateObject = ProductSpuConvert.INSTANCE.convert(updateBO); + productSpuMapper.updateById(updateObject); + } + + /** + * 获得商品 SPU + * + * @param productSpuId 商品 SPU编号 + * @return 商品 SPU + */ + public ProductSpuBO getProductSpu(Integer productSpuId) { + ProductSpuDO productSpuDO = productSpuMapper.selectById(productSpuId); + return ProductSpuConvert.INSTANCE.convert(productSpuDO); + } + + /** + * 获得商品 SPU列表 + * + * @param productSpuIds 商品 SPU编号列表 + * @return 商品 SPU列表 + */ + public List listProductSpus(List productSpuIds) { + List productSpuDOs = productSpuMapper.selectBatchIds(productSpuIds); + return ProductSpuConvert.INSTANCE.convertList(productSpuDOs); + } + + /** + * 获得商品 SPU分页 + * + * @param pageBO 商品 SPU分页查询 + * @return 商品 SPU分页结果 + */ + public PageResult pageProductSpu(ProductSpuPageBO pageBO) { + IPage productSpuDOPage = productSpuMapper.selectPage(pageBO); + return ProductSpuConvert.INSTANCE.convertPage(productSpuDOPage); + } + +} diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/spu/bo/ProductSpuBO.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/spu/bo/ProductSpuBO.java new file mode 100644 index 000000000..d752180c6 --- /dev/null +++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/spu/bo/ProductSpuBO.java @@ -0,0 +1,61 @@ +package cn.iocoder.mall.productservice.service.spu.bo; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; +import java.util.List; + +/** +* 商品 SPU 信息 BO +*/ +@Data +@Accessors(chain = true) +public class ProductSpuBO { + + /** + * 商品 SPU 编号 + */ + private Integer id; + /** + * SPU 名字 + */ + private String name; + /** + * 卖点 + */ + private String sellPoint; + /** + * 描述 + */ + private String description; + /** + * 分类编号 + */ + private Integer cid; + /** + * 商品主图地址 + */ + private List picUrls; + /** + * 是否上架商品 + */ + private Integer visible; + /** + * 排序字段 + */ + private Integer sort; + /** + * 价格 + */ + private Integer price; + /** + * 库存数量 + */ + private Integer quantity; + /** + * 创建时间 + */ + private Date createTime; + +} diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/spu/bo/ProductSpuCreateBO.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/spu/bo/ProductSpuCreateBO.java new file mode 100644 index 000000000..60f1892d5 --- /dev/null +++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/spu/bo/ProductSpuCreateBO.java @@ -0,0 +1,63 @@ +package cn.iocoder.mall.productservice.service.spu.bo; + +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.List; + +/** +* 商品 SPU 创建 BO +*/ +@Data +@Accessors(chain = true) +public class ProductSpuCreateBO { + + /** + * SPU 名字 + */ + @NotEmpty(message = "SPU 名字不能为空") + private String name; + /** + * 卖点 + */ + @NotEmpty(message = "卖点不能为空") + private String sellPoint; + /** + * 描述 + */ + @NotEmpty(message = "描述不能为空") + private String description; + /** + * 分类编号 + */ + @NotNull(message = "分类编号不能为空") + private Integer cid; + /** + * 商品主图地址 + */ + @NotEmpty(message = "商品主图地址不能为空") + private List picUrls; + /** + * 是否上架商品 + */ + @NotNull(message = "是否上架商品不能为空") + private Integer visible; + /** + * 排序字段 + */ + @NotNull(message = "排序字段不能为空") + private Integer sort; + /** + * 价格 + */ + @NotNull(message = "价格不能为空") + private Integer price; + /** + * 库存数量 + */ + @NotNull(message = "库存数量不能为空") + private Integer quantity; + +} diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/spu/bo/ProductSpuPageBO.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/spu/bo/ProductSpuPageBO.java new file mode 100644 index 000000000..46444b261 --- /dev/null +++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/spu/bo/ProductSpuPageBO.java @@ -0,0 +1,25 @@ +package cn.iocoder.mall.productservice.service.spu.bo; + +import cn.iocoder.common.framework.vo.PageParam; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** +* 商品 SPU 分页 BO +*/ +@Data +@EqualsAndHashCode(callSuper = true) +@Accessors(chain = true) +public class ProductSpuPageBO extends PageParam { + + /** + * SPU 名字 + */ + private String name; + /** + * 是否有库存 + */ + private Boolean hasQuantity; + +} diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/spu/bo/ProductSpuUpdateBO.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/spu/bo/ProductSpuUpdateBO.java new file mode 100644 index 000000000..aaf1faa36 --- /dev/null +++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/spu/bo/ProductSpuUpdateBO.java @@ -0,0 +1,68 @@ +package cn.iocoder.mall.productservice.service.spu.bo; + +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.List; + +/** +* 商品 SPU 更新 BO +*/ +@Data +@Accessors(chain = true) +public class ProductSpuUpdateBO { + + /** + * 商品 SPU 编号 + */ + @NotNull(message = "商品 SPU 编号不能为空") + private Integer id; + /** + * SPU 名字 + */ + @NotEmpty(message = "SPU 名字不能为空") + private String name; + /** + * 卖点 + */ + @NotEmpty(message = "卖点不能为空") + private String sellPoint; + /** + * 描述 + */ + @NotEmpty(message = "描述不能为空") + private String description; + /** + * 分类编号 + */ + @NotNull(message = "分类编号不能为空") + private Integer cid; + /** + * 商品主图地址 + */ + @NotEmpty(message = "商品主图地址不能为空") + private List picUrls; + /** + * 是否上架商品 + */ + @NotNull(message = "是否上架商品不能为空") + private Integer visible; + /** + * 排序字段 + */ + @NotNull(message = "排序字段不能为空") + private Integer sort; + /** + * 价格 + */ + @NotNull(message = "价格不能为空") + private Integer price; + /** + * 库存数量 + */ + @NotNull(message = "库存数量不能为空") + private Integer quantity; + +} diff --git a/product-service-project/product-service-app/src/main/resources/application.yaml b/product-service-project/product-service-app/src/main/resources/application.yaml index 1216dffa9..f79c0380a 100644 --- a/product-service-project/product-service-app/src/main/resources/application.yaml +++ b/product-service-project/product-service-app/src/main/resources/application.yaml @@ -38,6 +38,8 @@ dubbo: version: 1.0.0 ProductBrandRpc: version: 1.0.0 + ProductSpuRpc: + version: 1.0.0 # Dubbo 服务消费者的配置 consumer: ErrorCodeRpc: diff --git a/product/pom.xml b/product/pom.xml index eaf283845..4926a772e 100644 --- a/product/pom.xml +++ b/product/pom.xml @@ -14,13 +14,10 @@ pom - product-application product-rpc-api product-rpc product-rest product-biz - product-biz-api - product-mq diff --git a/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductSkuDO.java b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductSkuDO.java deleted file mode 100644 index 85ac8d80e..000000000 --- a/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductSkuDO.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.mall.product.dataobject; - -import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO; -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * 商品 SKU - */ -@Data -@Accessors(chain = true) -public class ProductSkuDO extends DeletableDO { - - /** - * sku 编号 - */ - private Integer id; - /** - * 商品编号 - */ - private Integer spuId; - - // TODO 店铺编号 - - /** - * 状态 - * - * 1-正常 - * 2-禁用 - */ - private Integer status; - /** - * 图片地址 - */ - private String picUrl; - /** - * 规格值({@link ProductAttrDO})数组 - * - * 数组,以逗号分隔 - */ - private String attrs; - /** - * 价格,单位:分 - */ - private Integer price; - /** - * 库存数量 - */ - private Integer quantity; -// /** -// * 商品在付款减库存的状态下,该Sku上未付款的订单数量 -// */ -// private Integer withHoldQuantity; -// /** -// * 销量 -// */ -// private Integer soldNum; - -} diff --git a/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductSpuDO.java b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductSpuDO.java deleted file mode 100644 index 18aa70805..000000000 --- a/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductSpuDO.java +++ /dev/null @@ -1,78 +0,0 @@ -package cn.iocoder.mall.product.dataobject; - -import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO; -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * 商品 SPU - * - * TODO 芋艿,后面增加商品普通参数。例如说,正面材料,背面材料,屏幕尺寸。 - */ -@Data -@Accessors(chain = true) -public class ProductSpuDO extends DeletableDO { - - /** - * SPU 编号 - */ - private Integer id; - - // TODO 店铺编号 先不考虑,因为第一个版本,不做 B2B2C - - // ========== 基本信息 ========= - /** - * SPU 名字 - */ - private String name; - /** - * 卖点 - */ - private String sellPoint; - /** - * 描述 - */ - private String description; - /** - * 分类编号 - */ - private Integer cid; - /** - * 商品主图地址 - * - * 数组,以逗号分隔 - * - * 建议尺寸:800*800像素,你可以拖拽图片调整顺序,最多上传15张 - */ - private String picUrls; - - // TODO 运费信息 - - // ========== 其他信息 ========= - /** - * 是否上架商品(是否可见)。 - * - * true 为已上架 - * false 为已下架 - */ - private Boolean visible; - /** - * 排序字段 - */ - private Integer sort; - - // ========== Sku 相关字段 ========= - /** - * 价格 - * - * 目前的计算方式是,以 Sku 最小价格为准 - */ - private Integer price; - /** - * 库存数量 - * - * 目前的计算方式是,以 Sku 库存累加为准 - */ - private Integer quantity; - -} diff --git a/product/product-start/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductCategoryController.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductCategoryController.java deleted file mode 100644 index 8e2b6603a..000000000 --- a/product/product-start/src/main/java/cn/iocoder/mall/product/application/controller/users/UsersProductCategoryController.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.mall.product.application.controller.users; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.product.api.ProductCategoryService; -import cn.iocoder.mall.product.api.bo.ProductCategoryBO; -import cn.iocoder.mall.product.application.convert.ProductCategoryConvert; -import cn.iocoder.mall.product.application.vo.users.UsersProductCategoryVO; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiOperation; -import org.apache.dubbo.config.annotation.Reference; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; - -@RestController -@RequestMapping("users/category") -@Api("商品分类") -public class UsersProductCategoryController { - - @Reference(validation = "true", version = "${dubbo.provider.ProductCategoryService.version}") - @Autowired - private ProductCategoryService productCategoryService; - - @GetMapping("/list") - @ApiOperation("获得指定编号下的子分类的数组") - @ApiImplicitParam(name = "pid", value = "指定分类编号", required = true, example = "0") - public CommonResult> list(@RequestParam("pid") Integer pid) { - List result = productCategoryService.getListByPid(pid); - return CommonResult.success(ProductCategoryConvert.Users.INSTANCE.convertToVO(result)); - } - -} diff --git a/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductCategoryVO.java b/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductCategoryVO.java deleted file mode 100644 index 57b158e02..000000000 --- a/product/product-start/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductCategoryVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.mall.product.application.vo.users; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.experimental.Accessors; - -@ApiModel("商品分类(简单)") -@Data -@Accessors(chain = true) -public class UsersProductCategoryVO { - - @ApiModelProperty(value = "分类编号", required = true, example = "1") - private Integer id; - @ApiModelProperty(value = "分类名", required = true, example = "手机") - private String name; - @ApiModelProperty(value = "分类图片", notes = "一般情况下,只有根分类才有图片", example = "http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg") - private String picUrl; - -}