提交 919f3f82 authored 作者: 吴德鹏's avatar 吴德鹏

属性管理

上级 c0d43f74
...@@ -180,23 +180,37 @@ public class AttributesController { ...@@ -180,23 +180,37 @@ public class AttributesController {
@RequestMapping("/queryAttrDescs") @RequestMapping("/queryAttrDescs")
@ResponseBody @ResponseBody
@IgnoreAuth @IgnoreAuth
public R queryAttrDescs(@RequestParam("id") String id) { public R queryAttrDescs(@RequestParam(value = "id", required = false) String id,
if (StringUtils.isBlank(id)) { @RequestParam(value = "name", required = false) String name) {
return R.error("id不能为空!");
if (StringUtils.isBlank(id) && StringUtils.isBlank(name))
return R.error("参数不能为空!");
if (StringUtils.isNotBlank(name)) {
AttributesEntity attributes = attributesService.queryByAttrName(name);
id = attributes.getId();
} }
Map<String, Object> map = new LinkedHashMap<>();
List<AttributesDescEntity> descs = attributesDescService.queryByAttrId(id); List<AttributesDescEntity> descs = attributesDescService.queryByAttrId(id);
List<AttributesDescVo> attributesVos = new ArrayList<>(); List<AttributesDescVo> attributesVos = new ArrayList<>();
descs.forEach(desc -> { if (descs.size() > 0 && descs != null) {
AttributesDescVo descVo = new AttributesDescVo(); map.put("attrId", id);
String attrValue = desc.getAttrValue(); descs.forEach(desc -> {
String attrDesc = desc.getAttrDesc(); AttributesDescVo descVo = new AttributesDescVo();
descVo.setAttrDescId(desc.getAttrDescId()); String attrValue = desc.getAttrValue();
descVo.setAttrValue(attrValue + "(" + attrDesc + ")"); String attrDesc = desc.getAttrDesc();
attributesVos.add(descVo); // descVo.setAttrId(desc.getAttrId());
}); descVo.setAttrDescId(desc.getAttrDescId());
descVo.setAttrValue(attrValue + "(" + attrDesc + ")");
attributesVos.add(descVo);
});
}
List<AttributesDescVo> list = attributesVos.stream().sorted(Comparator.comparing(AttributesDescVo::getAttrValue)).collect(Collectors.toList()); List<AttributesDescVo> list = attributesVos.stream().sorted(Comparator.comparing(AttributesDescVo::getAttrValue)).collect(Collectors.toList());
return R.ok().put("list", list); map.put("descs", list);
return R.ok().put("list", map);
} }
/** /**
......
...@@ -12,6 +12,7 @@ import java.util.List; ...@@ -12,6 +12,7 @@ import java.util.List;
*/ */
@Data @Data
public class AttributesDescVo { public class AttributesDescVo {
// private String attrId;
private String attrDescId; private String attrDescId;
private String attrValue; private String attrValue;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论