-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
97 additions
and
3 deletions.
There are no files selected for viewing
35 changes: 34 additions & 1 deletion
35
src/main/java/org/example/tree/domain/notification/controller/NotificationController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,42 @@ | ||
package org.example.tree.domain.notification.controller; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.example.tree.domain.notification.dto.NotificationResponseDTO; | ||
import org.example.tree.domain.notification.service.NotificationService; | ||
import org.example.tree.global.common.ApiResponse; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/notifications") | ||
public class NotificationController { | ||
|
||
private final NotificationService notificationService; | ||
|
||
@Operation(summary = "알림 생성 테스트") | ||
@PostMapping("/test") | ||
public ApiResponse<NotificationResponseDTO.sendNotification> sendNotification( | ||
@RequestBody final NotificationRequestDTO.sendNotification request) | ||
{ | ||
return ApiResponse.onSuccess(notificationService.sendNotification(request)); | ||
} | ||
|
||
@Operation(summary = "전체 알림 조회", description = "유저가 받은 알림들을 조회합니다.") | ||
@GetMapping | ||
public ApiResponse<List<NotificationResponseDTO.getNotification>> getNotifications( | ||
@RequestHeader("Authorization") final String header) | ||
{ | ||
String token = header.replace("Bearer ", ""); | ||
return ApiResponse.onSuccess(notificationService.getUserNotifications(token)); | ||
} | ||
|
||
@Operation(summary = "특정 알림 조회", description = "유저가 받은 알림 중 하나를 조회합니다.") | ||
@GetMapping("/{notificationId}") | ||
public ApiResponse<NotificationResponseDTO.getNotification> getNotification( | ||
@PathVariable final Long notificationId) | ||
{ | ||
return ApiResponse.onSuccess(notificationService.getNotification(notificationId)); | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/org/example/tree/domain/notification/converter/NotificationConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.example.tree.domain.notification.converter; | ||
|
||
import org.example.tree.domain.member.entity.Member; | ||
import org.example.tree.domain.notification.entity.Notification; | ||
import org.example.tree.domain.notification.entity.NotificationType; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class NotificationConverter { | ||
|
||
public Notification toNotification(String title, String message, String type, Member receiver) { | ||
return Notification.builder() | ||
.title(title) | ||
.message(message) | ||
.type(NotificationType.valueOf(type)) | ||
.receiver(receiver) | ||
.build(); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/org/example/tree/domain/notification/dto/NotificationRequestDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.example.tree.domain.notification.dto; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
|
||
public class NotificationRequestDTO { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/org/example/tree/domain/notification/entity/NotificationType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package org.example.tree.domain.notification.entity; | ||
|
||
public enum NotificationType { | ||
INVITATION, COMMENT, LIKE | ||
INVITATION, COMMENT, REACTION | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/org/example/tree/domain/notification/service/NotificationCommandService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package org.example.tree.domain.notification.service; | ||
|
||
public class NotificationCommandService { | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/org/example/tree/domain/notification/service/NotificationQueryService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package org.example.tree.domain.notification.service; | ||
|
||
public class NotificationQueryService { | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/org/example/tree/domain/notification/service/NotificationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,26 @@ | ||
package org.example.tree.domain.notification.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.example.tree.domain.member.entity.Member; | ||
import org.example.tree.domain.notification.converter.NotificationConverter; | ||
import org.example.tree.domain.notification.entity.Notification; | ||
import org.example.tree.domain.notification.repository.NotificationRepository; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.List; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class NotificationService { | ||
|
||
private final NotificationRepository notificationRepository; | ||
private final NotificationCommandService notificationCommandService; | ||
private final NotificationQueryService notificationQueryService; | ||
private final NotificationConverter notificationConverter; | ||
|
||
public Notification sendNotification(String title, String message, String type, Member receiver) { | ||
} | ||
|
||
public List<Notification> getUserNotifications(String token) { | ||
} | ||
} |