From 733a3c4615cf7e6ee23e0a16e2c74f4201e9389e Mon Sep 17 00:00:00 2001 From: shuaidawang Date: Thu, 19 May 2022 14:39:23 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=95=86=E5=93=81=E8=A7=84=E6=A0=BC?= =?UTF-8?q?=E5=AE=9E=E4=BD=93=E7=B1=BB=E5=A2=9E=E5=8A=A0Product=E5=89=8D?= =?UTF-8?q?=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...er.java => ProductPropertyController.java} | 47 +++++----- ...BaseVO.java => ProductPropertyBaseVO.java} | 2 +- ...O.java => ProductPropertyCreateReqVO.java} | 4 +- ...celVO.java => ProductPropertyExcelVO.java} | 2 +- ...O.java => ProductPropertyExportReqVO.java} | 2 +- ...qVO.java => ProductPropertyPageReqVO.java} | 2 +- ...RespVO.java => ProductPropertyRespVO.java} | 5 +- ...O.java => ProductPropertyUpdateReqVO.java} | 3 +- .../property/ProductPropertyConvert.java | 34 ++++++++ .../convert/property/PropertyConvert.java | 34 -------- ...PropertyDO.java => ProductPropertyDO.java} | 2 +- .../propertyvalue/PropertyValueDO.java | 4 +- .../mysql/property/ProductPropertyMapper.java | 36 ++++++++ .../dal/mysql/property/PropertyMapper.java | 36 -------- ...rvice.java => ProductPropertyService.java} | 16 ++-- .../property/ProductPropertyServiceImpl.java | 84 ++++++++++++++++++ .../service/property/PropertyServiceImpl.java | 85 ------------------- 17 files changed, 198 insertions(+), 200 deletions(-) rename yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/{PropertyController.java => ProductPropertyController.java} (63%) mode change 100755 => 100644 rename yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/{PropertyBaseVO.java => ProductPropertyBaseVO.java} (93%) mode change 100755 => 100644 rename yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/{PropertyCreateReqVO.java => ProductPropertyCreateReqVO.java} (68%) mode change 100755 => 100644 rename yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/{PropertyExcelVO.java => ProductPropertyExcelVO.java} (93%) mode change 100755 => 100644 rename yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/{PropertyExportReqVO.java => ProductPropertyExportReqVO.java} (95%) mode change 100755 => 100644 rename yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/{PropertyPageReqVO.java => ProductPropertyPageReqVO.java} (94%) mode change 100755 => 100644 rename yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/{PropertyRespVO.java => ProductPropertyRespVO.java} (65%) mode change 100755 => 100644 rename yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/{PropertyUpdateReqVO.java => ProductPropertyUpdateReqVO.java} (84%) mode change 100755 => 100644 create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyConvert.java delete mode 100755 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/PropertyConvert.java rename yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/{PropertyDO.java => ProductPropertyDO.java} (95%) mode change 100755 => 100644 create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java delete mode 100755 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/PropertyMapper.java rename yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/{PropertyService.java => ProductPropertyService.java} (70%) mode change 100755 => 100644 create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java delete mode 100755 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/PropertyServiceImpl.java diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/PropertyController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java old mode 100755 new mode 100644 similarity index 63% rename from yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/PropertyController.java rename to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java index b35e38ca0..c81cce984 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/PropertyController.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java @@ -1,12 +1,12 @@ package cn.iocoder.yudao.module.product.controller.admin.property; +import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import org.springframework.validation.annotation.Validated; import org.springframework.security.access.prepost.PreAuthorize; import io.swagger.annotations.*; -import javax.validation.constraints.*; import javax.validation.*; import javax.servlet.http.*; import java.util.*; @@ -22,31 +22,30 @@ import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; import cn.iocoder.yudao.module.product.controller.admin.property.vo.*; -import cn.iocoder.yudao.module.product.dal.dataobject.property.PropertyDO; -import cn.iocoder.yudao.module.product.convert.property.PropertyConvert; -import cn.iocoder.yudao.module.product.service.property.PropertyService; +import cn.iocoder.yudao.module.product.convert.property.ProductPropertyConvert; +import cn.iocoder.yudao.module.product.service.property.ProductPropertyService; @Api(tags = "管理后台 - 规格名称") @RestController @RequestMapping("/product/property") @Validated -public class PropertyController { +public class ProductPropertyController { @Resource - private PropertyService propertyService; + private ProductPropertyService productPropertyService; @PostMapping("/create") @ApiOperation("创建规格名称") @PreAuthorize("@ss.hasPermission('product:property:create')") - public CommonResult createProperty(@Valid @RequestBody PropertyCreateReqVO createReqVO) { - return success(propertyService.createProperty(createReqVO)); + public CommonResult createProperty(@Valid @RequestBody ProductPropertyCreateReqVO createReqVO) { + return success(productPropertyService.createProperty(createReqVO)); } @PutMapping("/update") @ApiOperation("更新规格名称") @PreAuthorize("@ss.hasPermission('product:property:update')") - public CommonResult updateProperty(@Valid @RequestBody PropertyUpdateReqVO updateReqVO) { - propertyService.updateProperty(updateReqVO); + public CommonResult updateProperty(@Valid @RequestBody ProductPropertyUpdateReqVO updateReqVO) { + productPropertyService.updateProperty(updateReqVO); return success(true); } @@ -55,7 +54,7 @@ public class PropertyController { @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) @PreAuthorize("@ss.hasPermission('product:property:delete')") public CommonResult deleteProperty(@RequestParam("id") Long id) { - propertyService.deleteProperty(id); + productPropertyService.deleteProperty(id); return success(true); } @@ -63,38 +62,38 @@ public class PropertyController { @ApiOperation("获得规格名称") @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) @PreAuthorize("@ss.hasPermission('product:property:query')") - public CommonResult getProperty(@RequestParam("id") Long id) { - PropertyDO property = propertyService.getProperty(id); - return success(PropertyConvert.INSTANCE.convert(property)); + public CommonResult getProperty(@RequestParam("id") Long id) { + ProductPropertyDO property = productPropertyService.getProperty(id); + return success(ProductPropertyConvert.INSTANCE.convert(property)); } @GetMapping("/list") @ApiOperation("获得规格名称列表") @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) @PreAuthorize("@ss.hasPermission('product:property:query')") - public CommonResult> getPropertyList(@RequestParam("ids") Collection ids) { - List list = propertyService.getPropertyList(ids); - return success(PropertyConvert.INSTANCE.convertList(list)); + public CommonResult> getPropertyList(@RequestParam("ids") Collection ids) { + List list = productPropertyService.getPropertyList(ids); + return success(ProductPropertyConvert.INSTANCE.convertList(list)); } @GetMapping("/page") @ApiOperation("获得规格名称分页") @PreAuthorize("@ss.hasPermission('product:property:query')") - public CommonResult> getPropertyPage(@Valid PropertyPageReqVO pageVO) { - PageResult pageResult = propertyService.getPropertyPage(pageVO); - return success(PropertyConvert.INSTANCE.convertPage(pageResult)); + public CommonResult> getPropertyPage(@Valid ProductPropertyPageReqVO pageVO) { + PageResult pageResult = productPropertyService.getPropertyPage(pageVO); + return success(ProductPropertyConvert.INSTANCE.convertPage(pageResult)); } @GetMapping("/export-excel") @ApiOperation("导出规格名称 Excel") @PreAuthorize("@ss.hasPermission('product:property:export')") @OperateLog(type = EXPORT) - public void exportPropertyExcel(@Valid PropertyExportReqVO exportReqVO, + public void exportPropertyExcel(@Valid ProductPropertyExportReqVO exportReqVO, HttpServletResponse response) throws IOException { - List list = propertyService.getPropertyList(exportReqVO); + List list = productPropertyService.getPropertyList(exportReqVO); // 导出 Excel - List datas = PropertyConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "规格名称.xls", "数据", PropertyExcelVO.class, datas); + List datas = ProductPropertyConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "规格名称.xls", "数据", ProductPropertyExcelVO.class, datas); } } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/PropertyBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyBaseVO.java old mode 100755 new mode 100644 similarity index 93% rename from yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/PropertyBaseVO.java rename to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyBaseVO.java index c04447920..4d38763f9 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/PropertyBaseVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyBaseVO.java @@ -10,7 +10,7 @@ import javax.validation.constraints.*; * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 */ @Data -public class PropertyBaseVO { +public class ProductPropertyBaseVO { @ApiModelProperty(value = "规格名称") private String name; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/PropertyCreateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyCreateReqVO.java old mode 100755 new mode 100644 similarity index 68% rename from yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/PropertyCreateReqVO.java rename to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyCreateReqVO.java index 4effd68b9..560771623 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/PropertyCreateReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyCreateReqVO.java @@ -1,14 +1,12 @@ package cn.iocoder.yudao.module.product.controller.admin.property.vo; import lombok.*; -import java.util.*; import io.swagger.annotations.*; -import javax.validation.constraints.*; @ApiModel("管理后台 - 规格名称创建 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class PropertyCreateReqVO extends PropertyBaseVO { +public class ProductPropertyCreateReqVO extends ProductPropertyBaseVO { } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/PropertyExcelVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyExcelVO.java old mode 100755 new mode 100644 similarity index 93% rename from yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/PropertyExcelVO.java rename to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyExcelVO.java index eb82e8512..c935c1001 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/PropertyExcelVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyExcelVO.java @@ -12,7 +12,7 @@ import com.alibaba.excel.annotation.ExcelProperty; * @author 芋道源码 */ @Data -public class PropertyExcelVO { +public class ProductPropertyExcelVO { @ExcelProperty("主键") private Long id; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/PropertyExportReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyExportReqVO.java old mode 100755 new mode 100644 similarity index 95% rename from yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/PropertyExportReqVO.java rename to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyExportReqVO.java index 0201ec5cf..e19ea2bfa --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/PropertyExportReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyExportReqVO.java @@ -10,7 +10,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @ApiModel(value = "管理后台 - 规格名称 Excel 导出 Request VO", description = "参数和 PropertyPageReqVO 是一致的") @Data -public class PropertyExportReqVO { +public class ProductPropertyExportReqVO { @ApiModelProperty(value = "规格名称") private String name; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/PropertyPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyPageReqVO.java old mode 100755 new mode 100644 similarity index 94% rename from yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/PropertyPageReqVO.java rename to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyPageReqVO.java index c6caf0b12..34d7239f2 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/PropertyPageReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyPageReqVO.java @@ -12,7 +12,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class PropertyPageReqVO extends PageParam { +public class ProductPropertyPageReqVO extends PageParam { @ApiModelProperty(value = "规格名称") private String name; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/PropertyRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyRespVO.java old mode 100755 new mode 100644 similarity index 65% rename from yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/PropertyRespVO.java rename to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyRespVO.java index 8b14f2ba2..2ef5c6efd --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/PropertyRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyRespVO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.product.controller.admin.property.vo; +import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.PropertyValueRespVO; import lombok.*; import java.util.*; import io.swagger.annotations.*; @@ -8,7 +9,7 @@ import io.swagger.annotations.*; @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class PropertyRespVO extends PropertyBaseVO { +public class ProductPropertyRespVO extends ProductPropertyBaseVO { @ApiModelProperty(value = "主键", required = true) private Long id; @@ -16,4 +17,6 @@ public class PropertyRespVO extends PropertyBaseVO { @ApiModelProperty(value = "创建时间") private Date createTime; + private List propertyValueRespVOList; + } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/PropertyUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyUpdateReqVO.java old mode 100755 new mode 100644 similarity index 84% rename from yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/PropertyUpdateReqVO.java rename to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyUpdateReqVO.java index 84b0b4ca7..f53d200d2 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/PropertyUpdateReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyUpdateReqVO.java @@ -1,7 +1,6 @@ package cn.iocoder.yudao.module.product.controller.admin.property.vo; import lombok.*; -import java.util.*; import io.swagger.annotations.*; import javax.validation.constraints.*; @@ -9,7 +8,7 @@ import javax.validation.constraints.*; @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class PropertyUpdateReqVO extends PropertyBaseVO { +public class ProductPropertyUpdateReqVO extends ProductPropertyBaseVO { @ApiModelProperty(value = "主键", required = true) @NotNull(message = "主键不能为空") diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyConvert.java new file mode 100644 index 000000000..c44cdc841 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyConvert.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.product.convert.property; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import cn.iocoder.yudao.module.product.controller.admin.property.vo.*; + +/** + * 规格名称 Convert + * + * @author 芋道源码 + */ +@Mapper +public interface ProductPropertyConvert { + + ProductPropertyConvert INSTANCE = Mappers.getMapper(ProductPropertyConvert.class); + + ProductPropertyDO convert(ProductPropertyCreateReqVO bean); + + ProductPropertyDO convert(ProductPropertyUpdateReqVO bean); + + ProductPropertyRespVO convert(ProductPropertyDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/PropertyConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/PropertyConvert.java deleted file mode 100755 index 520d7235e..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/PropertyConvert.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.product.convert.property; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.*; -import cn.iocoder.yudao.module.product.dal.dataobject.property.PropertyDO; - -/** - * 规格名称 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface PropertyConvert { - - PropertyConvert INSTANCE = Mappers.getMapper(PropertyConvert.class); - - PropertyDO convert(PropertyCreateReqVO bean); - - PropertyDO convert(PropertyUpdateReqVO bean); - - PropertyRespVO convert(PropertyDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - List convertList02(List list); - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/PropertyDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyDO.java old mode 100755 new mode 100644 similarity index 95% rename from yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/PropertyDO.java rename to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyDO.java index 7ff368800..2d91f6ba7 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/PropertyDO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyDO.java @@ -21,7 +21,7 @@ import lombok.*; @Builder @NoArgsConstructor @AllArgsConstructor -public class PropertyDO extends BaseDO { +public class ProductPropertyDO extends BaseDO { /** * 主键 diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/propertyvalue/PropertyValueDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/propertyvalue/PropertyValueDO.java index 083c4a485..07c7ea45b 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/propertyvalue/PropertyValueDO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/propertyvalue/PropertyValueDO.java @@ -1,7 +1,7 @@ package cn.iocoder.yudao.module.product.dal.dataobject.propertyvalue; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.product.dal.dataobject.property.PropertyDO; +import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; @@ -31,7 +31,7 @@ public class PropertyValueDO extends BaseDO { /** * 规格键 id * - * TODO @franky:加个 关联 {@link PropertyDO#getId()} ,这样就能更好的知道 + * TODO @franky:加个 关联 {@link ProductPropertyDO#getId()} ,这样就能更好的知道 */ private Long propertyId; /** diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java new file mode 100644 index 000000000..079b21c84 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/ProductPropertyMapper.java @@ -0,0 +1,36 @@ +package cn.iocoder.yudao.module.product.dal.mysql.property; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.product.controller.admin.property.vo.*; + +/** + * 规格名称 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface ProductPropertyMapper extends BaseMapperX { + + default PageResult selectPage(ProductPropertyPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(ProductPropertyDO::getName, reqVO.getName()) + .eqIfPresent(ProductPropertyDO::getStatus, reqVO.getStatus()) + .betweenIfPresent(ProductPropertyDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) + .orderByDesc(ProductPropertyDO::getId)); + } + + default List selectList(ProductPropertyExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .likeIfPresent(ProductPropertyDO::getName, reqVO.getName()) + .eqIfPresent(ProductPropertyDO::getStatus, reqVO.getStatus()) + .betweenIfPresent(ProductPropertyDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) + .orderByDesc(ProductPropertyDO::getId)); + } + +} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/PropertyMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/PropertyMapper.java deleted file mode 100755 index 3adb3cb1f..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/property/PropertyMapper.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.module.product.dal.mysql.property; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.product.dal.dataobject.property.PropertyDO; -import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.*; - -/** - * 规格名称 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface PropertyMapper extends BaseMapperX { - - default PageResult selectPage(PropertyPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(PropertyDO::getName, reqVO.getName()) - .eqIfPresent(PropertyDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(PropertyDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) - .orderByDesc(PropertyDO::getId)); - } - - default List selectList(PropertyExportReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(PropertyDO::getName, reqVO.getName()) - .eqIfPresent(PropertyDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(PropertyDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) - .orderByDesc(PropertyDO::getId)); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/PropertyService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java old mode 100755 new mode 100644 similarity index 70% rename from yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/PropertyService.java rename to yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java index e1e372a83..eb02796ce --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/PropertyService.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.product.service.property; import java.util.*; import javax.validation.*; import cn.iocoder.yudao.module.product.controller.admin.property.vo.*; -import cn.iocoder.yudao.module.product.dal.dataobject.property.PropertyDO; +import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; /** @@ -11,7 +11,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; * * @author 芋道源码 */ -public interface PropertyService { +public interface ProductPropertyService { /** * 创建规格名称 @@ -19,14 +19,14 @@ public interface PropertyService { * @param createReqVO 创建信息 * @return 编号 */ - Long createProperty(@Valid PropertyCreateReqVO createReqVO); + Long createProperty(@Valid ProductPropertyCreateReqVO createReqVO); /** * 更新规格名称 * * @param updateReqVO 更新信息 */ - void updateProperty(@Valid PropertyUpdateReqVO updateReqVO); + void updateProperty(@Valid ProductPropertyUpdateReqVO updateReqVO); /** * 删除规格名称 @@ -41,7 +41,7 @@ public interface PropertyService { * @param id 编号 * @return 规格名称 */ - PropertyDO getProperty(Long id); + ProductPropertyDO getProperty(Long id); /** * 获得规格名称列表 @@ -49,7 +49,7 @@ public interface PropertyService { * @param ids 编号 * @return 规格名称列表 */ - List getPropertyList(Collection ids); + List getPropertyList(Collection ids); /** * 获得规格名称分页 @@ -57,7 +57,7 @@ public interface PropertyService { * @param pageReqVO 分页查询 * @return 规格名称分页 */ - PageResult getPropertyPage(PropertyPageReqVO pageReqVO); + PageResult getPropertyPage(ProductPropertyPageReqVO pageReqVO); /** * 获得规格名称列表, 用于 Excel 导出 @@ -65,6 +65,6 @@ public interface PropertyService { * @param exportReqVO 查询条件 * @return 规格名称列表 */ - List getPropertyList(PropertyExportReqVO exportReqVO); + List getPropertyList(ProductPropertyExportReqVO exportReqVO); } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java new file mode 100644 index 000000000..cdddd3ce4 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java @@ -0,0 +1,84 @@ +package cn.iocoder.yudao.module.product.service.property; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.product.controller.admin.property.vo.*; +import cn.iocoder.yudao.module.product.controller.admin.property.vo.ProductPropertyCreateReqVO; +import cn.iocoder.yudao.module.product.controller.admin.property.vo.ProductPropertyUpdateReqVO; +import cn.iocoder.yudao.module.product.convert.property.ProductPropertyConvert; +import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; +import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyMapper; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.Collection; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_NOT_EXISTS; + +/** + * 规格名称 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class ProductPropertyServiceImpl implements ProductPropertyService { + + @Resource + private ProductPropertyMapper productPropertyMapper; + + @Override + public Long createProperty(ProductPropertyCreateReqVO createReqVO) { + // 插入 + ProductPropertyDO property = ProductPropertyConvert.INSTANCE.convert(createReqVO); + productPropertyMapper.insert(property); + // 返回 + return property.getId(); + } + + @Override + public void updateProperty(ProductPropertyUpdateReqVO updateReqVO) { + // 校验存在 + this.validatePropertyExists(updateReqVO.getId()); + // 更新 + ProductPropertyDO updateObj = ProductPropertyConvert.INSTANCE.convert(updateReqVO); + productPropertyMapper.updateById(updateObj); + } + + @Override + public void deleteProperty(Long id) { + // 校验存在 + this.validatePropertyExists(id); + // 删除 + productPropertyMapper.deleteById(id); + } + + private void validatePropertyExists(Long id) { + if (productPropertyMapper.selectById(id) == null) { + throw exception(PROPERTY_NOT_EXISTS); + } + } + + @Override + public ProductPropertyDO getProperty(Long id) { + return productPropertyMapper.selectById(id); + } + + @Override + public List getPropertyList(Collection ids) { + return productPropertyMapper.selectBatchIds(ids); + } + + @Override + public PageResult getPropertyPage(ProductPropertyPageReqVO pageReqVO) { + return productPropertyMapper.selectPage(pageReqVO); + } + + @Override + public List getPropertyList(ProductPropertyExportReqVO exportReqVO) { + return productPropertyMapper.selectList(exportReqVO); + } + +} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/PropertyServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/PropertyServiceImpl.java deleted file mode 100755 index ecb4543c3..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/PropertyServiceImpl.java +++ /dev/null @@ -1,85 +0,0 @@ -package cn.iocoder.yudao.module.product.service.property; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.PropertyCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.PropertyExportReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.PropertyPageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.PropertyUpdateReqVO; -import cn.iocoder.yudao.module.product.convert.property.PropertyConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.property.PropertyDO; -import cn.iocoder.yudao.module.product.dal.mysql.property.PropertyMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_NOT_EXISTS; - -/** - * 规格名称 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class PropertyServiceImpl implements PropertyService { - - @Resource - private PropertyMapper propertyMapper; - - @Override - public Long createProperty(PropertyCreateReqVO createReqVO) { - // 插入 - PropertyDO property = PropertyConvert.INSTANCE.convert(createReqVO); - propertyMapper.insert(property); - // 返回 - return property.getId(); - } - - @Override - public void updateProperty(PropertyUpdateReqVO updateReqVO) { - // 校验存在 - this.validatePropertyExists(updateReqVO.getId()); - // 更新 - PropertyDO updateObj = PropertyConvert.INSTANCE.convert(updateReqVO); - propertyMapper.updateById(updateObj); - } - - @Override - public void deleteProperty(Long id) { - // 校验存在 - this.validatePropertyExists(id); - // 删除 - propertyMapper.deleteById(id); - } - - private void validatePropertyExists(Long id) { - if (propertyMapper.selectById(id) == null) { - throw exception(PROPERTY_NOT_EXISTS); - } - } - - @Override - public PropertyDO getProperty(Long id) { - return propertyMapper.selectById(id); - } - - @Override - public List getPropertyList(Collection ids) { - return propertyMapper.selectBatchIds(ids); - } - - @Override - public PageResult getPropertyPage(PropertyPageReqVO pageReqVO) { - return propertyMapper.selectPage(pageReqVO); - } - - @Override - public List getPropertyList(PropertyExportReqVO exportReqVO) { - return propertyMapper.selectList(exportReqVO); - } - -} From a270db821d92adec4a8174f34b5fe0dd832abf9b Mon Sep 17 00:00:00 2001 From: shuaidawang Date: Thu, 19 May 2022 14:43:11 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E8=A7=84=E6=A0=BC=E5=8A=A0=E4=B8=AA?= =?UTF-8?q?=E6=9E=9A=E4=B8=BE=EF=BC=8C=E5=8E=BB=E6=8E=89TODO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/dal/dataobject/property/ProductPropertyDO.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyDO.java index 2d91f6ba7..5255c36ed 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyDO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyDO.java @@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.*; -// TODO @franky:每个表名,都加个 Product 前缀哈。 /** * 规格名称 DO * @@ -35,7 +34,7 @@ public class ProductPropertyDO extends BaseDO { /** * 状态: 0 开启 ,1 禁用 * - * TODO @franky:加个 枚举 {@link CommonStatusEnum} ,这样就能更好的知道 + * {@link CommonStatusEnum} */ private Integer status; From 204a5ba28497cca1dfdfd1d4af4ac9985b955cde Mon Sep 17 00:00:00 2001 From: shuaidawang Date: Thu, 19 May 2022 17:25:28 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=A7=84=E6=A0=BC=E5=A2=9E=E5=88=A0?= =?UTF-8?q?=E6=94=B9=E6=9F=A5=E6=8E=A5=E5=8F=A3=E5=8F=8A=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mall.sql | 16 +-- .../property/ProductPropertyController.java | 6 +- .../vo/ProductPropertyCreateReqVO.java | 8 ++ .../property/vo/ProductPropertyRespVO.java | 3 +- .../vo/ProductPropertyUpdateReqVO.java | 6 ++ .../PropertyValueController.java | 100 ------------------ .../propertyvalue/PropertyValueConvert.java | 2 + .../propertyvalue/PropertyValueMapper.java | 10 ++ .../property/ProductPropertyService.java | 9 ++ .../property/ProductPropertyServiceImpl.java | 59 +++++++++++ .../propertyvalue/PropertyValueService.java | 18 ++++ .../PropertyValueServiceImpl.java | 20 +++- .../src/views/mall/product/property/index.vue | 57 +++++----- 13 files changed, 172 insertions(+), 142 deletions(-) delete mode 100755 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/PropertyValueController.java diff --git a/sql/mall.sql b/sql/mall.sql index c3945a1fe..7b3d8ce5b 100644 --- a/sql/mall.sql +++ b/sql/mall.sql @@ -171,7 +171,7 @@ VALUES ('商品导出', 'product:spu:export', 3, 5, @parentId, '', '', '', 0); drop table if exists product_property; create table product_property ( - id bigint comment '主键', + id bigint NOT NULL AUTO_INCREMENT comment '主键', name varchar(64) comment '规格名称', status tinyint comment '状态: 0 开启 ,1 禁用', create_time datetime default current_timestamp comment '创建时间', @@ -179,7 +179,7 @@ create table product_property creator varchar(64) comment '创建人', updater varchar(64) comment '更新人', tenant_id bigint NOT NULL DEFAULT '0' COMMENT '租户编号', - deleted bit(1) comment '状态', + deleted bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', primary key (id), key idx_name ( name (32)) comment '规格名称索引' ) comment '规格名称' character set utf8mb4 @@ -189,7 +189,7 @@ create table product_property drop table if exists product_property_value; create table product_property_value ( - id int comment '主键', + id bigint NOT NULL AUTO_INCREMENT COMMENT '主键', property_id bigint comment '规格键id', name varchar(128) comment '规格值名字', status tinyint comment '状态: 1 开启 ,2 禁用', @@ -198,7 +198,7 @@ create table product_property_value creator varchar(64) comment '创建人', updater varchar(64) comment '更新人', tenant_id bigint NOT NULL DEFAULT '0' COMMENT '租户编号', - deleted bit(1) comment '状态', + deleted bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', primary key (id) ) comment '规格值' character set utf8mb4 collate utf8mb4_general_ci; @@ -207,7 +207,7 @@ create table product_property_value drop table if exists product_spu; create table product_spu ( - id int comment '主键', + id bigint NOT NULL AUTO_INCREMENT COMMENT '主键', name varchar(128) comment '商品名称', sell_point varchar(128) not null comment '卖点', description text not null comment '描述', @@ -223,7 +223,7 @@ create table product_spu creator varchar(64) comment '创建人', updater varchar(64) comment '更新人', tenant_id bigint NOT NULL DEFAULT '0' COMMENT '租户编号', - deleted bit(1) comment '状态', + deleted bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', primary key (id) ) comment '商品spu' character set utf8mb4 collate utf8mb4_general_ci; @@ -233,7 +233,7 @@ create table product_spu drop table if exists product_sku; create table product_sku ( - id int comment '主键', + id bigint NOT NULL AUTO_INCREMENT COMMENT '主键', spu_id bigint not null comment 'spu编号', properties varchar(64) not null comment '规格值数组-json格式, [{propertId: , valueId: }, {propertId: , valueId: }]', price int not null DEFAULT -1 comment '销售价格,单位:分', @@ -247,7 +247,7 @@ create table product_sku creator varchar(64) comment '创建人', updater varchar(64) comment '更新人', tenant_id bigint NOT NULL DEFAULT '0' COMMENT '租户编号', - deleted bit(1) comment '状态', + deleted bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', primary key (id) ) comment '商品sku' character set utf8mb4 collate utf8mb4_general_ci; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java index c81cce984..f1d31acab 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java @@ -63,8 +63,7 @@ public class ProductPropertyController { @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) @PreAuthorize("@ss.hasPermission('product:property:query')") public CommonResult getProperty(@RequestParam("id") Long id) { - ProductPropertyDO property = productPropertyService.getProperty(id); - return success(ProductPropertyConvert.INSTANCE.convert(property)); + return success(productPropertyService.getPropertyResp(id)); } @GetMapping("/list") @@ -80,8 +79,7 @@ public class ProductPropertyController { @ApiOperation("获得规格名称分页") @PreAuthorize("@ss.hasPermission('product:property:query')") public CommonResult> getPropertyPage(@Valid ProductPropertyPageReqVO pageVO) { - PageResult pageResult = productPropertyService.getPropertyPage(pageVO); - return success(ProductPropertyConvert.INSTANCE.convertPage(pageResult)); + return success(productPropertyService.getPropertyListPage(pageVO)); } @GetMapping("/export-excel") diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyCreateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyCreateReqVO.java index 560771623..d29f7aa2f 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyCreateReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyCreateReqVO.java @@ -1,12 +1,20 @@ package cn.iocoder.yudao.module.product.controller.admin.property.vo; +import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.PropertyValueCreateReqVO; import lombok.*; import io.swagger.annotations.*; +import javax.validation.constraints.NotNull; +import java.util.List; + @ApiModel("管理后台 - 规格名称创建 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) public class ProductPropertyCreateReqVO extends ProductPropertyBaseVO { + @ApiModelProperty(value = "属性值") + @NotNull(message = "属性值不能为空") + List propertyValueList; + } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyRespVO.java index 2ef5c6efd..ca85f4d93 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyRespVO.java @@ -17,6 +17,7 @@ public class ProductPropertyRespVO extends ProductPropertyBaseVO { @ApiModelProperty(value = "创建时间") private Date createTime; - private List propertyValueRespVOList; + @ApiModelProperty(value = "属性值") + private List propertyValueList; } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyUpdateReqVO.java index f53d200d2..6e077829e 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyUpdateReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyUpdateReqVO.java @@ -1,8 +1,10 @@ package cn.iocoder.yudao.module.product.controller.admin.property.vo; +import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.PropertyValueCreateReqVO; import lombok.*; import io.swagger.annotations.*; import javax.validation.constraints.*; +import java.util.List; @ApiModel("管理后台 - 规格名称更新 Request VO") @Data @@ -14,4 +16,8 @@ public class ProductPropertyUpdateReqVO extends ProductPropertyBaseVO { @NotNull(message = "主键不能为空") private Long id; + @ApiModelProperty(value = "属性值") + @NotNull(message = "属性值不能为空") + List propertyValueList; + } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/PropertyValueController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/PropertyValueController.java deleted file mode 100755 index 78404e507..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/PropertyValueController.java +++ /dev/null @@ -1,100 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.propertyvalue; - -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.annotations.*; - -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - -import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.*; -import cn.iocoder.yudao.module.product.dal.dataobject.propertyvalue.PropertyValueDO; -import cn.iocoder.yudao.module.product.convert.propertyvalue.PropertyValueConvert; -import cn.iocoder.yudao.module.product.service.propertyvalue.PropertyValueService; - -@Api(tags = "管理后台 - 规格值") -@RestController -@RequestMapping("/product/property-value") -@Validated -public class PropertyValueController { - - @Resource - private PropertyValueService propertyValueService; - - @PostMapping("/create") - @ApiOperation("创建规格值") - @PreAuthorize("@ss.hasPermission('product:property-value:create')") - public CommonResult createPropertyValue(@Valid @RequestBody PropertyValueCreateReqVO createReqVO) { - return success(propertyValueService.createPropertyValue(createReqVO)); - } - - @PutMapping("/update") - @ApiOperation("更新规格值") - @PreAuthorize("@ss.hasPermission('product:property-value:update')") - public CommonResult updatePropertyValue(@Valid @RequestBody PropertyValueUpdateReqVO updateReqVO) { - propertyValueService.updatePropertyValue(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @ApiOperation("删除规格值") - @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Integer.class) - @PreAuthorize("@ss.hasPermission('product:property-value:delete')") - public CommonResult deletePropertyValue(@RequestParam("id") Integer id) { - propertyValueService.deletePropertyValue(id); - return success(true); - } - - @GetMapping("/get") - @ApiOperation("获得规格值") - @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Integer.class) - @PreAuthorize("@ss.hasPermission('product:property-value:query')") - public CommonResult getPropertyValue(@RequestParam("id") Integer id) { - PropertyValueDO propertyValue = propertyValueService.getPropertyValue(id); - return success(PropertyValueConvert.INSTANCE.convert(propertyValue)); - } - - @GetMapping("/list") - @ApiOperation("获得规格值列表") - @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) - @PreAuthorize("@ss.hasPermission('product:property-value:query')") - public CommonResult> getPropertyValueList(@RequestParam("ids") Collection ids) { - List list = propertyValueService.getPropertyValueList(ids); - return success(PropertyValueConvert.INSTANCE.convertList(list)); - } - - @GetMapping("/page") - @ApiOperation("获得规格值分页") - @PreAuthorize("@ss.hasPermission('product:property-value:query')") - public CommonResult> getPropertyValuePage(@Valid PropertyValuePageReqVO pageVO) { - PageResult pageResult = propertyValueService.getPropertyValuePage(pageVO); - return success(PropertyValueConvert.INSTANCE.convertPage(pageResult)); - } - - @GetMapping("/export-excel") - @ApiOperation("导出规格值 Excel") - @PreAuthorize("@ss.hasPermission('product:property-value:export')") - @OperateLog(type = EXPORT) - public void exportPropertyValueExcel(@Valid PropertyValueExportReqVO exportReqVO, - HttpServletResponse response) throws IOException { - List list = propertyValueService.getPropertyValueList(exportReqVO); - // 导出 Excel - List datas = PropertyValueConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "规格值.xls", "数据", PropertyValueExcelVO.class, datas); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/propertyvalue/PropertyValueConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/propertyvalue/PropertyValueConvert.java index 58ec93069..7886eab85 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/propertyvalue/PropertyValueConvert.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/propertyvalue/PropertyValueConvert.java @@ -31,4 +31,6 @@ public interface PropertyValueConvert { List convertList02(List list); + List convertList03(List list); + } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/propertyvalue/PropertyValueMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/propertyvalue/PropertyValueMapper.java index 305541783..b281450f0 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/propertyvalue/PropertyValueMapper.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/propertyvalue/PropertyValueMapper.java @@ -35,4 +35,14 @@ public interface PropertyValueMapper extends BaseMapperX { .orderByDesc(PropertyValueDO::getId)); } + default List getPropertyValueListByPropertyId(List propertyIds){ + return selectList(new LambdaQueryWrapperX() + .inIfPresent(PropertyValueDO::getPropertyId, propertyIds)); + } + + default void deletePropertyValueByPropertyId(Long propertyId){ + LambdaQueryWrapperX queryWrapperX = new LambdaQueryWrapperX<>(); + queryWrapperX.eq(PropertyValueDO::getPropertyId, propertyId).eq(PropertyValueDO::getDeleted, false); + delete(queryWrapperX); + } } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java index eb02796ce..ec2622af5 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java @@ -67,4 +67,13 @@ public interface ProductPropertyService { */ List getPropertyList(ProductPropertyExportReqVO exportReqVO); + /** + * 获取属性及属性值列表 分页 + * @param pageReqVO + * @return + */ + PageResult getPropertyListPage(ProductPropertyPageReqVO pageReqVO); + + ProductPropertyRespVO getPropertyResp(Long id); + } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java index cdddd3ce4..3990855b3 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java @@ -4,15 +4,23 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.product.controller.admin.property.vo.*; import cn.iocoder.yudao.module.product.controller.admin.property.vo.ProductPropertyCreateReqVO; import cn.iocoder.yudao.module.product.controller.admin.property.vo.ProductPropertyUpdateReqVO; +import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.PropertyValueCreateReqVO; +import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.PropertyValueRespVO; import cn.iocoder.yudao.module.product.convert.property.ProductPropertyConvert; +import cn.iocoder.yudao.module.product.convert.propertyvalue.PropertyValueConvert; import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; +import cn.iocoder.yudao.module.product.dal.dataobject.propertyvalue.PropertyValueDO; import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyMapper; +import cn.iocoder.yudao.module.product.service.propertyvalue.PropertyValueService; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; +import java.util.Arrays; import java.util.Collection; import java.util.List; +import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_NOT_EXISTS; @@ -29,22 +37,39 @@ public class ProductPropertyServiceImpl implements ProductPropertyService { @Resource private ProductPropertyMapper productPropertyMapper; + @Resource + private PropertyValueService propertyValueService; + @Override + @Transactional(rollbackFor = Exception.class) public Long createProperty(ProductPropertyCreateReqVO createReqVO) { // 插入 ProductPropertyDO property = ProductPropertyConvert.INSTANCE.convert(createReqVO); productPropertyMapper.insert(property); + + //插入属性值 + List propertyValueList = createReqVO.getPropertyValueList(); + List propertyValueDOList = PropertyValueConvert.INSTANCE.convertList03(propertyValueList); + propertyValueDOList.stream().forEach(x-> x.setPropertyId(property.getId())); + propertyValueService.batchInsert(propertyValueDOList); // 返回 return property.getId(); } @Override + @Transactional(rollbackFor = Exception.class) public void updateProperty(ProductPropertyUpdateReqVO updateReqVO) { // 校验存在 this.validatePropertyExists(updateReqVO.getId()); // 更新 ProductPropertyDO updateObj = ProductPropertyConvert.INSTANCE.convert(updateReqVO); productPropertyMapper.updateById(updateObj); + //更新属性值,先删后加 + propertyValueService.deletePropertyValueByPropertyId(updateReqVO.getId()); + List propertyValueList = updateReqVO.getPropertyValueList(); + List propertyValueDOList = PropertyValueConvert.INSTANCE.convertList03(propertyValueList); + propertyValueDOList.stream().forEach(x-> x.setPropertyId(updateReqVO.getId())); + propertyValueService.batchInsert(propertyValueDOList); } @Override @@ -53,6 +78,8 @@ public class ProductPropertyServiceImpl implements ProductPropertyService { this.validatePropertyExists(id); // 删除 productPropertyMapper.deleteById(id); + //同步删除属性值 + propertyValueService.deletePropertyValueByPropertyId(id); } private void validatePropertyExists(Long id) { @@ -81,4 +108,36 @@ public class ProductPropertyServiceImpl implements ProductPropertyService { return productPropertyMapper.selectList(exportReqVO); } + @Override + public PageResult getPropertyListPage(ProductPropertyPageReqVO pageReqVO) { + //获取属性列表 + PageResult pageResult = productPropertyMapper.selectPage(pageReqVO); + PageResult propertyRespVOPageResult = ProductPropertyConvert.INSTANCE.convertPage(pageResult); + List propertyIds = propertyRespVOPageResult.getList().stream().map(x -> x.getId()).collect(Collectors.toList()); + + //获取属性值列表 + List propertyValueDOList = propertyValueService.getPropertyValueListByPropertyId(propertyIds); + List propertyValueRespVOList = PropertyValueConvert.INSTANCE.convertList(propertyValueDOList); + //组装一对多 + propertyRespVOPageResult.getList().stream().forEach(x->{ + Long propertyId = x.getId(); + List valueDOList = propertyValueRespVOList.stream().filter(v -> v.getPropertyId().equals(propertyId)).collect(Collectors.toList()); + x.setPropertyValueList(valueDOList); + }); + return propertyRespVOPageResult; + } + + @Override + public ProductPropertyRespVO getPropertyResp(Long id) { + //查询规格 + ProductPropertyDO property = getProperty(id); + ProductPropertyRespVO propertyRespVO = ProductPropertyConvert.INSTANCE.convert(property); + //查询属性值 + List valueDOList = propertyValueService.getPropertyValueListByPropertyId(Arrays.asList(id)); + List propertyValueRespVOS = PropertyValueConvert.INSTANCE.convertList(valueDOList); + //组装 + propertyRespVO.setPropertyValueList(propertyValueRespVOS); + return propertyRespVO; + } + } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/propertyvalue/PropertyValueService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/propertyvalue/PropertyValueService.java index 0e04e4bd9..94fb44f67 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/propertyvalue/PropertyValueService.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/propertyvalue/PropertyValueService.java @@ -67,4 +67,22 @@ public interface PropertyValueService { */ List getPropertyValueList(PropertyValueExportReqVO exportReqVO); + /** + * 批量插入属性值 + * @param propertyValues + */ + void batchInsert(List propertyValues); + + /** + * 根据属性id查询 + * @param propertyIds + * @return + */ + List getPropertyValueListByPropertyId(List propertyIds); + + /** + * 根据属性id 删除 + * @param propertyId + */ + void deletePropertyValueByPropertyId(Long propertyId); } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/propertyvalue/PropertyValueServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/propertyvalue/PropertyValueServiceImpl.java index d647d3e2e..15ea4e72e 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/propertyvalue/PropertyValueServiceImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/propertyvalue/PropertyValueServiceImpl.java @@ -1,10 +1,7 @@ package cn.iocoder.yudao.module.product.service.propertyvalue; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.PropertyValueCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.PropertyValueExportReqVO; -import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.PropertyValuePageReqVO; -import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.PropertyValueUpdateReqVO; +import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.*; import cn.iocoder.yudao.module.product.convert.propertyvalue.PropertyValueConvert; import cn.iocoder.yudao.module.product.dal.dataobject.propertyvalue.PropertyValueDO; import cn.iocoder.yudao.module.product.dal.mysql.propertyvalue.PropertyValueMapper; @@ -84,4 +81,19 @@ public class PropertyValueServiceImpl implements PropertyValueService { return propertyValueMapper.selectList(exportReqVO); } + @Override + public void batchInsert(List propertyValues) { + propertyValueMapper.insertBatch(propertyValues); + } + + @Override + public List getPropertyValueListByPropertyId(List propertyIds) { + return propertyValueMapper.getPropertyValueListByPropertyId(propertyIds); + } + + @Override + public void deletePropertyValueByPropertyId(Long propertyId) { + propertyValueMapper.deletePropertyValueByPropertyId(propertyId); + } + } diff --git a/yudao-ui-admin/src/views/mall/product/property/index.vue b/yudao-ui-admin/src/views/mall/product/property/index.vue index 46881fe88..6fd222341 100644 --- a/yudao-ui-admin/src/views/mall/product/property/index.vue +++ b/yudao-ui-admin/src/views/mall/product/property/index.vue @@ -24,16 +24,17 @@ 新增 - - 导出 - + + +