1.根据对象的属性过滤list集合
List<RespGoodsVo> list = cabinetLockerGridService.queryGoodsByLocker(lockerId);
List<RespGoodsVo> filterList = list.stream().filter(goods -> Integer.parseInt(goods.getNum()) > 0).collect(Collectors.toList());
2.lambad表达式里调用方法 将集合中每一个用户加1分
public void updateScoreEveryMonth() {
List<CabinetUserScoreEntity> userList= cabinetUserScoreService.getAllUserScore();
userList.stream().forEach(user->updateScore(user,1));
}
private void updateScore(CabinetUserScoreEntity user, int monthNum) {
int score = user.getScore();
user.setScore(score+monthNum);
cabinetUserScoreService.update(user);
}