【问题标题】:Spring boot push notificationSpring Boot 推送通知
【发布时间】: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


    【解决方案1】:

    您将首先通过阅读有关推送通知的 spring 文档或类似这样的教程来实现这一点:https://spring.io/guides/gs/messaging-stomp-websocket

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-23
      • 2015-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-27
      相关资源
      最近更新 更多