- Timestamp:
- 03/16/25 20:56:44 (3 months ago)
- Branches:
- master
- Children:
- 3a74959
- Parents:
- c064a42
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/skychasemk/controller/NotificationController.java
rc064a42 r8a947b9 2 2 3 3 import com.example.skychasemk.model.Notification; 4 import com.example.skychasemk.model.Wishlist; 5 import com.example.skychasemk.repository.NotificationRepository; 4 6 import com.example.skychasemk.services.NotificationService; 5 7 import org.springframework.beans.factory.annotation.Autowired; 8 import org.springframework.http.ResponseEntity; 6 9 import org.springframework.web.bind.annotation.*; 7 10 … … 16 19 private NotificationService notificationService; 17 20 18 // Get all notifications 19 @GetMapping 20 public List<Notification> getAllNotifications() { 21 return notificationService.getAllNotifications(); 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); 22 28 } 23 29 24 // Get notification by ID25 @GetMapping("/{id}")26 public Optional<Notification> getNotificationById(@PathVariable("id") Integer notificationID) {27 return notificationService.getNotificationById(notificationID);28 }29 30 // Create a new notification31 30 @PostMapping 32 31 public Notification createNotification(@RequestBody Notification notification) { … … 34 33 } 35 34 36 // Update an existing notification37 35 @PutMapping("/{id}") 38 36 public Notification updateNotification(@PathVariable("id") Integer notificationID, @RequestBody Notification notification) { … … 40 38 } 41 39 42 // Delete a notification43 40 @DeleteMapping("/{id}") 44 41 public void deleteNotification(@PathVariable("id") Integer notificationID) {
Note:
See TracChangeset
for help on using the changeset viewer.