Last change
on this file was 8a947b9, checked in by ste08 <sjovanoska@…>, 3 months ago |
Notifications + triggers!
|
-
Property mode
set to
100644
|
File size:
1.6 KB
|
Rev | Line | |
---|
[57e58a3] | 1 | package com.example.skychasemk.controller;
|
---|
| 2 |
|
---|
| 3 | import com.example.skychasemk.model.Notification;
|
---|
[8a947b9] | 4 | import com.example.skychasemk.model.Wishlist;
|
---|
| 5 | import com.example.skychasemk.repository.NotificationRepository;
|
---|
[57e58a3] | 6 | import com.example.skychasemk.services.NotificationService;
|
---|
| 7 | import org.springframework.beans.factory.annotation.Autowired;
|
---|
[8a947b9] | 8 | import org.springframework.http.ResponseEntity;
|
---|
[57e58a3] | 9 | import org.springframework.web.bind.annotation.*;
|
---|
| 10 |
|
---|
| 11 | import java.util.List;
|
---|
| 12 | import java.util.Optional;
|
---|
| 13 |
|
---|
| 14 | @RestController
|
---|
| 15 | @RequestMapping("/api/notifications")
|
---|
| 16 | public class NotificationController {
|
---|
| 17 |
|
---|
| 18 | @Autowired
|
---|
| 19 | private NotificationService notificationService;
|
---|
| 20 |
|
---|
[8a947b9] | 21 | @Autowired
|
---|
| 22 | private NotificationRepository notificationRepository;
|
---|
[57e58a3] | 23 |
|
---|
[8a947b9] | 24 | @GetMapping("/{userId}")
|
---|
| 25 | public ResponseEntity<List<Notification>> getAllNotifications(@PathVariable Integer userId) {
|
---|
| 26 | List<Notification> notifications = notificationRepository.findByUserId(userId);
|
---|
| 27 | return ResponseEntity.ok(notifications);
|
---|
[57e58a3] | 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.