Skip to content

Commit

Permalink
Revert : 잘못된 배포
Browse files Browse the repository at this point in the history
  • Loading branch information
yummygyudon committed Dec 5, 2023
1 parent c99564c commit 045cdc5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 189 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Notification> findNotificationList(User user, Pageable pageable) {
Expand Down Expand Up @@ -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());
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ public interface NotificationRepository extends JpaRepository<Notification, Long

List<Notification> findAllByUserId(Long userId, Pageable pageable);

Optional<Notification> findByIdAndUserId(Long id, Long userId);
Optional<Notification> findByNotificationIdAndUserId(String notificationId, Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<List<NotificationResponse.NotificationSimple>> findNotificationList(
@AuthenticationPrincipal User user,
@PageableDefault(size = 10, sort = "createdAt", direction = Sort.Direction.DESC) Pageable pageable
Expand All @@ -62,16 +62,16 @@ public ResponseEntity<List<NotificationResponse.NotificationSimple>> findNotific
@ApiResponse(responseCode = "200", description = "success"),
@ApiResponse(responseCode = "500", description = "server error", content = @Content)
})
@GetMapping(value = "/detail/{notificationId}")
@GetMapping(value = "/{notificationId}")
public ResponseEntity<NotificationResponse.NotificationDetail> findNotificationDetail(
@AuthenticationPrincipal User user,
@PathVariable("notificationId") String notificationId
) {
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(),
Expand Down Expand Up @@ -103,7 +103,7 @@ public ResponseEntity registerNotification(
@ApiResponse(responseCode = "500", description = "server error", content = @Content)
})
@PatchMapping(value = {
"/read/{notificationId}", "/read"
"/{notificationId}", ""
})
public ResponseEntity<NotificationDetail> updateNotificationIsRead(
@AuthenticationPrincipal User user,
Expand All @@ -113,72 +113,4 @@ public ResponseEntity<NotificationDetail> 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<List<NotificationResponse.NotificationSimpleDeprecated>> 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<NotificationResponse.NotificationDetailDeprecated> 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<NotificationDetail> updateNotificationIsReadDeprecated(
@AuthenticationPrincipal User user,
@PathVariable(name = "notificationId", required = false) Long notificationId
) {
notificationService.updateNotificationIsReadDeprecated(user, notificationId);
return ResponseEntity.status(HttpStatus.OK).body(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}


}

0 comments on commit 045cdc5

Please sign in to comment.