微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Spring Boot推送通知

如何解决Spring Boot推送通知

我有一个Web应用程序,它使用spring boot作为后端,而vue.js作为前端,并且我有一个脚本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;
}

解决方法

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。