完善商品属性接口,支持新增、删除和查询

This commit is contained in:
季圣华
2022-08-30 00:40:48 +08:00
parent 52bd683c7b
commit 654a246d84
10 changed files with 31 additions and 139 deletions

View File

@@ -31,8 +31,8 @@ public class MaterialAttributeComponent implements ICommonQuery {
private List<?> getMaterialList(Map<String, String> map) throws Exception{
String search = map.get(Constants.SEARCH);
String attributeField = StringUtil.getInfo(search, "attributeField");
return materialAttributeService.select(attributeField, QueryUtils.offset(map), QueryUtils.rows(map));
String attributeName = StringUtil.getInfo(search, "attributeName");
return materialAttributeService.select(attributeName, QueryUtils.offset(map), QueryUtils.rows(map));
}
@Override

View File

@@ -49,6 +49,7 @@ public class MaterialAttributeService {
public List<MaterialAttribute> getMaterialAttribute() throws Exception{
MaterialAttributeExample example = new MaterialAttributeExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("id desc");
List<MaterialAttribute> list=null;
try{
list=materialAttributeMapper.selectByExample(example);
@@ -58,31 +59,11 @@ public class MaterialAttributeService {
return list;
}
public List<MaterialAttribute> select(String attributeField, int offset, int rows)
public List<MaterialAttribute> select(String attributeName, int offset, int rows)
throws Exception{
String[] arr = {"manyColor","manySize","other1","other2","other3"};
Map<String, String> map = new HashMap<>();
map.put("manyColor", "多颜色");
map.put("manySize", "多尺寸");
map.put("other1", "自定义1");
map.put("other2", "自定义2");
map.put("other3", "自定义3");
List<MaterialAttribute> list = new ArrayList<>();
try{
List<MaterialAttribute> maList = materialAttributeMapperEx.selectByConditionMaterialAttribute(attributeField, offset, rows);
for(String field: arr) {
MaterialAttribute materialAttribute = new MaterialAttribute();
materialAttribute.setAttributeField(field);
materialAttribute.setAttributeName(map.get(field));
for(MaterialAttribute ma: maList) {
if(field.equals(ma.getAttributeField())){
materialAttribute.setId(ma.getId());
materialAttribute.setAttributeName(ma.getAttributeName());
materialAttribute.setAttributeValue(ma.getAttributeValue());
}
}
list.add(materialAttribute);
}
list = materialAttributeMapperEx.selectByConditionMaterialAttribute(attributeName, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}