-
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.
Merge pull request #28 from it-s-time-goat/dev/encJ/pushAlarm
[FEAT] 알림 목록 출력 기능 추가
- Loading branch information
Showing
14 changed files
with
208 additions
and
3 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
public record OnBoardingRequest( | ||
String nickname, | ||
String goal | ||
String goal, | ||
String fcmToken | ||
) { | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/goat/server/global/exception/AccessDeniedException.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,11 @@ | ||
package com.goat.server.global.exception; | ||
|
||
import com.goat.server.global.exception.errorcode.ErrorCode; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public class AccessDeniedException extends RuntimeException{ | ||
private final ErrorCode errorCode; | ||
} |
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
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
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
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
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
34 changes: 34 additions & 0 deletions
34
src/main/java/com/goat/server/notification/dto/response/NotificationResponse.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,34 @@ | ||
package com.goat.server.notification.dto.response; | ||
|
||
import com.goat.server.notification.domain.Notification; | ||
import lombok.Builder; | ||
|
||
import java.util.List; | ||
|
||
@Builder | ||
public record NotificationResponse( | ||
List<NotificationComponentResponse> notifications | ||
) { | ||
@Builder | ||
public record NotificationComponentResponse( | ||
Long notificationId, | ||
Long reviewId, | ||
String reviewBody, | ||
Boolean isRead | ||
){ | ||
public static NotificationComponentResponse from(Notification notification) { | ||
return NotificationComponentResponse.builder() | ||
.notificationId(notification.getNoti_id()) | ||
.reviewId(notification.getReview().getId()) | ||
.reviewBody(notification.getContent()) | ||
.isRead(notification.getIsRead()) | ||
.build(); | ||
} | ||
} | ||
|
||
public static NotificationResponse from(List<NotificationComponentResponse> notifications) { | ||
return NotificationResponse.builder() | ||
.notifications(notifications) | ||
.build(); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/com/goat/server/notification/presentation/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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.goat.server.notification.presentation; | ||
|
||
import com.goat.server.global.dto.ResponseTemplate; | ||
import com.goat.server.notification.application.NotificationService; | ||
import com.goat.server.notification.dto.response.NotificationResponse; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@Slf4j | ||
@RequiredArgsConstructor | ||
@RestController | ||
@Tag(name = "NotificationController", description = "NotificationController 관련 API") | ||
@RequestMapping("/goat/notification") | ||
public class NotificationController { | ||
|
||
private final NotificationService notificationService; | ||
|
||
@Operation(summary = "알림 목록 출력", description = "알림 목록 보기") | ||
@GetMapping | ||
public ResponseEntity<ResponseTemplate<Object>> getNotifications(@AuthenticationPrincipal Long userId) { | ||
|
||
log.info("[NotificationController.getNotifications]"); | ||
|
||
NotificationResponse notification = notificationService.getNotifications(userId); | ||
|
||
return ResponseEntity | ||
.status(HttpStatus.OK) | ||
.body(ResponseTemplate.from(notification)); | ||
} | ||
|
||
@Operation(summary = "알림 읽음 표시", description = "알림 읽음 표시") | ||
@GetMapping("/{notificationId}") | ||
public ResponseEntity<ResponseTemplate<Object>> readNotification(@AuthenticationPrincipal Long userId, @PathVariable Long notificationId) { | ||
|
||
log.info("[NotificationController.readNotification]"); | ||
|
||
notificationService.readNotification(userId, notificationId); | ||
|
||
return ResponseEntity | ||
.status(HttpStatus.OK) | ||
.body(ResponseTemplate.EMPTY_RESPONSE); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/com/goat/server/notification/repository/NotificationRepository.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,7 +1,12 @@ | ||
package com.goat.server.notification.repository; | ||
|
||
import com.goat.server.mypage.domain.User; | ||
import com.goat.server.notification.domain.Notification; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
|
||
public interface NotificationRepository extends JpaRepository<Notification, Long> { | ||
|
||
List<Notification> findAllByUser(User user); | ||
} |
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
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
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