【发布时间】:2020-09-03 19:36:26
【问题描述】:
我有一个使用 spring boot 作为后端和 vue.js 作为前端的 web 应用程序,我有一个脚本 python 捕获,最后可以向数据库添加行,所以我需要向用户推送通知,如何我可以吗?
@PostMapping("/plate")
public ResponseEntity<Void> createPositionOc(@RequestParam String plate) {
LocalDateTime myDateObj = LocalDateTime.now();
DateTimeFormatter myFormatObj = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
List<Car> cars = carController.getAllCars();
boolean exist = cars.stream().anyMatch(o -> o.getPlate().equals(plate));
List<Car> carsIn = carController.getAllCarsIn();
boolean existIn = carsIn.stream().anyMatch(o -> o.getPlate().equals(plate));
List<Position> free = getAllPositiosFree();
PositionOcp position = new PositionOcp(free.get(0).getId_pos(), plate,
myDateObj.format(myFormatObj));
if (exist && free.size() > 0 && !existIn) {
PositionOcp createdPositionOc = positionOcpRepository.save(position);
//send notification
}
return null;
}
【问题讨论】:
标签: spring-boot vue.js notifications server-sent-events