提交 65258e78 authored 作者: 潘鹏's avatar 潘鹏

Merge remote-tracking branch 'origin/master'

......@@ -12,6 +12,7 @@ import com.platform.utils.PageUtils;
import com.platform.utils.Query;
import com.platform.utils.R;
import com.platform.utils.util.StringUtil;
import com.platform.vo.AttributesDescVo;
import com.platform.vo.AttributesExtends;
import com.platform.vo.AttributesVo;
import org.apache.commons.lang.StringUtils;
......@@ -146,45 +147,52 @@ public class AttributesController {
LinkedList<AttributesVo> attrNameList = new LinkedList<>();
List<AttributesEntity> list = attributesService.queryList(null);
list.forEach(attr -> {
List<String> attrDescList = new ArrayList<>();
AttributesVo attrNames = new AttributesVo();
attrNames.setId(attr.getId());
attrNames.setAttrName(attr.getAttrName());
List<AttributesDescEntity> descs = attributesDescService.queryByAttrId(attr.getId());
List<AttributesDescVo> attributesVos = new ArrayList<>();
descs.forEach(desc -> {
AttributesDescVo descVo = new AttributesDescVo();
String attrValue = desc.getAttrValue();
String attrDesc = desc.getAttrDesc();
descVo.setAttrDescId(desc.getAttrDescId());
descVo.setAttrValue(attrValue + "(" + attrDesc + ")");
attributesVos.add(descVo);
});
attrNames.setDescList(attrDescList);
attrNames.setDescList(attributesVos);
attrNameList.add(attrNames);
});
return R.ok().put("list", attrNameList);
}
/**
* 属性值
*
* @param id 属性Id
* @return url(../attributes/queryAttrDescs?id=2)
*/
@RequestMapping("/queryAttrDescs")
@ResponseBody
@IgnoreAuth
public R queryAttrDescs(@RequestParam("id") String id) {
if (StringUtils.isBlank(id)) {
return R.error("id不能为空!");
}
List<String> attrDescList = new ArrayList<>();
List<AttributesDescEntity> descs = attributesDescService.queryByAttrId(id);
descs.forEach(desc -> {
String attrValue = desc.getAttrValue();
String attrDesc = desc.getAttrDesc();
attrDescList.add(attrValue + "(" + attrDesc + ")");
});
return R.ok().put("list", attrDescList);
}
// /**
// * 属性值
// *
// * @param id 属性Id
// * @return url(../attributes/queryAttrDescs?id=2)
// */
// @RequestMapping("/queryAttrDescs")
// @ResponseBody
// @IgnoreAuth
// public R queryAttrDescs(@RequestParam("id") String id) {
// if (StringUtils.isBlank(id)) {
// return R.error("id不能为空!");
// }
// List<String> attrDescList = new ArrayList<>();
// List<AttributesDescEntity> descs = attributesDescService.queryByAttrId(id);
//
// descs.forEach(desc -> {
// String attrValue = desc.getAttrValue();
// String attrDesc = desc.getAttrDesc();
// attrDescList.add(attrValue + "(" + attrDesc + ")");
// });
//
// return R.ok().put("list", attrDescList);
// }
/**
* 新版商品属性(整合旧版数据)
......
package com.platform.vo;
import com.platform.entity.AttributesDescEntity;
import lombok.Data;
import java.util.List;
/**
* @Auther: wudepeng
* @Date: 2020/12/18
* @Description:
*/
@Data
public class AttributesDescVo {
private String attrDescId;
private String attrValue;
}
package com.platform.vo;
import com.platform.entity.AttributesDescEntity;
import lombok.Data;
import java.util.List;
......@@ -13,5 +14,5 @@ import java.util.List;
public class AttributesVo {
private String id;
private String attrName;
private List<String> descList;
private List<AttributesDescVo> descList;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论