Commit 198b1189e896e97fa3f08f874d991e8f1bb8f922
1 parent
96db6b97
feature(uniapp商品): 商品修改
Showing
4 changed files
with
28 additions
and
9 deletions
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/ProductPropertyViewRespVO.java
| @@ -5,7 +5,7 @@ import io.swagger.annotations.ApiModelProperty; | @@ -5,7 +5,7 @@ import io.swagger.annotations.ApiModelProperty; | ||
| 5 | import lombok.Data; | 5 | import lombok.Data; |
| 6 | import lombok.ToString; | 6 | import lombok.ToString; |
| 7 | 7 | ||
| 8 | -import java.util.Set; | 8 | +import java.util.List; |
| 9 | 9 | ||
| 10 | /** | 10 | /** |
| 11 | * @Description: ProductPropertyViewRespVO | 11 | * @Description: ProductPropertyViewRespVO |
| @@ -25,16 +25,17 @@ public class ProductPropertyViewRespVO { | @@ -25,16 +25,17 @@ public class ProductPropertyViewRespVO { | ||
| 25 | public String name; | 25 | public String name; |
| 26 | 26 | ||
| 27 | @ApiModelProperty(value = "规格属性值集合", example = "[{\"v1\":11,\"v2\":\"64G\"},{\"v1\":10,\"v2\":\"32G\"}]") | 27 | @ApiModelProperty(value = "规格属性值集合", example = "[{\"v1\":11,\"v2\":\"64G\"},{\"v1\":10,\"v2\":\"32G\"}]") |
| 28 | - public Set<Tuple2> propertyValues; | 28 | + public List<Tuple2> propertyValues; |
| 29 | 29 | ||
| 30 | @Data | 30 | @Data |
| 31 | @ApiModel(value = "规格属性值元组") | 31 | @ApiModel(value = "规格属性值元组") |
| 32 | public static class Tuple2 { | 32 | public static class Tuple2 { |
| 33 | - private final long v1; | ||
| 34 | - private final String v2; | ||
| 35 | - public Tuple2(Long v1, String v2) { | ||
| 36 | - this.v1 = v1; | ||
| 37 | - this.v2 = v2; | 33 | + private final long id; |
| 34 | + private final String name; | ||
| 35 | + | ||
| 36 | + public Tuple2(Long id, String name) { | ||
| 37 | + this.id = id; | ||
| 38 | + this.name = name; | ||
| 38 | } | 39 | } |
| 39 | 40 | ||
| 40 | } | 41 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java
| @@ -20,7 +20,7 @@ import java.util.List; | @@ -20,7 +20,7 @@ import java.util.List; | ||
| 20 | * | 20 | * |
| 21 | * @author 芋道源码 | 21 | * @author 芋道源码 |
| 22 | */ | 22 | */ |
| 23 | -@TableName("product_sku") | 23 | +@TableName(value = "product_sku",autoResultMap = true) |
| 24 | @KeySequence("product_sku_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | 24 | @KeySequence("product_sku_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 |
| 25 | @Data | 25 | @Data |
| 26 | @EqualsAndHashCode(callSuper = true) | 26 | @EqualsAndHashCode(callSuper = true) |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java
| @@ -30,6 +30,7 @@ import org.springframework.validation.annotation.Validated; | @@ -30,6 +30,7 @@ import org.springframework.validation.annotation.Validated; | ||
| 30 | 30 | ||
| 31 | import javax.annotation.Resource; | 31 | import javax.annotation.Resource; |
| 32 | import java.util.*; | 32 | import java.util.*; |
| 33 | +import java.util.function.Function; | ||
| 33 | import java.util.stream.Collectors; | 34 | import java.util.stream.Collectors; |
| 34 | 35 | ||
| 35 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 36 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| @@ -142,7 +143,7 @@ public class ProductSpuServiceImpl implements ProductSpuService { | @@ -142,7 +143,7 @@ public class ProductSpuServiceImpl implements ProductSpuService { | ||
| 142 | ProductPropertyViewRespVO productPropertyViewRespVO = new ProductPropertyViewRespVO(); | 143 | ProductPropertyViewRespVO productPropertyViewRespVO = new ProductPropertyViewRespVO(); |
| 143 | productPropertyViewRespVO.setPropertyId(p.getId()); | 144 | productPropertyViewRespVO.setPropertyId(p.getId()); |
| 144 | productPropertyViewRespVO.setName(p.getName()); | 145 | productPropertyViewRespVO.setName(p.getName()); |
| 145 | - Set<ProductPropertyViewRespVO.Tuple2> propertyValues = new HashSet<>(); | 146 | + List<ProductPropertyViewRespVO.Tuple2> propertyValues = new ArrayList<>(); |
| 146 | Map<Long, ProductPropertyValueRespVO> propertyValueMaps = p.getPropertyValueList().stream().collect(Collectors.toMap(ProductPropertyValueRespVO::getId, pv -> pv)); | 147 | Map<Long, ProductPropertyValueRespVO> propertyValueMaps = p.getPropertyValueList().stream().collect(Collectors.toMap(ProductPropertyValueRespVO::getId, pv -> pv)); |
| 147 | propertyMaps.get(p.getId()).forEach(pv -> { | 148 | propertyMaps.get(p.getId()).forEach(pv -> { |
| 148 | ProductPropertyViewRespVO.Tuple2 tuple2 = new ProductPropertyViewRespVO.Tuple2(pv.getValueId(), propertyValueMaps.get(pv.getValueId()).getName()); | 149 | ProductPropertyViewRespVO.Tuple2 tuple2 = new ProductPropertyViewRespVO.Tuple2(pv.getValueId(), propertyValueMaps.get(pv.getValueId()).getName()); |
yudao-ui-admin/src/views/mall/product/spu/save.vue
| @@ -471,6 +471,23 @@ export default { | @@ -471,6 +471,23 @@ export default { | ||
| 471 | this.baseForm.showStock=data.showStock; | 471 | this.baseForm.showStock=data.showStock; |
| 472 | this.baseForm.brandId=data.brandId; | 472 | this.baseForm.brandId=data.brandId; |
| 473 | this.ratesForm.spec=data.specType; | 473 | this.ratesForm.spec=data.specType; |
| 474 | + if(this.ratesForm.spec == 2){ | ||
| 475 | + data.productPropertyViews.forEach(p=>{ | ||
| 476 | + let obj = {}; | ||
| 477 | + obj.specId = p.propertyId; | ||
| 478 | + obj.specName = p.name; | ||
| 479 | + obj.specValue = p.propertyValues; | ||
| 480 | + this.dynamicSpec.push(obj); | ||
| 481 | + }) | ||
| 482 | + data.skus.forEach(s=>{ | ||
| 483 | + s.spec = []; | ||
| 484 | + s.properties.forEach(sp=>{ | ||
| 485 | + let spec = data.productPropertyViews.find(o=>o.propertyId == sp.propertyId).propertyValues.find(v=>v.id == sp.valueId).name; | ||
| 486 | + s.spec.push(spec) | ||
| 487 | + }) | ||
| 488 | + }) | ||
| 489 | + } | ||
| 490 | + console.log(data.skus); | ||
| 474 | this.ratesForm.rates=data.skus | 491 | this.ratesForm.rates=data.skus |
| 475 | }) | 492 | }) |
| 476 | } | 493 | } |