Last change
on this file since 8a947b9 was 8a947b9, checked in by ste08 <sjovanoska@…>, 3 months ago |
Notifications + triggers!
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | package com.example.skychasemk.services;
|
---|
2 |
|
---|
3 | import com.example.skychasemk.model.Notification;
|
---|
4 | import com.example.skychasemk.repository.NotificationRepository;
|
---|
5 | import org.springframework.beans.factory.annotation.Autowired;
|
---|
6 | import org.springframework.stereotype.Service;
|
---|
7 |
|
---|
8 | import java.util.List;
|
---|
9 | import java.util.Optional;
|
---|
10 |
|
---|
11 | @Service
|
---|
12 | public class NotificationService {
|
---|
13 |
|
---|
14 | @Autowired
|
---|
15 | private NotificationRepository notificationRepository;
|
---|
16 |
|
---|
17 | public List<Notification> getAllNotifications(Integer userId) {
|
---|
18 | return notificationRepository.findByUserId(userId);
|
---|
19 | }
|
---|
20 |
|
---|
21 | public Notification saveNotification(Notification notification) {
|
---|
22 | return notificationRepository.save(notification);
|
---|
23 | }
|
---|
24 |
|
---|
25 | public Notification updateNotification(Integer notificationID, Notification notification) {
|
---|
26 | if (notificationRepository.existsById(notificationID)) {
|
---|
27 | notification.setNotificationID(notificationID);
|
---|
28 | return notificationRepository.save(notification);
|
---|
29 | } else {
|
---|
30 | throw new RuntimeException("Notification not found with id " + notificationID);
|
---|
31 | }
|
---|
32 | }
|
---|
33 |
|
---|
34 | public void deleteNotification(Integer notificationID) {
|
---|
35 | notificationRepository.deleteById(notificationID);
|
---|
36 | }
|
---|
37 | }
|
---|
38 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.