diff --git a/src/main/java/com/example/pladialmserver/booking/service/CarBookingService.java b/src/main/java/com/example/pladialmserver/booking/service/CarBookingService.java index a5be4b3b..e4894ecf 100644 --- a/src/main/java/com/example/pladialmserver/booking/service/CarBookingService.java +++ b/src/main/java/com/example/pladialmserver/booking/service/CarBookingService.java @@ -93,7 +93,7 @@ public void rejectProductBooking(User user, Long carBookingId) { emailUtil.createBookingData(SendEmailReq.toDto(carBooking, REJECT_BOOKING_TEXT)), BOOKING_TEMPLATE); // 차랑 예약 반려 알림 try { - notificationService.sendNotification(Constants.NotificationCategory.CAR, Constants.Notification.BODY_DENIED, user); + notificationService.sendNotification(carBooking.getCar().getName(), Constants.NotificationCategory.CAR, Constants.Notification.BODY_DENIED, user); } catch (IOException e) { e.printStackTrace(); } @@ -148,7 +148,7 @@ private void sendReturnNotification(User user, CarBooking carBooking) { emailUtil.createBookingData(SendEmailReq.toDto(carBooking, RETURN_BOOKING_TEXT)), BOOKING_TEMPLATE); // 차랑 예약 반납 알림 try { - notificationService.sendNotification(Constants.NotificationCategory.CAR, Constants.Notification.BODY_RETURNED, user); + notificationService.sendNotification(carBooking.getCar().getName(), Constants.NotificationCategory.CAR, Constants.Notification.BODY_RETURNED, user); } catch (IOException e) { e.printStackTrace(); } @@ -202,7 +202,7 @@ public void cancelBookingProduct(User user, Long carBookingId) { // 차량 예약 취소 알림 try { - notificationService.sendNotification(Constants.NotificationCategory.CAR, Constants.Notification.BODY_CANCELED, user); + notificationService.sendNotification(carBooking.getCar().getName(), Constants.NotificationCategory.CAR, Constants.Notification.BODY_CANCELED, user); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/main/java/com/example/pladialmserver/booking/service/OfficeBookingService.java b/src/main/java/com/example/pladialmserver/booking/service/OfficeBookingService.java index 790fae22..51308e16 100644 --- a/src/main/java/com/example/pladialmserver/booking/service/OfficeBookingService.java +++ b/src/main/java/com/example/pladialmserver/booking/service/OfficeBookingService.java @@ -105,7 +105,7 @@ public void cancelBookingOffice(User user, Long officeBookingId) { // 회의실 예약 취소 알림 try { - notificationService.sendNotification(Constants.NotificationCategory.OFFICE, Constants.Notification.BODY_CANCELED, user); + notificationService.sendNotification(officeBooking.getOffice().getName(), Constants.NotificationCategory.OFFICE, Constants.Notification.BODY_CANCELED, user); } catch (IOException e) { e.printStackTrace(); } @@ -191,7 +191,7 @@ public void cancelBookingOfficeByAdmin(User user, Long officeBookingId) { // 회의실 예약 반려 알림 try { - notificationService.sendNotification(Constants.NotificationCategory.OFFICE, Constants.Notification.BODY_DENIED, user); + notificationService.sendNotification(officeBooking.getOffice().getName(), Constants.NotificationCategory.OFFICE, Constants.Notification.BODY_DENIED, user); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/main/java/com/example/pladialmserver/booking/service/ResourceBookingService.java b/src/main/java/com/example/pladialmserver/booking/service/ResourceBookingService.java index fd6446d8..c0d62bc4 100644 --- a/src/main/java/com/example/pladialmserver/booking/service/ResourceBookingService.java +++ b/src/main/java/com/example/pladialmserver/booking/service/ResourceBookingService.java @@ -124,7 +124,7 @@ public void cancelBookingProduct(User user, Long resourceBookingId) { // 장비 예약 취소 알림 try { - notificationService.sendNotification(Constants.NotificationCategory.RESOURCE, Constants.Notification.BODY_CANCELED, user); + notificationService.sendNotification(resourceBooking.getResource().getName(), Constants.NotificationCategory.RESOURCE, Constants.Notification.BODY_CANCELED, user); } catch (IOException e) { e.printStackTrace(); } @@ -175,7 +175,7 @@ public void rejectProductBooking(User user, Long resourceBookingId) { // 장비 예약 반려 알림 try { - notificationService.sendNotification(Constants.NotificationCategory.RESOURCE, Constants.Notification.BODY_DENIED, resourceBooking.getUser()); + notificationService.sendNotification(resourceBooking.getResource().getName(), Constants.NotificationCategory.RESOURCE, Constants.Notification.BODY_DENIED, resourceBooking.getUser()); } catch (IOException e) { e.printStackTrace(); } @@ -201,7 +201,7 @@ public void allowProductBooking(User user, Long resourceBookingId) { emailUtil.createBookingData(SendEmailReq.toDto(resourceBooking, APPROVE_BOOKING_TEXT)), BOOKING_TEMPLATE); // 장비 예약 알림 try { - notificationService.sendNotification(Constants.NotificationCategory.RESOURCE, Constants.Notification.BODY_SUCCESS, resourceBooking.getResource().getUser()); + notificationService.sendNotification(resourceBooking.getResource().getName(), Constants.NotificationCategory.RESOURCE, Constants.Notification.BODY_SUCCESS, resourceBooking.getResource().getUser()); } catch (IOException e) { e.printStackTrace(); } @@ -225,7 +225,7 @@ private void sendReturnNotification(User user, ResourceBooking resourceBooking) emailUtil.createBookingData(SendEmailReq.toDto(resourceBooking, RETURN_BOOKING_TEXT)), BOOKING_TEMPLATE); // 장비 반납 알림 try { - notificationService.sendNotification(Constants.NotificationCategory.RESOURCE, Constants.Notification.BODY_RETURNED, user); + notificationService.sendNotification(resourceBooking.getResource().getName(), Constants.NotificationCategory.RESOURCE, Constants.Notification.BODY_RETURNED, user); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/main/java/com/example/pladialmserver/global/Constants.java b/src/main/java/com/example/pladialmserver/global/Constants.java index c0c4c05c..6f3a5687 100644 --- a/src/main/java/com/example/pladialmserver/global/Constants.java +++ b/src/main/java/com/example/pladialmserver/global/Constants.java @@ -58,10 +58,11 @@ public static class NotificationCategory{ } public static class Notification { - public static final String BODY_SUCCESS = "예약이 완료되었습니다."; + public static final String SPACE = " "; + public static final String BODY_SUCCESS = "예약이 승인되었습니다."; public static final String BODY_DENIED = "예약이 반려되었습니다."; public static final String BODY_CANCELED = "예약이 취소되었습니다."; - public static final String BODY_RETURNED = "예약이 종료되었습니다."; + public static final String BODY_RETURNED = "반납 확인되었습니다."; public static final String TITLE_SUCCESS = "예약 완료"; public static final String TITLE_DENIED = "예약 반려"; public static final String TITLE_CANCELED = "예약 취소"; diff --git a/src/main/java/com/example/pladialmserver/notification/service/PushNotificationService.java b/src/main/java/com/example/pladialmserver/notification/service/PushNotificationService.java index 5b18209b..1f938316 100644 --- a/src/main/java/com/example/pladialmserver/notification/service/PushNotificationService.java +++ b/src/main/java/com/example/pladialmserver/notification/service/PushNotificationService.java @@ -40,9 +40,9 @@ public class PushNotificationService { private final EmailUtil emailUtil; @Transactional - public void sendNotification(String category, String type, User user) throws IOException { + public void sendNotification(String name, String category, String type, User user) throws IOException { String title = getTitle(category, type); - String messageBody = category + type; + String messageBody = name + Constants.Notification.SPACE + type; if (user.getFcmToken() != null) { FcmMessage fcmMessage = FcmMessage.makeMessage(user.getFcmToken(), title, messageBody); Response response = sendMessage(objectMapper.writeValueAsString(fcmMessage)); diff --git a/src/main/java/com/example/pladialmserver/product/car/service/CarService.java b/src/main/java/com/example/pladialmserver/product/car/service/CarService.java index 2f48ee4f..b7984412 100644 --- a/src/main/java/com/example/pladialmserver/product/car/service/CarService.java +++ b/src/main/java/com/example/pladialmserver/product/car/service/CarService.java @@ -90,7 +90,7 @@ public void bookProduct(User user, Long resourceId, ProductReq productReq) { emailUtil.createBookingData(SendEmailReq.toDto(carBooking, NEW_BOOKING_TEXT)), BOOKING_TEMPLATE); // 차량 예약 알림 try { - notificationService.sendNotification(Constants.NotificationCategory.RESOURCE, Constants.Notification.BODY_SUCCESS, car.getUser()); + notificationService.sendNotification(car.getName(), Constants.NotificationCategory.RESOURCE, Constants.Notification.BODY_SUCCESS, car.getUser()); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/main/java/com/example/pladialmserver/product/resource/service/ResourceService.java b/src/main/java/com/example/pladialmserver/product/resource/service/ResourceService.java index 1076f450..86e615d9 100644 --- a/src/main/java/com/example/pladialmserver/product/resource/service/ResourceService.java +++ b/src/main/java/com/example/pladialmserver/product/resource/service/ResourceService.java @@ -118,7 +118,7 @@ public void bookProduct(User user, Long resourceId, ProductReq productReq) { // 차량 예약 알림 try { - notificationService.sendNotification(Constants.NotificationCategory.RESOURCE, Constants.Notification.BODY_SUCCESS, resource.getUser()); + notificationService.sendNotification(resource.getName(), Constants.NotificationCategory.RESOURCE, Constants.Notification.BODY_SUCCESS, resource.getUser()); } catch (IOException e) { e.printStackTrace(); }