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

属性管理

上级 c0d43f74
......@@ -180,23 +180,37 @@ public class AttributesController {
@RequestMapping("/queryAttrDescs")
@ResponseBody
@IgnoreAuth
public R queryAttrDescs(@RequestParam("id") String id) {
if (StringUtils.isBlank(id)) {
return R.error("id不能为空!");
public R queryAttrDescs(@RequestParam(value = "id", required = false) String id,
@RequestParam(value = "name", required = false) String name) {
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<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);
});
if (descs.size() > 0 && descs != null) {
map.put("attrId", id);
descs.forEach(desc -> {
AttributesDescVo descVo = new AttributesDescVo();
String attrValue = desc.getAttrValue();
String attrDesc = desc.getAttrDesc();
// 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());
return R.ok().put("list", list);
map.put("descs", list);
return R.ok().put("list", map);
}
/**
......
......@@ -12,6 +12,7 @@ import java.util.List;
*/
@Data
public class AttributesDescVo {
// private String attrId;
private String attrDescId;
private String attrValue;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论