source: src/main/java/com/example/skychasemk/controller/NotificationController.java@ ff72ad2

Last change on this file since ff72ad2 was 8a947b9, checked in by ste08 <sjovanoska@…>, 3 months ago

Notifications + triggers!

  • Property mode set to 100644
File size: 1.6 KB
Line 
1package com.example.skychasemk.controller;
2
3import com.example.skychasemk.model.Notification;
4import com.example.skychasemk.model.Wishlist;
5import com.example.skychasemk.repository.NotificationRepository;
6import com.example.skychasemk.services.NotificationService;
7import org.springframework.beans.factory.annotation.Autowired;
8import org.springframework.http.ResponseEntity;
9import org.springframework.web.bind.annotation.*;
10
11import java.util.List;
12import java.util.Optional;
13
14@RestController
15@RequestMapping("/api/notifications")
16public class NotificationController {
17
18 @Autowired
19 private NotificationService notificationService;
20
21 @Autowired
22 private NotificationRepository notificationRepository;
23
24 @GetMapping("/{userId}")
25 public ResponseEntity<List<Notification>> getAllNotifications(@PathVariable Integer userId) {
26 List<Notification> notifications = notificationRepository.findByUserId(userId);
27 return ResponseEntity.ok(notifications);
28 }
29
30 @PostMapping
31 public Notification createNotification(@RequestBody Notification notification) {
32 return notificationService.saveNotification(notification);
33 }
34
35 @PutMapping("/{id}")
36 public Notification updateNotification(@PathVariable("id") Integer notificationID, @RequestBody Notification notification) {
37 return notificationService.updateNotification(notificationID, notification);
38 }
39
40 @DeleteMapping("/{id}")
41 public void deleteNotification(@PathVariable("id") Integer notificationID) {
42 notificationService.deleteNotification(notificationID);
43 }
44}
Note: See TracBrowser for help on using the repository browser.