Spring boot 向所有客户端发送Spring启动推送通知
我有一个web应用程序,使用spring boot作为后端,vue.js作为前端,我有一个脚本python capture frames,当获取信息时,将其设置为服务器,最后向数据库添加一行,所以我希望在服务器添加到db时,我会收到前面的通知Spring boot 向所有客户端发送Spring启动推送通知,spring-boot,vue.js,notifications,server-sent-events,Spring Boot,Vue.js,Notifications,Server Sent Events,我有一个web应用程序,使用spring boot作为后端,vue.js作为前端,我有一个脚本python capture frames,当获取信息时,将其设置为服务器,最后向数据库添加一行,所以我希望在服务器添加到db时,我会收到前面的通知 @PostMapping("/plate") public ResponseEntity<Void> createPositionOc(@RequestParam String plate) { LocalDate
@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;
}
@PostMapping(“/plate”)
公共响应createPositionOc(@RequestParam字符串板){
LocalDateTime myDateObj=LocalDateTime.now();
DateTimeFormatter myFormatObj=模式的DateTimeFormatter.(“yyyy-MM-dd HH:MM:ss”);
List cars=carController.getAllCars();
布尔存在=cars.stream().anyMatch(o->o.getPlate().equals(plate));
List carsIn=carController.getAllCarsIn();
布尔existIn=carsIn.stream().anyMatch(o->o.getPlate().equals(plate));
List free=getAllPositiosFree();
位置OCP位置=新位置OCP(自由。获取(0)。获取ID_位置(),板,
格式(myFormatObj));
if(exist&&free.size()>0&&!existIn){
PositionOcp createdPositionOc=positionOcpRepository.save(位置);
//发送通知
}
返回null;
}