From 724d24d91608290f27c21b7affce116e17ed120a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=A4=80?= Date: Wed, 7 Sep 2022 21:27:08 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=95=8C=EB=A6=BC=20=EB=A6=AC=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EA=B0=80=EC=A0=B8=EC=98=A4=EA=B8=B0=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/request/ChallengeRequest.java | 2 +- .../com/ceos/bankids/dto/NotificationListDTO.java | 7 ++++++- .../service/ExpoNotificationServiceImpl.java | 14 ++++++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/ceos/bankids/controller/request/ChallengeRequest.java b/src/main/java/com/ceos/bankids/controller/request/ChallengeRequest.java index 7e983823..0fbe41cb 100644 --- a/src/main/java/com/ceos/bankids/controller/request/ChallengeRequest.java +++ b/src/main/java/com/ceos/bankids/controller/request/ChallengeRequest.java @@ -37,7 +37,7 @@ public class ChallengeRequest { @ApiModelProperty(example = "에어팟 사기") @NotBlank(message = "돈길의 제목을 입력해주세요") - @Length(min = 3, max = 15, message = "돈길 제목 길이를 확인해주세요") + @Length(max = 12, message = "돈길 제목 길이를 확인해주세요") private String title; @ApiModelProperty(example = "30") diff --git a/src/main/java/com/ceos/bankids/dto/NotificationListDTO.java b/src/main/java/com/ceos/bankids/dto/NotificationListDTO.java index 03e88412..48db879f 100644 --- a/src/main/java/com/ceos/bankids/dto/NotificationListDTO.java +++ b/src/main/java/com/ceos/bankids/dto/NotificationListDTO.java @@ -19,8 +19,13 @@ public class NotificationListDTO { @ApiModelProperty(example = "list") private List notificationList; - public NotificationListDTO(Long lastId, List notificationList) { + @ApiModelProperty(example = "false") + private Boolean isLast; + + public NotificationListDTO(Long lastId, Boolean isLast, + List notificationList) { this.lastId = lastId; this.notificationList = notificationList; + this.isLast = isLast; } } diff --git a/src/main/java/com/ceos/bankids/service/ExpoNotificationServiceImpl.java b/src/main/java/com/ceos/bankids/service/ExpoNotificationServiceImpl.java index f87a3fda..0bd1e744 100644 --- a/src/main/java/com/ceos/bankids/service/ExpoNotificationServiceImpl.java +++ b/src/main/java/com/ceos/bankids/service/ExpoNotificationServiceImpl.java @@ -49,14 +49,24 @@ public NotificationListDTO readNotificationList(User user, Long lastId) { .collect(Collectors.toList()); NotificationDTO lastNotification = notificationDTOS.get(notificationDTOS.size() - 1); Long lastNotificationId = lastNotification.getId(); - return new NotificationListDTO(lastNotificationId, notificationDTOS); + if (notificationDTOS.size() == 11L) { + notificationDTOS.remove(10); + return new NotificationListDTO(lastNotificationId, false, notificationDTOS); + } else if (notificationDTOS.size() < 11L) { + return new NotificationListDTO(lastNotificationId, true, notificationDTOS); + } } List notificationDTOList = notificationRepository.findByIdLessThanAndUserIdOrderByIdDesc( lastId, user.getId(), pageRequest).stream() .map(NotificationDTO::new).collect(Collectors.toList()); NotificationDTO lastNotification = notificationDTOList.get(notificationDTOList.size() - 1); Long last = lastNotification.getId(); - return new NotificationListDTO(last, notificationDTOList); + if (notificationDTOList.size() <= 11L) { + notificationDTOList.remove(10); + return new NotificationListDTO(last, false, notificationDTOList); + } else { + return new NotificationListDTO(last, true, notificationDTOList); + } } @Transactional