From 90047c10d7fdd102ea44b35323dd0691a3ae547a Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Tue, 28 Jul 2020 23:58:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E8=A7=84=E6=A0=BC=20value=20?= =?UTF-8?q?=E7=9A=84=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/ProductAttrController.java | 34 ++++++-- .../vo/attr/ProductAttrValueCreateReqVO.java | 28 +++++++ .../vo/attr/ProductAttrValueRespVO.java | 22 +++++ .../vo/attr/ProductAttrValueUpdateReqVO.java | 28 +++++++ .../convert/product/ProductAttrConvert.java | 37 ++++++++ .../product/ProductAttrKeyConvert.java | 34 -------- .../product/ProductAttrKeyManager.java | 78 ++++++++++++----- .../rpc/attr/ProductAttrRpc.java | 43 +++++++--- .../attr/dto/ProductAttrKeyCreateReqDTO.java | 3 + .../attr/dto/ProductAttrKeyUpdateReqDTO.java | 3 + .../dto/ProductAttrValueCreateReqDTO.java | 36 ++++++++ .../rpc/attr/dto/ProductAttrValueRespDTO.java | 37 ++++++++ .../dto/ProductAttrValueUpdateReqDTO.java | 44 ++++++++++ .../convert/attr/ProductAttrConvert.java | 27 ++++-- .../dataobject/attr/ProductAttrValueDO.java | 8 +- .../mapper/attr/ProductAttrValueMapper.java | 4 + .../manager/attr/ProductAttrManager.java | 57 ++++++++++--- .../rpc/attr/ProductAttrRpcImpl.java | 32 ++++--- .../service/attr/ProductAttrService.java | 84 +++++++++++++++---- .../service/attr/bo/ProductAttrValueBO.java | 36 ++++++++ .../attr/bo/ProductAttrValueCreateBO.java | 35 ++++++++ .../attr/bo/ProductAttrValueUpdateBO.java | 41 +++++++++ .../product/dataobject/ProductAttrDO.java | 30 ------- .../dataobject/ProductAttrValueDO.java | 34 -------- 24 files changed, 630 insertions(+), 185 deletions(-) create mode 100644 management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/attr/ProductAttrValueCreateReqVO.java create mode 100644 management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/attr/ProductAttrValueRespVO.java create mode 100644 management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/attr/ProductAttrValueUpdateReqVO.java create mode 100644 management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/product/ProductAttrConvert.java delete mode 100644 management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/product/ProductAttrKeyConvert.java create mode 100644 product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/dto/ProductAttrValueCreateReqDTO.java create mode 100644 product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/dto/ProductAttrValueRespDTO.java create mode 100644 product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/dto/ProductAttrValueUpdateReqDTO.java create mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/attr/bo/ProductAttrValueBO.java create mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/attr/bo/ProductAttrValueCreateBO.java create mode 100644 product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/attr/bo/ProductAttrValueUpdateBO.java delete mode 100644 product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductAttrDO.java delete mode 100644 product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductAttrValueDO.java diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductAttrController.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductAttrController.java index aa1a589c9..aed155397 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductAttrController.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductAttrController.java @@ -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 createProductAttrValue(@Valid ProductAttrValueCreateReqVO createVO) { + return success(productAttrKeyManager.createProductAttrValue(createVO)); + } + + @PostMapping("/value/update") + @ApiOperation("更新商品规格值") + public CommonResult updateProductAttrValue(@Valid ProductAttrValueUpdateReqVO updateVO) { + productAttrKeyManager.updateProductAttrValue(updateVO); + return success(true); + } + + @GetMapping("/value/get") + @ApiOperation("获得商品规格值") + @ApiImplicitParam(name = "productAttrValueId", value = "商品规格值编号", required = true) + public CommonResult getProductAttrValue(@RequestParam("productAttrValueId") Integer productAttrValueId) { + return success(productAttrKeyManager.getProductAttrValue(productAttrValueId)); + } + + @GetMapping("/value/list") + @ApiOperation("获得商品规格值列表") + @ApiImplicitParam(name = "productAttrValueIds", value = "商品规格值编号列表", required = true) + public CommonResult> listProductAttrValues(@RequestParam("productAttrValueIds") List productAttrValueIds) { + return success(productAttrKeyManager.listProductAttrValues(productAttrValueIds)); + } + } diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/attr/ProductAttrValueCreateReqVO.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/attr/ProductAttrValueCreateReqVO.java new file mode 100644 index 000000000..b1c2e6ea9 --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/attr/ProductAttrValueCreateReqVO.java @@ -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; + +} + diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/attr/ProductAttrValueRespVO.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/attr/ProductAttrValueRespVO.java new file mode 100644 index 000000000..77b3ba654 --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/attr/ProductAttrValueRespVO.java @@ -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; + +} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/attr/ProductAttrValueUpdateReqVO.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/attr/ProductAttrValueUpdateReqVO.java new file mode 100644 index 000000000..3a77de78a --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/vo/attr/ProductAttrValueUpdateReqVO.java @@ -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; + +} + diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/product/ProductAttrConvert.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/product/ProductAttrConvert.java new file mode 100644 index 000000000..a6ee07584 --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/product/ProductAttrConvert.java @@ -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 convertList(List list); + + PageResult convertPage(PageResult page); + + ProductAttrKeyPageReqDTO convert(ProductAttrKeyPageReqVO bean); + + + ProductAttrValueCreateReqDTO convert(ProductAttrValueCreateReqVO bean); + + ProductAttrValueUpdateReqDTO convert(ProductAttrValueUpdateReqVO bean); + + ProductAttrValueRespVO convert(ProductAttrValueRespDTO bean); + + List convertList02(List list); + +} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/product/ProductAttrKeyConvert.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/product/ProductAttrKeyConvert.java deleted file mode 100644 index 693de6dd0..000000000 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/product/ProductAttrKeyConvert.java +++ /dev/null @@ -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 convertList(List list); - - PageResult convertPage(PageResult page); - - ProductAttrKeyPageReqDTO convert(ProductAttrKeyPageReqVO bean); - -} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductAttrKeyManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductAttrKeyManager.java index 37510922d..c724b7826 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductAttrKeyManager.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductAttrKeyManager.java @@ -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 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 updateProductAttrKeyResult = productAttrKeyRpc.updateProductAttrKey( - ProductAttrKeyConvert.INSTANCE.convert(updateVO)); + ProductAttrConvert.INSTANCE.convert(updateVO)); updateProductAttrKeyResult.checkError(); } - /** - * 删除商品规格键 - * - * @param productAttrKeyId 商品规格键编号 - */ - public void deleteProductAttrKey(Integer productAttrKeyId) { - CommonResult deleteProductAttrKeyResult = productAttrKeyRpc.deleteProductAttrKey(productAttrKeyId); - deleteProductAttrKeyResult.checkError(); - } - /** * 获得商品规格键 * @@ -66,7 +54,7 @@ public class ProductAttrKeyManager { public ProductAttrKeyRespVO getProductAttrKey(Integer productAttrKeyId) { CommonResult 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 listProductAttrKeys(List productAttrKeyIds) { CommonResult> 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 pageProductAttrKey(ProductAttrKeyPageReqVO pageVO) { CommonResult> 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 createProductAttrValueResult = productAttrKeyRpc.createProductAttrValue( + ProductAttrConvert.INSTANCE.convert(createVO)); + createProductAttrValueResult.checkError(); + return createProductAttrValueResult.getData(); + } + + /** + * 更新商品规格值 + * + * @param updateVO 更新商品规格值 VO + */ + public void updateProductAttrValue(ProductAttrValueUpdateReqVO updateVO) { + CommonResult updateProductAttrValueResult = productAttrKeyRpc.updateProductAttrValue( + ProductAttrConvert.INSTANCE.convert(updateVO)); + updateProductAttrValueResult.checkError(); + } + + /** + * 获得商品规格值 + * + * @param productAttrValueId 商品规格值编号 + * @return 商品规格值 + */ + public ProductAttrValueRespVO getProductAttrValue(Integer productAttrValueId) { + CommonResult getProductAttrValueResult = productAttrKeyRpc.getProductAttrValue(productAttrValueId); + getProductAttrValueResult.checkError(); + return ProductAttrConvert.INSTANCE.convert(getProductAttrValueResult.getData()); + } + + /** + * 获得商品规格值列表 + * + * @param productAttrValueIds 商品规格值编号列表 + * @return 商品规格值列表 + */ + public List listProductAttrValues(List productAttrValueIds) { + CommonResult> listProductAttrValueResult = productAttrKeyRpc.listProductAttrValues(productAttrValueIds); + listProductAttrValueResult.checkError(); + return ProductAttrConvert.INSTANCE.convertList02(listProductAttrValueResult.getData()); } } diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/ProductAttrRpc.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/ProductAttrRpc.java index 81989b0ff..577660bac 100644 --- a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/ProductAttrRpc.java +++ b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/ProductAttrRpc.java @@ -2,10 +2,7 @@ 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.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 cn.iocoder.mall.productservice.rpc.attr.dto.*; import java.util.List; @@ -29,13 +26,6 @@ public interface ProductAttrRpc { */ CommonResult updateProductAttrKey(ProductAttrKeyUpdateReqDTO updateDTO); - /** - * 删除商品规格键 - * - * @param productAttrKeyId 商品规格键编号 - */ - CommonResult deleteProductAttrKey(Integer productAttrKeyId); - /** * 获得商品规格键 * @@ -60,4 +50,35 @@ public interface ProductAttrRpc { */ CommonResult> pageProductAttrKey(ProductAttrKeyPageReqDTO pageDTO); + /** + * 创建商品规格值 + * + * @param createDTO 创建商品规格值 DTO + * @return 商品规格值编号 + */ + CommonResult createProductAttrValue(ProductAttrValueCreateReqDTO createDTO); + + /** + * 更新商品规格值 + * + * @param updateDTO 更新商品规格值 DTO + */ + CommonResult updateProductAttrValue(ProductAttrValueUpdateReqDTO updateDTO); + + /** + * 获得商品规格值 + * + * @param productAttrValueId 商品规格值编号 + * @return 商品规格值 + */ + CommonResult getProductAttrValue(Integer productAttrValueId); + + /** + * 获得商品规格值列表 + * + * @param productAttrValueIds 商品规格值编号列表 + * @return 商品规格值列表 + */ + CommonResult> listProductAttrValues(List productAttrValueIds); + } diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/dto/ProductAttrKeyCreateReqDTO.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/dto/ProductAttrKeyCreateReqDTO.java index 17dd0a69b..e28a4a736 100644 --- a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/dto/ProductAttrKeyCreateReqDTO.java +++ b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/dto/ProductAttrKeyCreateReqDTO.java @@ -1,5 +1,7 @@ package cn.iocoder.mall.productservice.rpc.attr.dto; +import cn.iocoder.common.framework.enums.CommonStatusEnum; +import cn.iocoder.common.framework.validator.InEnum; import lombok.Data; import lombok.experimental.Accessors; @@ -23,6 +25,7 @@ public class ProductAttrKeyCreateReqDTO implements Serializable { * 状态 */ @NotNull(message = "状态不能为空") + @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") private Integer status; } diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/dto/ProductAttrKeyUpdateReqDTO.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/dto/ProductAttrKeyUpdateReqDTO.java index c323943cf..7094628bf 100644 --- a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/dto/ProductAttrKeyUpdateReqDTO.java +++ b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/dto/ProductAttrKeyUpdateReqDTO.java @@ -1,5 +1,7 @@ package cn.iocoder.mall.productservice.rpc.attr.dto; +import cn.iocoder.common.framework.enums.CommonStatusEnum; +import cn.iocoder.common.framework.validator.InEnum; import lombok.Data; import lombok.experimental.Accessors; @@ -28,6 +30,7 @@ public class ProductAttrKeyUpdateReqDTO implements Serializable { * 状态 */ @NotNull(message = "状态不能为空") + @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") private Integer status; } diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/dto/ProductAttrValueCreateReqDTO.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/dto/ProductAttrValueCreateReqDTO.java new file mode 100644 index 000000000..439d8b299 --- /dev/null +++ b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/dto/ProductAttrValueCreateReqDTO.java @@ -0,0 +1,36 @@ +package cn.iocoder.mall.productservice.rpc.attr.dto; + +import cn.iocoder.common.framework.enums.CommonStatusEnum; +import cn.iocoder.common.framework.validator.InEnum; +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * 商品规格值创建 Request DTO + */ +@Data +@Accessors(chain = true) +public class ProductAttrValueCreateReqDTO implements Serializable { + + /** + * 规格键编号 + */ + @NotNull(message = "规格键编号不能为空") + private Integer attrKeyId; + /** + * 规格值名字 + */ + @NotEmpty(message = "规格值名字不能为空") + private String name; + /** + * 状态 + */ + @NotNull(message = "状态不能为空") + @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") + private Integer status; + +} diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/dto/ProductAttrValueRespDTO.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/dto/ProductAttrValueRespDTO.java new file mode 100644 index 000000000..dca795832 --- /dev/null +++ b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/dto/ProductAttrValueRespDTO.java @@ -0,0 +1,37 @@ +package cn.iocoder.mall.productservice.rpc.attr.dto; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; + +/** + * 商品规格值 Response DTO + */ +@Data +@Accessors(chain = true) +public class ProductAttrValueRespDTO implements Serializable { + + /** + * 规格值编号 + */ + private Integer id; + /** + * 规格键编号 + */ + private Integer attrKeyId; + /** + * 规格值名字 + */ + private String name; + /** + * 状态 + */ + private Integer status; + /** + * 创建时间 + */ + private Date createTime; + +} diff --git a/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/dto/ProductAttrValueUpdateReqDTO.java b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/dto/ProductAttrValueUpdateReqDTO.java new file mode 100644 index 000000000..69e455c11 --- /dev/null +++ b/product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/attr/dto/ProductAttrValueUpdateReqDTO.java @@ -0,0 +1,44 @@ +package cn.iocoder.mall.productservice.rpc.attr.dto; + +import cn.iocoder.common.framework.enums.CommonStatusEnum; +import cn.iocoder.common.framework.validator.InEnum; +import lombok.*; +import lombok.experimental.*; + +import io.swagger.annotations.*; + +import java.util.*; +import java.io.Serializable; + +import javax.validation.constraints.*; + +/** + * 商品规格值更新 Request DTO + */ +@Data +@Accessors(chain = true) +public class ProductAttrValueUpdateReqDTO implements Serializable { + + /** + * 规格值编号 + */ + @NotNull(message = "规格值编号不能为空") + private Integer id; + /** + * 规格键编号 + */ + @NotNull(message = "规格键编号不能为空") + private Integer attrKeyId; + /** + * 规格值名字 + */ + @NotEmpty(message = "规格值名字不能为空") + private String name; + /** + * 状态 + */ + @NotNull(message = "状态不能为空") + @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") + private Integer status; + +} diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/convert/attr/ProductAttrConvert.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/convert/attr/ProductAttrConvert.java index 90a55889e..b9a258e82 100644 --- a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/convert/attr/ProductAttrConvert.java +++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/convert/attr/ProductAttrConvert.java @@ -2,14 +2,9 @@ package cn.iocoder.mall.productservice.convert.attr; import cn.iocoder.common.framework.vo.PageResult; import cn.iocoder.mall.productservice.dal.mysql.dataobject.attr.ProductAttrKeyDO; -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 cn.iocoder.mall.productservice.service.attr.bo.ProductAttrKeyBO; -import cn.iocoder.mall.productservice.service.attr.bo.ProductAttrKeyCreateBO; -import cn.iocoder.mall.productservice.service.attr.bo.ProductAttrKeyPageBO; -import cn.iocoder.mall.productservice.service.attr.bo.ProductAttrKeyUpdateBO; +import cn.iocoder.mall.productservice.dal.mysql.dataobject.attr.ProductAttrValueDO; +import cn.iocoder.mall.productservice.rpc.attr.dto.*; +import cn.iocoder.mall.productservice.service.attr.bo.*; import com.baomidou.mybatisplus.core.metadata.IPage; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -43,4 +38,20 @@ public interface ProductAttrConvert { PageResult convertPage(PageResult page); + ProductAttrValueDO convert(ProductAttrValueCreateBO bean); + + ProductAttrValueBO convert(ProductAttrValueDO bean); + + ProductAttrValueDO convert(ProductAttrValueUpdateBO bean); + + List convertList03(List list); + + ProductAttrValueCreateBO convert(ProductAttrValueCreateReqDTO bean); + + ProductAttrValueUpdateBO convert(ProductAttrValueUpdateReqDTO bean); + + ProductAttrValueRespDTO convert(ProductAttrValueBO bean); + + List convertList04(List list); + } diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/dataobject/attr/ProductAttrValueDO.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/dataobject/attr/ProductAttrValueDO.java index 277c57e09..75bb844b2 100644 --- a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/dataobject/attr/ProductAttrValueDO.java +++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/dataobject/attr/ProductAttrValueDO.java @@ -21,11 +21,13 @@ public class ProductAttrValueDO extends DeletableDO { */ private Integer id; /** - * 规格编号 + * 规格键编号 + * + * 外键 {@link ProductAttrKeyDO#getId()} */ - private Integer attrId; + private Integer attrKeyId; /** - * 规格值 + * 规格值名字 */ private String name; /** diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/mapper/attr/ProductAttrValueMapper.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/mapper/attr/ProductAttrValueMapper.java index dd64788de..4915d134c 100644 --- a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/mapper/attr/ProductAttrValueMapper.java +++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/dal/mysql/mapper/attr/ProductAttrValueMapper.java @@ -1,11 +1,15 @@ package cn.iocoder.mall.productservice.dal.mysql.mapper.attr; import cn.iocoder.mall.productservice.dal.mysql.dataobject.attr.ProductAttrValueDO; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.springframework.stereotype.Repository; @Repository public interface ProductAttrValueMapper extends BaseMapper { + default ProductAttrValueDO selectByAttrKeyIdAndName(Integer attrKeyId, String name) { + return selectOne(new QueryWrapper().eq("attrKeyId", attrKeyId).eq("name", name)); + } } diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/manager/attr/ProductAttrManager.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/manager/attr/ProductAttrManager.java index 447356b87..b05ba37d0 100644 --- a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/manager/attr/ProductAttrManager.java +++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/manager/attr/ProductAttrManager.java @@ -2,12 +2,10 @@ package cn.iocoder.mall.productservice.manager.attr; import cn.iocoder.common.framework.vo.PageResult; import cn.iocoder.mall.productservice.convert.attr.ProductAttrConvert; -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 cn.iocoder.mall.productservice.rpc.attr.dto.*; import cn.iocoder.mall.productservice.service.attr.ProductAttrService; import cn.iocoder.mall.productservice.service.attr.bo.ProductAttrKeyBO; +import cn.iocoder.mall.productservice.service.attr.bo.ProductAttrValueBO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -42,15 +40,6 @@ public class ProductAttrManager { productAttrService.updateProductAttrKey(ProductAttrConvert.INSTANCE.convert(updateDTO)); } - /** - * 删除商品规格键 - * - * @param productAttrKeyId 商品规格键编号 - */ - public void deleteProductAttrKey(Integer productAttrKeyId) { - productAttrService.deleteProductAttrKey(productAttrKeyId); - } - /** * 获得商品规格键 * @@ -84,4 +73,46 @@ public class ProductAttrManager { return ProductAttrConvert.INSTANCE.convertPage(pageResultBO); } + /** + * 创建商品规格值 + * + * @param createDTO 创建商品规格值 DTO + * @return 商品规格值 + */ + public Integer createProductAttrValue(ProductAttrValueCreateReqDTO createDTO) { + ProductAttrValueBO productAttrValueBO = productAttrService.createProductAttrValue(ProductAttrConvert.INSTANCE.convert(createDTO)); + return productAttrValueBO.getId(); + } + + /** + * 更新商品规格值 + * + * @param updateDTO 更新商品规格值 DTO + */ + public void updateProductAttrValue(ProductAttrValueUpdateReqDTO updateDTO) { + productAttrService.updateProductAttrValue(ProductAttrConvert.INSTANCE.convert(updateDTO)); + } + + /** + * 获得商品规格值 + * + * @param productAttrValueId 商品规格值编号 + * @return 商品规格值 + */ + public ProductAttrValueRespDTO getProductAttrValue(Integer productAttrValueId) { + ProductAttrValueBO productAttrValueBO = productAttrService.getProductAttrValue(productAttrValueId); + return ProductAttrConvert.INSTANCE.convert(productAttrValueBO); + } + + /** + * 获得商品规格值列表 + * + * @param productAttrValueIds 商品规格值编号列表 + * @return 商品规格值列表 + */ + public List listProductAttrValues(List productAttrValueIds) { + List productAttrValueBOs = productAttrService.listProductAttrValues(productAttrValueIds); + return ProductAttrConvert.INSTANCE.convertList04(productAttrValueBOs); + } + } diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/attr/ProductAttrRpcImpl.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/attr/ProductAttrRpcImpl.java index a753af142..85ee0d1f8 100644 --- a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/attr/ProductAttrRpcImpl.java +++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/rpc/attr/ProductAttrRpcImpl.java @@ -3,10 +3,7 @@ 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.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 cn.iocoder.mall.productservice.rpc.attr.dto.*; import org.apache.dubbo.config.annotation.DubboService; import org.springframework.beans.factory.annotation.Autowired; @@ -34,12 +31,6 @@ public class ProductAttrRpcImpl implements ProductAttrRpc { return success(true); } - @Override - public CommonResult deleteProductAttrKey(Integer productAttrKeyId) { - productAttrManager.deleteProductAttrKey(productAttrKeyId); - return success(true); - } - @Override public CommonResult getProductAttrKey(Integer productAttrKeyId) { return success(productAttrManager.getProductAttrKey(productAttrKeyId)); @@ -55,4 +46,25 @@ public class ProductAttrRpcImpl implements ProductAttrRpc { return success(productAttrManager.pageProductAttrKey(pageDTO)); } + @Override + public CommonResult createProductAttrValue(ProductAttrValueCreateReqDTO createDTO) { + return success(productAttrManager.createProductAttrValue(createDTO)); + } + + @Override + public CommonResult updateProductAttrValue(ProductAttrValueUpdateReqDTO updateDTO) { + productAttrManager.updateProductAttrValue(updateDTO); + return success(true); + } + + @Override + public CommonResult getProductAttrValue(Integer productAttrValueId) { + return success(productAttrManager.getProductAttrValue(productAttrValueId)); + } + + @Override + public CommonResult> listProductAttrValues(List productAttrValueIds) { + return success(productAttrManager.listProductAttrValues(productAttrValueIds)); + } + } diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/attr/ProductAttrService.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/attr/ProductAttrService.java index 8121bc30d..dac4844c9 100644 --- a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/attr/ProductAttrService.java +++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/attr/ProductAttrService.java @@ -50,7 +50,7 @@ public class ProductAttrService { } } // 然后,校验规 Key - Set attrKeyIds = CollectionUtils.convertSet(attrValues, ProductAttrValueDO::getAttrId); + Set attrKeyIds = CollectionUtils.convertSet(attrValues, ProductAttrValueDO::getAttrKeyId); List attrKeys = productAttrKeyMapper.selectBatchIds(attrKeyIds); if (attrKeys.size() != attrKeyIds.size()) { throw ServiceExceptionUtil.exception(PRODUCT_ATTR_KEY_NOT_EXIST); @@ -66,7 +66,7 @@ public class ProductAttrService { Map attrKeyMap = CollectionUtils.convertMap(attrKeys, ProductAttrKeyDO::getId, attrKeyDO -> attrKeyDO); // ProductAttrDO 的映射,方便查找。 return attrValues.stream().map(attrValueDO -> new ProductAttrKeyValueBO() - .setAttrKeyId(attrValueDO.getAttrId()).setAttrKeyName(attrKeyMap.get(attrValueDO.getAttrId()).getName()) + .setAttrKeyId(attrValueDO.getAttrKeyId()).setAttrKeyName(attrKeyMap.get(attrValueDO.getAttrKeyId()).getName()) .setAttrValueId(attrValueDO.getId()).setAttrValueName(attrValueDO.getName())) .collect(Collectors.toList()); } @@ -109,20 +109,6 @@ public class ProductAttrService { productAttrKeyMapper.updateById(updateObject); } - /** - * 删除商品规格键 - * - * @param productAttrKeyId 商品规格键编号 - */ - public void deleteProductAttrKey(Integer productAttrKeyId) { - // 校验删除的商品规格键是否存在 - if (productAttrKeyMapper.selectById(productAttrKeyId) == null) { - throw ServiceExceptionUtil.exception(PRODUCT_ATTR_KEY_NOT_EXIST); - } - // 标记删除 - productAttrKeyMapper.deleteById(productAttrKeyId); - } - /** * 获得商品规格键 * @@ -156,4 +142,70 @@ public class ProductAttrService { return ProductAttrConvert.INSTANCE.convertPage(productAttrKeyDOPage); } + /** + * 创建商品规格值 + * + * @param createBO 创建商品规格值 BO + * @return 商品规格值 + */ + public ProductAttrValueBO createProductAttrValue(@Valid ProductAttrValueCreateBO createBO) { + // 校验规格键是否存在 + if (productAttrKeyMapper.selectById(createBO.getAttrKeyId()) == null) { + throw ServiceExceptionUtil.exception(PRODUCT_ATTR_KEY_NOT_EXIST); + } + // 校验规格值的名字是否重复 + if (productAttrValueMapper.selectByAttrKeyIdAndName(createBO.getAttrKeyId(), createBO.getName()) != null) { + throw ServiceExceptionUtil.exception(PRODUCT_ATTR_VALUE_EXISTS); + } + // 插入到数据库 + ProductAttrValueDO productAttrValueDO = ProductAttrConvert.INSTANCE.convert(createBO); + productAttrValueMapper.insert(productAttrValueDO); + // 返回 + return ProductAttrConvert.INSTANCE.convert(productAttrValueDO); + } + + /** + * 更新商品规格值 + * + * @param updateBO 更新商品规格值 BO + */ + public void updateProductAttrValue(@Valid ProductAttrValueUpdateBO updateBO) { + // 校验更新的商品规格值是否存在 + ProductAttrValueDO attrValueDO = productAttrValueMapper.selectById(updateBO.getId()); + if (attrValueDO == null) { + throw ServiceExceptionUtil.exception(PRODUCT_ATTR_VALUE_NOT_EXIST); + } + // 校验规格值的名字是否重复 + ProductAttrValueDO attrValueDOByName = productAttrValueMapper.selectByAttrKeyIdAndName( + attrValueDO.getAttrKeyId(), updateBO.getName()); + if (attrValueDOByName != null && !attrValueDOByName.getId().equals(updateBO.getId())) { + throw ServiceExceptionUtil.exception(PRODUCT_ATTR_VALUE_EXISTS); + } + // 更新到数据库 + ProductAttrValueDO updateObject = ProductAttrConvert.INSTANCE.convert(updateBO); + productAttrValueMapper.updateById(updateObject); + } + + /** + * 获得商品规格值 + * + * @param productAttrValueId 商品规格值编号 + * @return 商品规格值 + */ + public ProductAttrValueBO getProductAttrValue(Integer productAttrValueId) { + ProductAttrValueDO productAttrValueDO = productAttrValueMapper.selectById(productAttrValueId); + return ProductAttrConvert.INSTANCE.convert(productAttrValueDO); + } + + /** + * 获得商品规格值列表 + * + * @param productAttrValueIds 商品规格值编号列表 + * @return 商品规格值列表 + */ + public List listProductAttrValues(List productAttrValueIds) { + List productAttrValueDOs = productAttrValueMapper.selectBatchIds(productAttrValueIds); + return ProductAttrConvert.INSTANCE.convertList03(productAttrValueDOs); + } + } diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/attr/bo/ProductAttrValueBO.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/attr/bo/ProductAttrValueBO.java new file mode 100644 index 000000000..eefb3ff05 --- /dev/null +++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/attr/bo/ProductAttrValueBO.java @@ -0,0 +1,36 @@ +package cn.iocoder.mall.productservice.service.attr.bo; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; + +/** + * 商品规格值 BO + */ +@Data +@Accessors(chain = true) +public class ProductAttrValueBO { + + /** + * 规格值编号 + */ + private Integer id; + /** + * 规格键编号 + */ + private Integer attrKeyId; + /** + * 规格值名字 + */ + private String name; + /** + * 状态 + */ + private Integer status; + /** + * 创建时间 + */ + private Date createTime; + +} diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/attr/bo/ProductAttrValueCreateBO.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/attr/bo/ProductAttrValueCreateBO.java new file mode 100644 index 000000000..d9dfda20e --- /dev/null +++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/attr/bo/ProductAttrValueCreateBO.java @@ -0,0 +1,35 @@ +package cn.iocoder.mall.productservice.service.attr.bo; + +import cn.iocoder.common.framework.enums.CommonStatusEnum; +import cn.iocoder.common.framework.validator.InEnum; +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; + +/** + * 商品规格值创建 BO + */ +@Data +@Accessors(chain = true) +public class ProductAttrValueCreateBO { + + /** + * 规格键编号 + */ + @NotNull(message = "规格键编号不能为空") + private Integer attrKeyId; + /** + * 规格值名字 + */ + @NotEmpty(message = "规格值名字不能为空") + private String name; + /** + * 状态 + */ + @NotNull(message = "状态") + @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") + private Integer status; + +} diff --git a/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/attr/bo/ProductAttrValueUpdateBO.java b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/attr/bo/ProductAttrValueUpdateBO.java new file mode 100644 index 000000000..f0c0f2886 --- /dev/null +++ b/product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/service/attr/bo/ProductAttrValueUpdateBO.java @@ -0,0 +1,41 @@ +package cn.iocoder.mall.productservice.service.attr.bo; + + +import cn.iocoder.common.framework.enums.CommonStatusEnum; +import cn.iocoder.common.framework.validator.InEnum; +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; + +/** + * 商品规格值更新 BO + */ +@Data +@Accessors(chain = true) +public class ProductAttrValueUpdateBO { + + /** + * 规格值编号 + */ + @NotNull(message = "规格值编号不能为空") + private Integer id; + /** + * 规格键编号 + */ + @NotNull(message = "规格键编号不能为空") + private Integer attrKeyId; + /** + * 规格值名字 + */ + @NotEmpty(message = "规格值名字不能为空") + private String name; + /** + * 状态 + */ + @NotNull(message = "状态") + @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") + private Integer status; + +} diff --git a/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductAttrDO.java b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductAttrDO.java deleted file mode 100644 index 360fc9df8..000000000 --- a/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductAttrDO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.mall.product.dataobject; - -import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO; -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * Product 规格 - */ -@Data -@Accessors(chain = true) -public class ProductAttrDO extends DeletableDO { - - /** - * 规格编号 - */ - private Integer id; - /** - * 名称 - */ - private String name; - /** - * 状态 - * - * 1-开启 - * 2-禁用 - */ - private Integer status; - -} diff --git a/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductAttrValueDO.java b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductAttrValueDO.java deleted file mode 100644 index 5d9aba81b..000000000 --- a/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductAttrValueDO.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.mall.product.dataobject; - -import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO; -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * Product 规格值 - */ -@Data -@Accessors(chain = true) -public class ProductAttrValueDO extends DeletableDO { - - /** - * 规格值编号 - */ - private Integer id; - /** - * 规格编号 - */ - private Integer attrId; - /** - * 规格值 - */ - private String name; - /** - * 状态 - * - * 1-正常 - * 2-禁用 - */ - private Integer status; - -}