mirror of
https://github.com/headporter81/specialsource-homepage-backend.git
synced 2026-10-07 15:21:09 +09:00
This commit is contained in:
@@ -26,6 +26,15 @@ public class ScrapedPostQueryService {
|
||||
return page.map(ScrapedPostResponse::from);
|
||||
}
|
||||
|
||||
public Page<ScrapedPostResponse> getViewedPosts(String boardKey, Pageable pageable) {
|
||||
// 조회한(viewedAt != null) 글만 최근 읽은 순으로 보여준다.
|
||||
Page<ScrapedPost> page = (boardKey == null || boardKey.isBlank())
|
||||
? scrapedPostRepository.findByViewedAtIsNotNullOrderByViewedAtDesc(pageable)
|
||||
: scrapedPostRepository.findByBoardKeyAndViewedAtIsNotNullOrderByViewedAtDesc(boardKey, pageable);
|
||||
|
||||
return page.map(ScrapedPostResponse::from);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void markViewed(Long id) {
|
||||
ScrapedPost post = scrapedPostRepository.findById(id)
|
||||
|
||||
@@ -18,7 +18,8 @@ public record ScrapedPostResponse(
|
||||
Integer likeCount,
|
||||
String content,
|
||||
List<String> imageUrls,
|
||||
LocalDateTime scrapedAt
|
||||
LocalDateTime scrapedAt,
|
||||
LocalDateTime viewedAt
|
||||
) {
|
||||
public static ScrapedPostResponse from(ScrapedPost post) {
|
||||
List<String> imageUrls = (post.getImageUrls() == null || post.getImageUrls().isBlank())
|
||||
@@ -38,7 +39,8 @@ public record ScrapedPostResponse(
|
||||
post.getLikeCount(),
|
||||
post.getContent(),
|
||||
imageUrls,
|
||||
post.getScrapedAt()
|
||||
post.getScrapedAt(),
|
||||
post.getViewedAt()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user