feature(uniapp商品): 商品修改

This commit is contained in:
luowenfeng
2022-09-01 11:00:40 +08:00
parent 96db6b97ad
commit 198b1189e8
4 changed files with 28 additions and 9 deletions

View File

@ -5,7 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import java.util.Set;
import java.util.List;
/**
* @Description: ProductPropertyViewRespVO
@ -25,16 +25,17 @@ public class ProductPropertyViewRespVO {
public String name;
@ApiModelProperty(value = "规格属性值集合", example = "[{\"v1\":11,\"v2\":\"64G\"},{\"v1\":10,\"v2\":\"32G\"}]")
public Set<Tuple2> propertyValues;
public List<Tuple2> propertyValues;
@Data
@ApiModel(value = "规格属性值元组")
public static class Tuple2 {
private final long v1;
private final String v2;
public Tuple2(Long v1, String v2) {
this.v1 = v1;
this.v2 = v2;
private final long id;
private final String name;
public Tuple2(Long id, String name) {
this.id = id;
this.name = name;
}
}

View File

@ -20,7 +20,7 @@ import java.util.List;
*
* @author 芋道源码
*/
@TableName("product_sku")
@TableName(value = "product_sku",autoResultMap = true)
@KeySequence("product_sku_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)

View File

@ -30,6 +30,7 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
@ -142,7 +143,7 @@ public class ProductSpuServiceImpl implements ProductSpuService {
ProductPropertyViewRespVO productPropertyViewRespVO = new ProductPropertyViewRespVO();
productPropertyViewRespVO.setPropertyId(p.getId());
productPropertyViewRespVO.setName(p.getName());
Set<ProductPropertyViewRespVO.Tuple2> propertyValues = new HashSet<>();
List<ProductPropertyViewRespVO.Tuple2> propertyValues = new ArrayList<>();
Map<Long, ProductPropertyValueRespVO> propertyValueMaps = p.getPropertyValueList().stream().collect(Collectors.toMap(ProductPropertyValueRespVO::getId, pv -> pv));
propertyMaps.get(p.getId()).forEach(pv -> {
ProductPropertyViewRespVO.Tuple2 tuple2 = new ProductPropertyViewRespVO.Tuple2(pv.getValueId(), propertyValueMaps.get(pv.getValueId()).getName());