Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 알림 리스트 가져오기 수정 #202

Merged
merged 1 commit into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/ceos/bankids/dto/NotificationListDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ public class NotificationListDTO {
@ApiModelProperty(example = "list")
private List<NotificationDTO> notificationList;

public NotificationListDTO(Long lastId, List<NotificationDTO> notificationList) {
@ApiModelProperty(example = "false")
private Boolean isLast;

public NotificationListDTO(Long lastId, Boolean isLast,
List<NotificationDTO> notificationList) {
this.lastId = lastId;
this.notificationList = notificationList;
this.isLast = isLast;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<NotificationDTO> 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
Expand Down