From 045cdc5092cb3398a35d1cedc9f6a5ac97b956e8 Mon Sep 17 00:00:00 2001 From: yummygyudon Date: Tue, 5 Dec 2023 16:39:12 +0900 Subject: [PATCH] =?UTF-8?q?Revert=20:=20=EC=9E=98=EB=AA=BB=EB=90=9C=20?= =?UTF-8?q?=EB=B0=B0=ED=8F=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification/NotificationService.java | 37 ++------ .../postgres/NotificationRepository.java | 1 - .../notification/NotificationController.java | 78 ++--------------- .../notification/NotificationResponse.java | 85 ------------------- 4 files changed, 12 insertions(+), 189 deletions(-) diff --git a/src/main/java/org/sopt/app/application/notification/NotificationService.java b/src/main/java/org/sopt/app/application/notification/NotificationService.java index 6c662706..08ee0e21 100644 --- a/src/main/java/org/sopt/app/application/notification/NotificationService.java +++ b/src/main/java/org/sopt/app/application/notification/NotificationService.java @@ -31,12 +31,6 @@ public Notification findNotification(User user, String notificationId) { return notificationRepository.findByNotificationIdAndUserId(notificationId, user.getId()) .orElseThrow(() -> new BadRequestException(ErrorCode.NOTIFICATION_NOT_FOUND.getMessage())); } - @Transactional(readOnly = true) - @Deprecated - public Notification findNotificationDeprecated(User user, Long notificationId) { - return notificationRepository.findByIdAndUserId(notificationId, user.getId()) - .orElseThrow(() -> new BadRequestException(ErrorCode.NOTIFICATION_NOT_FOUND.getMessage())); - } @Transactional(readOnly = true) public List findNotificationList(User user, Pageable pageable) { @@ -84,30 +78,6 @@ public void updateNotificationIsRead(User user, String notificationId) { updateSingleNotificationIsRead(user, notificationId); } } - @Transactional - @Deprecated - public void updateNotificationIsReadDeprecated(User user, Long notificationId) { - if (Objects.isNull(notificationId)) { - updateAllNotificationIsRead(user); - } else { - updateSingleNotificationIsReadDeprecated(user, notificationId); - } - } - - private void updateSingleNotificationIsRead(User user, String notificationId) { - val notification = notificationRepository.findByNotificationIdAndUserId(notificationId, user.getId()) - .orElseThrow(() -> new BadRequestException(ErrorCode.NOTIFICATION_NOT_FOUND.getMessage())); - notification.updateIsRead(); - notificationRepository.save(notification); - } - - @Deprecated - private void updateSingleNotificationIsReadDeprecated(User user, Long notificationId) { - val notification = notificationRepository.findByIdAndUserId(notificationId, user.getId()) - .orElseThrow(() -> new BadRequestException(ErrorCode.NOTIFICATION_NOT_FOUND.getMessage())); - notification.updateIsRead(); - notificationRepository.save(notification); - } private void updateAllNotificationIsRead(User user) { val notificationList = notificationRepository.findAllByUserId(user.getId()); @@ -120,6 +90,13 @@ private void updateAllNotificationIsRead(User user) { notificationRepository.saveAll(readNotificationList); } + private void updateSingleNotificationIsRead(User user, String notificationId) { + val notification = notificationRepository.findByNotificationIdAndUserId(notificationId, user.getId()) + .orElseThrow(() -> new BadRequestException(ErrorCode.NOTIFICATION_NOT_FOUND.getMessage())); + notification.updateIsRead(); + notificationRepository.save(notification); + } + @Transactional(readOnly = true) public Boolean getNotificationConfirmStatus(User user) { val notificationList = notificationRepository.findAllByUserId(user.getId()); diff --git a/src/main/java/org/sopt/app/interfaces/postgres/NotificationRepository.java b/src/main/java/org/sopt/app/interfaces/postgres/NotificationRepository.java index 4c755036..d7e3df67 100644 --- a/src/main/java/org/sopt/app/interfaces/postgres/NotificationRepository.java +++ b/src/main/java/org/sopt/app/interfaces/postgres/NotificationRepository.java @@ -12,6 +12,5 @@ public interface NotificationRepository extends JpaRepository findAllByUserId(Long userId, Pageable pageable); - Optional findByIdAndUserId(Long id, Long userId); Optional findByNotificationIdAndUserId(String notificationId, Long userId); } diff --git a/src/main/java/org/sopt/app/presentation/notification/NotificationController.java b/src/main/java/org/sopt/app/presentation/notification/NotificationController.java index fb7c98cd..3601b3e5 100644 --- a/src/main/java/org/sopt/app/presentation/notification/NotificationController.java +++ b/src/main/java/org/sopt/app/presentation/notification/NotificationController.java @@ -39,7 +39,7 @@ public class NotificationController { @ApiResponse(responseCode = "200", description = "success"), @ApiResponse(responseCode = "500", description = "server error", content = @Content) }) - @GetMapping(value = "/all") + @GetMapping(value = "") public ResponseEntity> findNotificationList( @AuthenticationPrincipal User user, @PageableDefault(size = 10, sort = "createdAt", direction = Sort.Direction.DESC) Pageable pageable @@ -62,7 +62,7 @@ public ResponseEntity> findNotific @ApiResponse(responseCode = "200", description = "success"), @ApiResponse(responseCode = "500", description = "server error", content = @Content) }) - @GetMapping(value = "/detail/{notificationId}") + @GetMapping(value = "/{notificationId}") public ResponseEntity findNotificationDetail( @AuthenticationPrincipal User user, @PathVariable("notificationId") String notificationId @@ -70,8 +70,8 @@ public ResponseEntity findNotificationD val result = notificationService.findNotification(user, notificationId); return ResponseEntity.status(HttpStatus.OK).body( NotificationResponse.NotificationDetail.of( - result.getNotificationId(), - result.getUserId(), + notificationId, + user.getId(), result.getTitle(), result.getContent(), result.getDeepLink(), @@ -103,7 +103,7 @@ public ResponseEntity registerNotification( @ApiResponse(responseCode = "500", description = "server error", content = @Content) }) @PatchMapping(value = { - "/read/{notificationId}", "/read" + "/{notificationId}", "" }) public ResponseEntity updateNotificationIsRead( @AuthenticationPrincipal User user, @@ -113,72 +113,4 @@ public ResponseEntity updateNotificationIsRead( return ResponseEntity.status(HttpStatus.OK).body(null); } - - - @Operation(summary = "알림 목록 조회 - DEPRECATED") - @ApiResponses({ - @ApiResponse(responseCode = "200", description = "success"), - @ApiResponse(responseCode = "500", description = "server error", content = @Content) - }) - @GetMapping(value = "") - @Deprecated - public ResponseEntity> findNotificationListDeprecated( - @AuthenticationPrincipal User user, - @PageableDefault(size = 10, sort = "createdAt", direction = Sort.Direction.DESC) Pageable pageable - ) { - val result = notificationService.findNotificationList(user, pageable); - return ResponseEntity.status(HttpStatus.OK).body( - result.stream() - .map((notification) -> NotificationResponse.NotificationSimpleDeprecated.of( - notification.getId() - , notification.getUserId() - , notification.getTitle() - , notification.getContent() - , notification.getCategory().name() - , notification.getIsRead() - , notification.getCreatedAt() - )).toList()); - } - @Operation(summary = "알림 상세 조회 - DEPRECATED") - @ApiResponses({ - @ApiResponse(responseCode = "200", description = "success"), - @ApiResponse(responseCode = "500", description = "server error", content = @Content) - }) - @GetMapping(value = "/{notificationId}") - @Deprecated - public ResponseEntity findNotificationDetailDeprecated( - @AuthenticationPrincipal User user, - @PathVariable("notificationId") Long notificationId - ) { - val result = notificationService.findNotificationDeprecated(user, notificationId); - return ResponseEntity.status(HttpStatus.OK).body( - NotificationResponse.NotificationDetailDeprecated.of( - result.getId(), - result.getUserId(), - result.getTitle(), - result.getContent(), - result.getDeepLink(), - result.getWebLink(), - result.getCreatedAt(), - result.getUpdatedAt() - ) - ); - } - - @Operation(summary = "알림 읽음 여부 변경 - DEPRECATED") - @ApiResponses({ - @ApiResponse(responseCode = "200", description = "success"), - @ApiResponse(responseCode = "500", description = "server error", content = @Content) - }) - @PatchMapping(value = { - "/{notificationId}", "" - }) - @Deprecated - public ResponseEntity updateNotificationIsReadDeprecated( - @AuthenticationPrincipal User user, - @PathVariable(name = "notificationId", required = false) Long notificationId - ) { - notificationService.updateNotificationIsReadDeprecated(user, notificationId); - return ResponseEntity.status(HttpStatus.OK).body(null); - } } diff --git a/src/main/java/org/sopt/app/presentation/notification/NotificationResponse.java b/src/main/java/org/sopt/app/presentation/notification/NotificationResponse.java index 5595d6e2..6fd2155c 100644 --- a/src/main/java/org/sopt/app/presentation/notification/NotificationResponse.java +++ b/src/main/java/org/sopt/app/presentation/notification/NotificationResponse.java @@ -104,89 +104,4 @@ public static NotificationConfirmStatus of( ); } } - - @Getter - @NoArgsConstructor(access = AccessLevel.PRIVATE) - @AllArgsConstructor(access = AccessLevel.PRIVATE) - @ToString - @Deprecated - public static class NotificationSimpleDeprecated { - - @Schema(description = "알림 아이디", example = "1") - private Long id; - - @Schema(description = "앱 유저 아이디", example = "1") - private Long userId; - - @Schema(description = "알림 제목", example = "공지다!") - private String title; - - @Schema(description = "알림 내용", example = "공지 내용은 앱팀 최고입니다.") - private String content; - - @Schema(description = "알림 카테고리", example = "NOTICE") - private String category; - - @Schema(description = "알림 읽음 여부", example = "true") - private Boolean isRead; - - @Schema(description = "알림 생성 일시", example = "2023-03-29T18:39:42.106369") - private LocalDateTime createdAt; - - public static NotificationSimpleDeprecated of( - Long notificationId - , Long userId - , String title - , String content - , String category - , Boolean isRead - , LocalDateTime createdAt - ) { - return new NotificationSimpleDeprecated( - notificationId, userId, title, content, category, isRead, createdAt - ); - } - } - - @Getter - @NoArgsConstructor(access = AccessLevel.PRIVATE) - @AllArgsConstructor(access = AccessLevel.PRIVATE) - @ToString - @Deprecated - public static class NotificationDetailDeprecated { - - @Schema(description = "알림 아이디", example = "1") - private Long id; - @Schema(description = "유저 아이디", example = "1") - private Long userId; - @Schema(description = "알림 제목", example = "공지다!") - private String title; - @Schema(description = "알림 내용", example = "공지 내용은 앱팀 최고입니다.") - private String content; - @Schema(description = "알림 첨부 딥링크") - private String deepLink; - @Schema(description = "알림 첨부 웹링크") - private String webLink; - @Schema(description = "알림 생성 일시", example = "2023-03-29T18:39:42.106369") - private LocalDateTime createdAt; - @Schema(description = "알림 수정 일시", example = "2023-03-29T18:39:42.106369") - private LocalDateTime updatedAt; - - public static NotificationDetailDeprecated of( - Long notificationId - , Long userId - , String title - , String content - , String deepLink - , String webLink - , LocalDateTime createdAt - , LocalDateTime updatedAt - ) { - return new NotificationDetailDeprecated( - notificationId, userId, title, content, deepLink, webLink, createdAt, updatedAt - ); - } - } - - }