Ignore:
Timestamp:
03/16/25 20:56:44 (3 months ago)
Author:
ste08 <sjovanoska@…>
Branches:
master
Children:
3a74959
Parents:
c064a42
Message:

Notifications + triggers!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/skychasemk/controller/NotificationController.java

    rc064a42 r8a947b9  
    22
    33import com.example.skychasemk.model.Notification;
     4import com.example.skychasemk.model.Wishlist;
     5import com.example.skychasemk.repository.NotificationRepository;
    46import com.example.skychasemk.services.NotificationService;
    57import org.springframework.beans.factory.annotation.Autowired;
     8import org.springframework.http.ResponseEntity;
    69import org.springframework.web.bind.annotation.*;
    710
     
    1619    private NotificationService notificationService;
    1720
    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);
    2228    }
    2329
    24     // Get notification by ID
    25     @GetMapping("/{id}")
    26     public Optional<Notification> getNotificationById(@PathVariable("id") Integer notificationID) {
    27         return notificationService.getNotificationById(notificationID);
    28     }
    29 
    30     // Create a new notification
    3130    @PostMapping
    3231    public Notification createNotification(@RequestBody Notification notification) {
     
    3433    }
    3534
    36     // Update an existing notification
    3735    @PutMapping("/{id}")
    3836    public Notification updateNotification(@PathVariable("id") Integer notificationID, @RequestBody Notification notification) {
     
    4038    }
    4139
    42     // Delete a notification
    4340    @DeleteMapping("/{id}")
    4441    public void deleteNotification(@PathVariable("id") Integer notificationID) {
Note: See TracChangeset for help on using the changeset viewer.