mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-08-16 03:01:53 +08:00
product:商品规格,调整成商品属性,避免和 sku 概念冲突
This commit is contained in:
@@ -18,7 +18,7 @@ import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Api(tags = "管理后台 - 规格名称")
|
||||
@Api(tags = "管理后台 - 商品属性项")
|
||||
@RestController
|
||||
@RequestMapping("/product/property")
|
||||
@Validated
|
||||
@@ -28,14 +28,14 @@ public class ProductPropertyController {
|
||||
private ProductPropertyService productPropertyService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建规格名称")
|
||||
@ApiOperation("创建属性项")
|
||||
@PreAuthorize("@ss.hasPermission('product:property:create')")
|
||||
public CommonResult<Long> createProperty(@Valid @RequestBody ProductPropertyCreateReqVO createReqVO) {
|
||||
return success(productPropertyService.createProperty(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("更新规格名称")
|
||||
@ApiOperation("更新属性项")
|
||||
@PreAuthorize("@ss.hasPermission('product:property:update')")
|
||||
public CommonResult<Boolean> updateProperty(@Valid @RequestBody ProductPropertyUpdateReqVO updateReqVO) {
|
||||
productPropertyService.updateProperty(updateReqVO);
|
||||
@@ -43,7 +43,7 @@ public class ProductPropertyController {
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除规格名称")
|
||||
@ApiOperation("删除属性项")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('product:property:delete')")
|
||||
public CommonResult<Boolean> deleteProperty(@RequestParam("id") Long id) {
|
||||
@@ -52,7 +52,7 @@ public class ProductPropertyController {
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得规格名称")
|
||||
@ApiOperation("获得属性项")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('product:property:query')")
|
||||
public CommonResult<ProductPropertyRespVO> getProperty(@RequestParam("id") Long id) {
|
||||
@@ -60,21 +60,21 @@ public class ProductPropertyController {
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得规格名称列表")
|
||||
@ApiOperation("获得属性项列表")
|
||||
@PreAuthorize("@ss.hasPermission('product:property:query')")
|
||||
public CommonResult<List<ProductPropertyRespVO>> getPropertyList(@Valid ProductPropertyListReqVO listReqVO) {
|
||||
return success(productPropertyService.getPropertyList(listReqVO));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得规格名称分页")
|
||||
@ApiOperation("获得属性项分页")
|
||||
@PreAuthorize("@ss.hasPermission('product:property:query')")
|
||||
public CommonResult<PageResult<ProductPropertyRespVO>> getPropertyPage(@Valid ProductPropertyPageReqVO pageVO) {
|
||||
return success(productPropertyService.getPropertyPage(pageVO));
|
||||
}
|
||||
|
||||
@GetMapping("/listAndValue")
|
||||
@ApiOperation("获得规格名称列表")
|
||||
@ApiOperation("获得属性项列表")
|
||||
@PreAuthorize("@ss.hasPermission('product:property:query')")
|
||||
public CommonResult<List<ProductPropertyAndValueRespVO>> getPropertyAndValueList(@Valid ProductPropertyListReqVO listReqVO) {
|
||||
return success(productPropertyService.getPropertyAndValueList(listReqVO));
|
||||
|
@@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.product.controller.admin.property;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyPageReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO;
|
||||
@@ -20,7 +19,7 @@ import javax.validation.Valid;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Api(tags = "管理后台 - 规格值名称")
|
||||
@Api(tags = "管理后台 - 商品属性值")
|
||||
@RestController
|
||||
@RequestMapping("/product/property/value")
|
||||
@Validated
|
||||
@@ -30,14 +29,14 @@ public class ProductPropertyValueController {
|
||||
private ProductPropertyValueService productPropertyValueService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建规格名称")
|
||||
@ApiOperation("创建属性值")
|
||||
@PreAuthorize("@ss.hasPermission('product:property:create')")
|
||||
public CommonResult<Long> createProperty(@Valid @RequestBody ProductPropertyValueCreateReqVO createReqVO) {
|
||||
return success(productPropertyValueService.createPropertyValue(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("更新规格名称")
|
||||
@ApiOperation("更新属性值")
|
||||
@PreAuthorize("@ss.hasPermission('product:property:update')")
|
||||
public CommonResult<Boolean> updateProperty(@Valid @RequestBody ProductPropertyValueUpdateReqVO updateReqVO) {
|
||||
productPropertyValueService.updatePropertyValue(updateReqVO);
|
||||
@@ -45,7 +44,7 @@ public class ProductPropertyValueController {
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除规格名称")
|
||||
@ApiOperation("删除属性值")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('product:property:delete')")
|
||||
public CommonResult<Boolean> deleteProperty(@RequestParam("id") Long id) {
|
||||
@@ -54,7 +53,7 @@ public class ProductPropertyValueController {
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得规格名称")
|
||||
@ApiOperation("获得属性值")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('product:property:query')")
|
||||
public CommonResult<ProductPropertyValueRespVO> getProperty(@RequestParam("id") Long id) {
|
||||
@@ -62,7 +61,7 @@ public class ProductPropertyValueController {
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得规格名称分页")
|
||||
@ApiOperation("获得属性值分页")
|
||||
@PreAuthorize("@ss.hasPermission('product:property:query')")
|
||||
public CommonResult<PageResult<ProductPropertyValueRespVO>> getPropertyValuePage(@Valid ProductPropertyValuePageReqVO pageVO) {
|
||||
return success(productPropertyValueService.getPropertyValueListPage(pageVO));
|
||||
|
@@ -7,28 +7,23 @@ import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: ProductPropertyViewRespVO
|
||||
* @Author: franky
|
||||
* @CreateDate: 2022/7/5 21:29
|
||||
* @Version: 1.0.0
|
||||
*/
|
||||
@ApiModel("管理后台 - 规格名称详情展示 Request VO")
|
||||
// TODO 芋艿:看看怎么删除
|
||||
@ApiModel("管理后台 - 商品属性详情展示 Request VO")
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class ProductPropertyViewRespVO {
|
||||
|
||||
@ApiModelProperty(value = "规格名称id", example = "1")
|
||||
@ApiModelProperty(value = "属性项 id", example = "1")
|
||||
public Long propertyId;
|
||||
|
||||
@ApiModelProperty(value = "规格名称", example = "内存")
|
||||
@ApiModelProperty(value = "属性项的名字", example = "内存")
|
||||
public String name;
|
||||
|
||||
@ApiModelProperty(value = "规格属性值集合", example = "[{\"v1\":11,\"v2\":\"64G\"},{\"v1\":10,\"v2\":\"32G\"}]")
|
||||
@ApiModelProperty(value = "属性值数组")
|
||||
public List<Tuple2> propertyValues;
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "规格属性值元组")
|
||||
@ApiModel(value = "属性值元组")
|
||||
public static class Tuple2 {
|
||||
private final long id;
|
||||
private final String name;
|
||||
|
@@ -10,20 +10,20 @@ import lombok.ToString;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("管理后台 - 规格 + 规格值 Response VO")
|
||||
@ApiModel("管理后台 - 商品属性项 + 属性值 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ProductPropertyAndValueRespVO extends ProductPropertyBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "规格的编号", required = true, example = "1024")
|
||||
@ApiModelProperty(value = "属性项的编号", required = true, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 规格值的集合
|
||||
* 属性值的集合
|
||||
*/
|
||||
private List<ProductPropertyValueRespVO> values;
|
||||
|
||||
|
@@ -7,14 +7,14 @@ import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 规格名称 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 商品属性项 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class ProductPropertyBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "规格名称", required = true, example = "颜色")
|
||||
@NotBlank(message = "规格名称不能为空")
|
||||
@ApiModelProperty(value = "名称", required = true, example = "颜色")
|
||||
@NotBlank(message = "名称不能为空")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "备注", example = "颜色")
|
||||
|
@@ -5,7 +5,7 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@ApiModel("管理后台 - 规格名称创建 Request VO")
|
||||
@ApiModel("管理后台 - 属性项创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
|
@@ -5,12 +5,12 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
@ApiModel("管理后台 - 规格名称 List Request VO")
|
||||
@ApiModel("管理后台 - 属性项 List Request VO")
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class ProductPropertyListReqVO {
|
||||
|
||||
@ApiModelProperty(value = "规格名称", example = "颜色")
|
||||
@ApiModelProperty(value = "名称", example = "颜色")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 CommonStatusEnum 枚举")
|
||||
|
@@ -12,13 +12,13 @@ import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel("管理后台 - 规格名称分页 Request VO")
|
||||
@ApiModel("管理后台 - 属性项 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ProductPropertyPageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "规格名称", example = "颜色")
|
||||
@ApiModelProperty(value = "名称", example = "颜色")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 CommonStatusEnum 枚举")
|
||||
|
@@ -8,13 +8,13 @@ import lombok.ToString;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@ApiModel("管理后台 - 规格 + 规格值 Response VO")
|
||||
@ApiModel("管理后台 - 属性项 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ProductPropertyRespVO extends ProductPropertyBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "规格的编号", required = true, example = "1024")
|
||||
@ApiModelProperty(value = "编号", required = true, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
|
@@ -1,12 +1,14 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.property.vo.property;
|
||||
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO;
|
||||
import lombok.*;
|
||||
import io.swagger.annotations.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@ApiModel("管理后台 - 规格名称更新 Request VO")
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("管理后台 - 属性项更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
|
@@ -7,18 +7,18 @@ import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 规格值 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 属性值 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class ProductPropertyValueBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "规格编号", required = true, example = "1024")
|
||||
@NotNull(message = "规格编号不能为空")
|
||||
@ApiModelProperty(value = "属性项的编号", required = true, example = "1024")
|
||||
@NotNull(message = "属性项的编号不能为空")
|
||||
private Long propertyId;
|
||||
|
||||
@ApiModelProperty(value = "规格值名字", required = true, example = "红色")
|
||||
@NotEmpty(message = "规格值名字不能为空")
|
||||
@ApiModelProperty(value = "名称", required = true, example = "红色")
|
||||
@NotEmpty(message = "名称名字不能为空")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 CommonStatusEnum 枚举")
|
||||
|
@@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.product.controller.admin.property.vo.value;
|
||||
import lombok.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
@ApiModel("管理后台 - 规格值创建 Request VO")
|
||||
@ApiModel("管理后台 - 商品属性值创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
|
@@ -6,23 +6,17 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel("管理后台 - 规格名称值分页 Request VO")
|
||||
@ApiModel("管理后台 - 商品属性值分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ProductPropertyValuePageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "规格id", example = "1024")
|
||||
@ApiModelProperty(value = "属性项的编号", example = "1024")
|
||||
private String propertyId;
|
||||
|
||||
@ApiModelProperty(value = "规格值", example = "红色")
|
||||
@ApiModelProperty(value = "名称", example = "红色")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 CommonStatusEnum 枚举")
|
||||
|
@@ -8,13 +8,13 @@ import lombok.ToString;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@ApiModel("管理后台 - 规格值 Response VO")
|
||||
@ApiModel("管理后台 - 商品属性值 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ProductPropertyValueRespVO extends ProductPropertyValueBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "主键", required = true, example = "10")
|
||||
@ApiModelProperty(value = "编号", required = true, example = "10")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
|
@@ -4,7 +4,7 @@ import lombok.*;
|
||||
import io.swagger.annotations.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@ApiModel("管理后台 - 规格值更新 Request VO")
|
||||
@ApiModel("管理后台 - 商品属性值更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
|
@@ -55,7 +55,7 @@ public class ProductSkuBaseVO {
|
||||
@ApiModelProperty(value = "商品体积", example = "1024", notes = "单位:m^3 平米")
|
||||
private Double volume;
|
||||
|
||||
@ApiModel("规格值")
|
||||
@ApiModel("商品属性")
|
||||
@Data
|
||||
public static class Property {
|
||||
|
||||
|
@@ -18,7 +18,7 @@ public class ProductSkuCreateOrUpdateReqVO extends ProductSkuBaseVO {
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 规格值数组
|
||||
* 属性数组
|
||||
*/
|
||||
private List<Property> properties;
|
||||
|
||||
|
@@ -22,7 +22,7 @@ public class ProductSkuRespVO extends ProductSkuBaseVO {
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 规格值数组
|
||||
* 属性数组
|
||||
*/
|
||||
private List<Property> properties;
|
||||
|
||||
|
@@ -35,22 +35,22 @@ public class ProductSpuDetailRespVO extends ProductSpuBaseVO {
|
||||
public static class Sku extends ProductSkuBaseVO {
|
||||
|
||||
/**
|
||||
* 规格的数组
|
||||
* 属性数组
|
||||
*/
|
||||
private List<ProductSpuDetailRespVO.Property> properties;
|
||||
|
||||
}
|
||||
|
||||
@ApiModel(value = "管理后台 - 商品规格的详细 Response VO")
|
||||
@ApiModel(value = "管理后台 - 商品属性的详细 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public static class Property extends ProductSkuBaseVO.Property {
|
||||
|
||||
@ApiModelProperty(value = "规格的名字", required = true, example = "颜色")
|
||||
@ApiModelProperty(value = "属性项的名字", required = true, example = "颜色")
|
||||
private String propertyName;
|
||||
|
||||
@ApiModelProperty(value = "规格值的名字", required = true, example = "蓝色")
|
||||
@ApiModelProperty(value = "属性值的名称", required = true, example = "蓝色")
|
||||
private String valueName;
|
||||
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public class ProductSpuDetailRespVO extends ProductSpuBaseVO {
|
||||
private Long categoryId;
|
||||
|
||||
// TODO @芋艿:在瞅瞅~
|
||||
@ApiModelProperty(value = "规格属性修改和详情展示组合", example = "[{\"propertyId\":2,\"name\":\"内存\",\"propertyValues\":[{\"v1\":11,\"v2\":\"64G\"},{\"v1\":10,\"v2\":\"32G\"}]},{\"propertyId\":3,\"name\":\"尺寸\",\"propertyValues\":[{\"v1\":16,\"v2\":\"6.1\"},{\"v1\":15,\"v2\":\"5.7\"}]}]")
|
||||
@ApiModelProperty(value = "属性修改和详情展示组合", example = "[{\"propertyId\":2,\"name\":\"内存\",\"propertyValues\":[{\"v1\":11,\"v2\":\"64G\"},{\"v1\":10,\"v2\":\"32G\"}]},{\"propertyId\":3,\"name\":\"尺寸\",\"propertyValues\":[{\"v1\":16,\"v2\":\"6.1\"},{\"v1\":15,\"v2\":\"5.7\"}]}]")
|
||||
private List<ProductPropertyViewRespVO> productPropertyViews;
|
||||
|
||||
}
|
||||
|
@@ -5,16 +5,14 @@ import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.Pro
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyCreateReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyRespVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 规格名称 Convert
|
||||
* 属性项 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
|
@@ -1,9 +1,6 @@
|
||||
package cn.iocoder.yudao.module.product.convert.propertyvalue;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO;
|
||||
@@ -11,8 +8,10 @@ import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyVa
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 规格值 Convert
|
||||
* 属性值 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
|
@@ -8,7 +8,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 规格名称 DO
|
||||
* 商品属性项 DO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@@ -28,7 +28,7 @@ public class ProductPropertyDO extends BaseDO {
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 规格名称
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
|
@@ -9,7 +9,7 @@ import lombok.*;
|
||||
|
||||
|
||||
/**
|
||||
* 规格值 DO
|
||||
* 商品属性值 DO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@@ -29,13 +29,13 @@ public class ProductPropertyValueDO extends BaseDO {
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 规格键编号
|
||||
* 属性项的编号
|
||||
*
|
||||
* 关联 {@link ProductPropertyDO#getId()}
|
||||
*/
|
||||
private Long propertyId;
|
||||
/**
|
||||
* 规格值名字
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
|
@@ -48,7 +48,7 @@ public class ProductSkuDO extends BaseDO {
|
||||
*/
|
||||
private String spuName;
|
||||
/**
|
||||
* 规格值数组,JSON 格式
|
||||
* 属性数组,JSON 格式
|
||||
*/
|
||||
@TableField(typeHandler = PropertyTypeHandler.class)
|
||||
private List<Property> properties;
|
||||
|
@@ -7,13 +7,6 @@ import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.Pro
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 规格名称 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface ProductPropertyMapper extends BaseMapperX<ProductPropertyDO> {
|
||||
|
||||
|
@@ -9,11 +9,6 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 规格值 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface ProductPropertyValueMapper extends BaseMapperX<ProductPropertyValueDO> {
|
||||
|
||||
|
@@ -1,23 +1,21 @@
|
||||
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.property.ProductPropertyRespVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.*;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 规格名称 Service 接口
|
||||
* 商品属性项 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface ProductPropertyService {
|
||||
|
||||
/**
|
||||
* 创建规格名称
|
||||
* 创建属性项
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
@@ -25,23 +23,23 @@ public interface ProductPropertyService {
|
||||
Long createProperty(@Valid ProductPropertyCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新规格名称
|
||||
* 更新属性项
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateProperty(@Valid ProductPropertyUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除规格名称
|
||||
* 删除属性项
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteProperty(Long id);
|
||||
|
||||
/**
|
||||
* 获得规格名称列表
|
||||
* 获得属性项列表
|
||||
* @param listReqVO 集合查询
|
||||
* @return 规格名称集合
|
||||
* @return 属性项集合
|
||||
*/
|
||||
List<ProductPropertyRespVO> getPropertyList(ProductPropertyListReqVO listReqVO);
|
||||
|
||||
@@ -49,31 +47,31 @@ public interface ProductPropertyService {
|
||||
* 获取属性名称分页
|
||||
*
|
||||
* @param pageReqVO 分页条件
|
||||
* @return 规格名称分页
|
||||
* @return 属性项分页
|
||||
*/
|
||||
PageResult<ProductPropertyRespVO> getPropertyPage(ProductPropertyPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得指定编号的规格名称
|
||||
* 获得指定编号的属性项
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 规格名称
|
||||
* @return 属性项
|
||||
*/
|
||||
ProductPropertyRespVO getProperty(Long id);
|
||||
|
||||
/**
|
||||
* 根据规格属性编号的集合,获得对应的规格 + 规格值的集合
|
||||
* 根据属性项的编号的集合,获得对应的属性项数组
|
||||
*
|
||||
* @param ids 规格编号的集合
|
||||
* @return 对应的规格
|
||||
* @param ids 属性项的编号的集合
|
||||
* @return 属性项数组
|
||||
*/
|
||||
List<ProductPropertyRespVO> getPropertyList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得规格名称 + 值的列表
|
||||
* 获得属性项 + 值的列表
|
||||
*
|
||||
* @param listReqVO 列表查询
|
||||
* @return 规格名称 + 值的列表
|
||||
* @return 属性项 + 值的列表
|
||||
*/
|
||||
List<ProductPropertyAndValueRespVO> getPropertyAndValueList(ProductPropertyListReqVO listReqVO);
|
||||
|
||||
|
@@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.product.service.property;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.*;
|
||||
import cn.iocoder.yudao.module.product.convert.property.ProductPropertyConvert;
|
||||
@@ -19,14 +18,13 @@ import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_EXISTS;
|
||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 规格名称 Service 实现类
|
||||
* 商品属性项 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@@ -58,7 +56,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateProperty(ProductPropertyUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
this.validatePropertyExists(updateReqVO.getId());
|
||||
validatePropertyExists(updateReqVO.getId());
|
||||
ProductPropertyDO productPropertyDO = productPropertyMapper.selectByName(updateReqVO.getName());
|
||||
if (productPropertyDO != null && !productPropertyDO.getId().equals(updateReqVO.getId())) {
|
||||
throw exception(PROPERTY_EXISTS);
|
||||
@@ -71,10 +69,10 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
|
||||
@Override
|
||||
public void deleteProperty(Long id) {
|
||||
// 校验存在
|
||||
this.validatePropertyExists(id);
|
||||
validatePropertyExists(id);
|
||||
// 删除
|
||||
productPropertyMapper.deleteById(id);
|
||||
//同步删除属性值
|
||||
// 同步删除属性值
|
||||
productPropertyValueMapper.deletePropertyValueByPropertyId(id);
|
||||
}
|
||||
|
||||
@@ -93,7 +91,6 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
|
||||
|
||||
@Override
|
||||
public PageResult<ProductPropertyRespVO> getPropertyPage(ProductPropertyPageReqVO pageReqVO) {
|
||||
//获取属性列表
|
||||
PageResult<ProductPropertyDO> pageResult = productPropertyMapper.selectPage(pageReqVO);
|
||||
return ProductPropertyConvert.INSTANCE.convertPage(pageResult);
|
||||
}
|
||||
@@ -104,11 +101,13 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
|
||||
return ProductPropertyConvert.INSTANCE.convert(property);
|
||||
}
|
||||
|
||||
// TODO @芋艿:丢到 Controller
|
||||
@Override
|
||||
public List<ProductPropertyRespVO> getPropertyList(Collection<Long> ids) {
|
||||
return ProductPropertyConvert.INSTANCE.convertList(productPropertyMapper.selectBatchIds(ids));
|
||||
}
|
||||
|
||||
// TODO @芋艿:丢到 Controller
|
||||
@Override
|
||||
public List<ProductPropertyAndValueRespVO> getPropertyAndValueList(ProductPropertyListReqVO listReqVO) {
|
||||
List<ProductPropertyRespVO> propertyList = getPropertyList(listReqVO);
|
||||
|
@@ -9,16 +9,14 @@ import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.Produc
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 规格值 Service 接口
|
||||
* </p>
|
||||
* 商品属性值 Service 接口
|
||||
*
|
||||
* @author LuoWenFeng
|
||||
*/
|
||||
public interface ProductPropertyValueService {
|
||||
|
||||
/**
|
||||
* 创建规格值
|
||||
* 创建属性值
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
@@ -26,40 +24,40 @@ public interface ProductPropertyValueService {
|
||||
Long createPropertyValue(ProductPropertyValueCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新规格值
|
||||
* 更新属性值
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updatePropertyValue(ProductPropertyValueUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除规格值
|
||||
* 删除属性值
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deletePropertyValue(Long id);
|
||||
|
||||
/**
|
||||
* 获得规格值
|
||||
* 获得属性值
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 规格名称
|
||||
* @return 属性值
|
||||
*/
|
||||
ProductPropertyValueRespVO getPropertyValue(Long id);
|
||||
|
||||
/**
|
||||
* 获得规格值
|
||||
* 获得属性值
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 规格名称
|
||||
* @return 属性值
|
||||
*/
|
||||
List<ProductPropertyValueRespVO> getPropertyValueListByPropertyId(List<Long> id);
|
||||
|
||||
/**
|
||||
* 获取规格值 分页
|
||||
* 获取属性值的分页
|
||||
*
|
||||
* @param pageReqVO 查询条件
|
||||
* @return
|
||||
* @return 属性值的分页
|
||||
*/
|
||||
PageResult<ProductPropertyValueRespVO> getPropertyValueListPage(ProductPropertyValuePageReqVO pageReqVO);
|
||||
}
|
||||
|
@@ -14,13 +14,12 @@ import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_VALUE_EXISTS;
|
||||
|
||||
/**
|
||||
* 规格值 Service 实现类
|
||||
* 商品属性值 Service 实现类
|
||||
*
|
||||
* @author LuoWenFeng
|
||||
*/
|
||||
|
@@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.module.product.service.property.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 商品属性项的明细 Response BO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Data
|
||||
public class ProductPropertyValueDetailRespBO {
|
||||
|
||||
/**
|
||||
* 属性的编号
|
||||
*/
|
||||
private Long propertyId;
|
||||
|
||||
/**
|
||||
* 属性的名称
|
||||
*/
|
||||
private String propertyName;
|
||||
|
||||
/**
|
||||
* 属性值的编号
|
||||
*/
|
||||
private Long valueId;
|
||||
|
||||
/**
|
||||
* 属性值的名称
|
||||
*/
|
||||
private String valueName;
|
||||
|
||||
}
|
@@ -84,15 +84,17 @@ public class ProductSkuServiceImpl implements ProductSkuService {
|
||||
return;
|
||||
}
|
||||
|
||||
// 1、校验规格属性存在
|
||||
Set<Long> propertyIds = skus.stream().filter(p -> p.getProperties() != null).flatMap(p -> p.getProperties().stream()) // 遍历多个 Property 属性
|
||||
.map(ProductSkuBaseVO.Property::getPropertyId).collect(Collectors.toSet()); // 将每个 Property 转换成对应的 propertyId,最后形成集合
|
||||
// 1、校验属性项存在
|
||||
Set<Long> propertyIds = skus.stream().filter(p -> p.getProperties() != null)
|
||||
.flatMap(p -> p.getProperties().stream()) // 遍历多个 Property 属性
|
||||
.map(ProductSkuBaseVO.Property::getPropertyId) // 将每个 Property 转换成对应的 propertyId,最后形成集合
|
||||
.collect(Collectors.toSet());
|
||||
List<ProductPropertyRespVO> propertyList = productPropertyService.getPropertyList(propertyIds);
|
||||
if (propertyList.size() != propertyIds.size()) {
|
||||
throw exception(PROPERTY_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 2. 校验,一个 SKU 下,没有重复的规格。校验方式是,遍历每个 SKU ,看看是否有重复的规格 propertyId
|
||||
// 2. 校验,一个 SKU 下,没有重复的属性。校验方式是,遍历每个 SKU ,看看是否有重复的属性 propertyId
|
||||
Map<Long, ProductPropertyValueRespVO> propertyValueMap = CollectionUtils.convertMap(productPropertyValueService.getPropertyValueListByPropertyId(new ArrayList<>(propertyIds)), ProductPropertyValueRespVO::getId);
|
||||
skus.forEach(sku -> {
|
||||
Set<Long> skuPropertyIds = convertSet(sku.getProperties(), propertyItem -> propertyValueMap.get(propertyItem.getValueId()).getPropertyId());
|
||||
@@ -101,7 +103,7 @@ public class ProductSkuServiceImpl implements ProductSkuService {
|
||||
}
|
||||
});
|
||||
|
||||
// 3. 再校验,每个 Sku 的规格值的数量,是一致的。
|
||||
// 3. 再校验,每个 Sku 的属性值的数量,是一致的。
|
||||
int attrValueIdsSize = skus.get(0).getProperties().size();
|
||||
for (int i = 1; i < skus.size(); i++) {
|
||||
if (attrValueIdsSize != skus.get(i).getProperties().size()) {
|
||||
@@ -151,7 +153,7 @@ public class ProductSkuServiceImpl implements ProductSkuService {
|
||||
public void updateSkus(Long spuId, String spuName, List<ProductSkuCreateOrUpdateReqVO> skus) {
|
||||
// 查询 SPU 下已经存在的 SKU 的集合
|
||||
List<ProductSkuDO> existsSkus = productSkuMapper.selectListBySpuId(spuId);
|
||||
// 构建规格与 SKU 的映射关系;
|
||||
// 构建属性与 SKU 的映射关系;
|
||||
// TODO @luowenfeng: 可以下 existsSkuMap2; 会简洁一点; 另外, 可以考虑抽一个小方法, 用于 Properties 生成一个串; 这样 177 也可以复用了
|
||||
Map<String, Long> existsSkuMap = existsSkus.stream()
|
||||
.map(v -> {
|
||||
|
@@ -133,7 +133,7 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
||||
if (null != spu) {
|
||||
List<ProductSpuDetailRespVO.Sku> skuReqs = ProductSkuConvert.INSTANCE.convertList03(productSkuService.getSkusBySpuId(id));
|
||||
respVO.setSkus(skuReqs);
|
||||
// 组合 sku 规格属性
|
||||
// 组合 sku 属性
|
||||
if (spu.getSpecType().equals(ProductSpuSpecTypeEnum.DISABLE.getType())) {
|
||||
List<ProductSkuRespVO.Property> properties = new ArrayList<>();
|
||||
for (ProductSpuDetailRespVO.Sku productSkuRespVO : skuReqs) {
|
||||
|
Reference in New Issue
Block a user