增加批量更新商品信息的接口

This commit is contained in:
季圣华 2022-05-15 22:13:01 +08:00
parent ad9ee39c80
commit 46eca9c424
2 changed files with 30 additions and 0 deletions

View File

@ -624,4 +624,24 @@ public class MaterialController {
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
}
}
/**
* 批量更新商品信息
* @param jsonObject
* @param request
* @return
* @throws Exception
*/
@PostMapping(value = "/batchUpdate")
@ApiOperation(value = "批量更新商品信息")
public String batchUpdate(@RequestBody JSONObject jsonObject,
HttpServletRequest request)throws Exception {
Map<String, Object> objectMap = new HashMap<>();
int res = materialService.batchUpdate(jsonObject);
if(res > 0) {
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
} else {
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
}
}
}

View File

@ -1080,4 +1080,14 @@ public class MaterialService {
}
return res;
}
public int batchUpdate(JSONObject jsonObject) {
String ids = jsonObject.getString("ids");
String materialStr = jsonObject.getString("material");
List<Long> idList = StringUtil.strToLongList(ids);
Material material = JSONObject.parseObject(materialStr, Material.class);
MaterialExample example = new MaterialExample();
example.createCriteria().andIdIn(idList).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
return materialMapper.updateByExampleSelective(material, example);
}
}