-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: Cursor 네이밍 추가 * refactor: 조회하는 쿼리와 Read를 True로 변경하는 쿼리 분리 * feat: 오프셋기반 조회 dto 추가 * feat: 오프셋 기반 사용자 알림 목록 조회 구현 * test: 오프셋 기반 사용자 알림 조회 컨트롤러 테스트 구현 * fix: createAt -> createdAt * fix: replay -> reply * docs: API 문서 최신화
- Loading branch information
Showing
16 changed files
with
405 additions
and
110 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
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/ssafy/ssafsound/domain/notification/dto/GetNotificationOffsetReqDto.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.ssafy.ssafsound.domain.notification.dto; | ||
|
||
import lombok.*; | ||
import lombok.experimental.SuperBuilder; | ||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.data.domain.Sort; | ||
|
||
import javax.validation.constraints.Min; | ||
|
||
@Getter | ||
@Setter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class GetNotificationOffsetReqDto { | ||
@Builder.Default | ||
private Integer page = 1; | ||
|
||
@Min(value = 10, message = "Size가 너무 작습니다.") | ||
@Builder.Default | ||
private Integer size = 10; | ||
|
||
public void setPage(Integer page) { | ||
if (page <= 0) { | ||
this.page = 1; | ||
return; | ||
} | ||
this.page = page; | ||
} | ||
|
||
public PageRequest toPageRequest() { | ||
return PageRequest.of(this.page - 1, this.size, Sort.Direction.DESC, "id"); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/ssafy/ssafsound/domain/notification/dto/GetNotificationOffsetResDto.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,28 @@ | ||
package com.ssafy.ssafsound.domain.notification.dto; | ||
|
||
import com.ssafy.ssafsound.domain.notification.domain.Notification; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import org.springframework.data.domain.Page; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Getter | ||
@Builder | ||
public class GetNotificationOffsetResDto { | ||
private List<GetNotificationElement> notifications; | ||
private Integer currentPage; | ||
private Integer totalPageCount; | ||
|
||
public static GetNotificationOffsetResDto of(Page<Notification> notifications) { | ||
return GetNotificationOffsetResDto.builder() | ||
.notifications(notifications.getContent().stream() | ||
.map(GetNotificationElement::from) | ||
.collect(Collectors.toList())) | ||
.currentPage(notifications.getNumber() + 1) | ||
.totalPageCount(notifications.getTotalPages()) | ||
.build(); | ||
|
||
} | ||
} |
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
3 changes: 3 additions & 0 deletions
3
src/main/java/com/ssafy/ssafsound/domain/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,9 +1,12 @@ | ||
package com.ssafy.ssafsound.domain.notification.repository; | ||
|
||
import com.ssafy.ssafsound.domain.notification.domain.Notification; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.mongodb.repository.MongoRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface NotificationRepository extends MongoRepository<Notification, String>, NotificationCustomRepository { | ||
Page<Notification> findAllByOwnerId(Long ownerId, Pageable pageable); | ||
} |
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
Oops, something went wrong.