Skip to content
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 @@ -93,11 +93,12 @@ public ResponseDto<GetAllArticlesResponse> getAllArticles(
public ResponseDto<ArticlesPageResponse> getAllArticlesByCategory(
@Parameter(hidden = true) @CurrentUser User user,
@Parameter(description = "카테고리 ID") @RequestParam Long categoryId,
@Parameter(description = "읽음 상태 (true: 읽음, false: 안읽음)", example = "true") @RequestParam(name = "read-status") boolean isRead,
@Parameter(description = "페이지 번호 (0부터 시작)") @RequestParam(defaultValue = "0") int page,
@Parameter(description = "페이지 크기") @RequestParam(defaultValue = "8") int size
) {
PageQuery query = new PageQuery(page, size);
ArticlesPageResponse response = getArticlePort.getAllArticlesByCategory(user, categoryId, query);
ArticlesPageResponse response = getArticlePort.getAllArticlesByCategory(user, categoryId, isRead, query);
return ResponseDto.ok(response);
Comment on lines +96 to 102
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Avoid breaking clients: make read-status optional with a default

Primitive boolean without a default makes the new query param mandatory and will 400 existing callers.

Apply:

-        @Parameter(description = "읽음 상태 (true: 읽음, false: 안읽음)", example = "true") @RequestParam(name = "read-status") boolean isRead,
+        @Parameter(description = "읽음 상태 (true: 읽음, false: 안읽음). 미지정 시 기본값 false") 
+        @RequestParam(name = "read-status", required = false, defaultValue = "false") boolean isRead,

If the FE is already updated to always send it, confirm and keep as-is.


🏁 Script executed:

#!/bin/bash
set -euo pipefail

target="api/src/main/java/com/pinback/api/article/controller/ArticleController.java"
if [ -f "$target" ]; then
  echo "FOUND:$target"
  nl -ba "$target" | sed -n '1,220p'
  exit 0
fi

file=$(rg -n --hidden --no-ignore-vcs -S "class\s+ArticleController" -g 'api/**' -l || true)
if [ -n "$file" ]; then
  echo "FOUND_SEARCH:$file"
  nl -ba "$file" | sed -n '1,220p'
  exit 0
fi

echo "NOT_FOUND"

Length of output: 122


🏁 Script executed:

#!/bin/bash
set -euo pipefail
f="api/src/main/java/com/pinback/api/article/controller/ArticleController.java"
if [ ! -f "$f" ]; then
  echo "NOT_FOUND:$f"
  rg -n --hidden --no-ignore-vcs -S "class\s+ArticleController" -g 'api/**' || true
  exit 0
fi
echo "FILE:$f"
awk '{printf "%5d: %s\n", NR, $0}' "$f" | sed -n '1,240p'
echo "----@RequestParam lines----"
awk '/@RequestParam/ {printf "%5d: %s\n", NR, $0}' "$f" || true

Length of output: 9764


Make read-status query param optional (default false)

Primitive boolean params are required by default and will 400 callers that don't send them. Two occurrences found in api/src/main/java/com/pinback/api/article/controller/ArticleController.java — update both:

  • getAllArticlesByCategory(...)
  • getRemindArticles(...)

Apply (or equivalent) for each occurrence:

- @Parameter(description = "읽음 상태 (true: 읽음, false: 안읽음)", example = "true") @RequestParam(name = "read-status") boolean isRead,
+ @Parameter(description = "읽음 상태 (true: 읽음, false: 안읽음). 미지정 시 기본값 false", example = "true")
+ @RequestParam(name = "read-status", required = false, defaultValue = "false") boolean isRead,
- @Parameter(description = "읽음 상태 (true: 읽음, false: 안읽음)", example = "true") @RequestParam(name = "read-status") boolean readStatus,
+ @Parameter(description = "읽음 상태 (true: 읽음, false: 안읽음). 미지정 시 기본값 false", example = "true")
+ @RequestParam(name = "read-status", required = false, defaultValue = "false") boolean readStatus,

If the frontend is guaranteed to always send this param, confirm and keep as-is.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Parameter(description = "읽음 상태 (true: 읽음, false: 안읽음)", example = "true") @RequestParam(name = "read-status") boolean isRead,
@Parameter(description = "페이지 번호 (0부터 시작)") @RequestParam(defaultValue = "0") int page,
@Parameter(description = "페이지 크기") @RequestParam(defaultValue = "8") int size
) {
PageQuery query = new PageQuery(page, size);
ArticlesPageResponse response = getArticlePort.getAllArticlesByCategory(user, categoryId, query);
ArticlesPageResponse response = getArticlePort.getAllArticlesByCategory(user, categoryId, isRead, query);
return ResponseDto.ok(response);
@Parameter(description = "읽음 상태 (true: 읽음, false: 안읽음). 미지정 시 기본값 false", example = "true")
@RequestParam(name = "read-status", required = false, defaultValue = "false") boolean isRead,
@Parameter(description = "페이지 번호 (0부터 시작)") @RequestParam(defaultValue = "0") int page,
@Parameter(description = "페이지 크기") @RequestParam(defaultValue = "8") int size
) {
PageQuery query = new PageQuery(page, size);
ArticlesPageResponse response = getArticlePort.getAllArticlesByCategory(user, categoryId, isRead, query);
return ResponseDto.ok(response);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public CorsConfigurationSource corsConfigurationSource() {
"https://pinback-client.vercel.app",
"https://pinback.today",
"https://landing.pinback.today",
"https://www.pinback.today"
"https://www.pinback.today",
"https://api.pinack.today"
));

configuration.setAllowedMethods(Arrays.asList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.pinback.application.article.dto.response.ArticleDetailResponse;
import com.pinback.application.article.dto.response.ArticlesPageResponse;
import com.pinback.application.article.dto.response.GetAllArticlesResponse;
import com.pinback.application.article.dto.response.RemindArticlesResponse;
import com.pinback.application.article.dto.response.TodayRemindResponse;
import com.pinback.domain.user.entity.User;

Expand All @@ -17,7 +16,7 @@ public interface GetArticlePort {

GetAllArticlesResponse getAllArticles(User user, PageQuery query);

ArticlesPageResponse getAllArticlesByCategory(User user, long categoryId, PageQuery query);
ArticlesPageResponse getAllArticlesByCategory(User user, long categoryId, boolean isRead, PageQuery query);

ArticlesPageResponse getUnreadArticles(User user, PageQuery query);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ public interface ArticleGetServicePort {

ArticlesWithUnreadCountDto findAll(User user, PageRequest pageRequest);

ArticlesWithUnreadCountDto findAllByCategory(User user, Category category, PageRequest pageRequest);
ArticlesWithUnreadCountDto findAllByCategory(User user, Category category, boolean isRead, PageRequest pageRequest);

ArticlesWithUnreadCountDto findUnreadArticles(User user, PageRequest pageRequest);

Page<Article> findTodayRemind(User user, LocalDateTime remindDateTime, Pageable pageable, Boolean isRead);

RemindArticlesWithCountDto findTodayRemindWithCount(User user, LocalDateTime remindDateTime, Pageable pageable, Boolean isRead);

RemindArticlesWithCountDto findTodayRemindWithCount(User user, LocalDateTime remindDateTime, Pageable pageable,
Boolean isRead);
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ public GetAllArticlesResponse getAllArticles(User user, PageQuery query) {
}

@Override
public ArticlesPageResponse getAllArticlesByCategory(User user, long categoryId, PageQuery query) {
public ArticlesPageResponse getAllArticlesByCategory(User user, long categoryId, boolean isRead, PageQuery query) {
Category category = getCategoryPort.getCategoryAndUser(categoryId, user);

ArticlesWithUnreadCountDto result = articleGetServicePort.findAllByCategory(
user, category, PageRequest.of(query.pageNumber(), query.pageSize()));
user, category, isRead, PageRequest.of(query.pageNumber(), query.pageSize()));

List<ArticleResponse> articleResponses = result.article().stream()
.map(ArticleResponse::from)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,15 @@ void getAllArticlesByCategory_Success() {
ArticlesWithUnreadCountDto dto = new ArticlesWithUnreadCountDto(3L, articlePage);

when(getCategoryPort.getCategoryAndUser(categoryId, user)).thenReturn(category);
when(articleGetServicePort.findAllByCategory(user, category, pageRequest)).thenReturn(dto);
when(articleGetServicePort.findAllByCategory(user, category, true, pageRequest)).thenReturn(dto);

// when
ArticlesPageResponse response = getArticleUsecase.getAllArticlesByCategory(user, categoryId, pageQuery);
ArticlesPageResponse response = getArticleUsecase.getAllArticlesByCategory(user, categoryId, true, pageQuery);

// then
assertThat(response.articles()).hasSize(3);
verify(getCategoryPort).getCategoryAndUser(categoryId, user);
verify(articleGetServicePort).findAllByCategory(user, category, pageRequest);
verify(articleGetServicePort).findAllByCategory(user, category, true, pageRequest);
}

@DisplayName("읽지 않은 아티클만 조회할 수 있다")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
public interface ArticleRepositoryCustom {
ArticlesWithUnreadCount findAllCustom(UUID userId, Pageable pageable);

ArticlesWithUnreadCount findAllByCategory(UUID userId, long articleId, Pageable pageable);
ArticlesWithUnreadCount findAllByCategory(UUID userId, long articleId, boolean isRead, Pageable pageable);

Page<Article> findTodayRemind(UUID userId, Pageable pageable, LocalDateTime startAt, LocalDateTime endAt, Boolean isRead);

RemindArticlesWithCount findTodayRemindWithCount(UUID userId, Pageable pageable, LocalDateTime startAt, LocalDateTime endAt, Boolean isRead);
Page<Article> findTodayRemind(UUID userId, Pageable pageable, LocalDateTime startAt, LocalDateTime endAt,
Boolean isRead);

RemindArticlesWithCount findTodayRemindWithCount(UUID userId, Pageable pageable, LocalDateTime startAt,
LocalDateTime endAt, Boolean isRead);

ArticlesWithUnreadCount findAllByIsReadFalse(UUID userId, Pageable pageable);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@Repository
@RequiredArgsConstructor
public class ArticleRepositoryCustomImpl implements ArticleRepositoryCustom {

private final JPAQueryFactory queryFactory;

@Override
Expand Down Expand Up @@ -58,9 +58,10 @@ public ArticlesWithUnreadCount findAllCustom(UUID userId, Pageable pageable) {
}

@Override
public ArticlesWithUnreadCount findAllByCategory(UUID userId, long categoryId, Pageable pageable) {
public ArticlesWithUnreadCount findAllByCategory(UUID userId, long categoryId, boolean isRead, Pageable pageable) {

BooleanExpression conditions = article.category.id.eq(categoryId);
BooleanExpression conditions = article.category.id.eq(categoryId)
.and(article.isRead.eq(isRead));

List<Article> articles = queryFactory
.selectFrom(article)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ public ArticlesWithUnreadCountDto findAll(User user, PageRequest pageRequest) {
}

@Override
public ArticlesWithUnreadCountDto findAllByCategory(User user, Category category, PageRequest pageRequest) {
public ArticlesWithUnreadCountDto findAllByCategory(User user, Category category, boolean isRead,
PageRequest pageRequest) {
ArticlesWithUnreadCount infraResult = articleRepository.findAllByCategory(user.getId(), category.getId(),
isRead,
pageRequest);
return convertToDto(infraResult);
}
Expand All @@ -73,12 +75,15 @@ public Article findByUserAndId(User user, long articleId) {

@Override
public Page<Article> findTodayRemind(User user, LocalDateTime remindDateTime, Pageable pageable, Boolean isRead) {
return articleRepository.findTodayRemind(user.getId(), pageable, remindDateTime, remindDateTime.plusDays(1), isRead);
return articleRepository.findTodayRemind(user.getId(), pageable, remindDateTime, remindDateTime.plusDays(1),
isRead);
}

@Override
public RemindArticlesWithCountDto findTodayRemindWithCount(User user, LocalDateTime remindDateTime, Pageable pageable, Boolean isRead) {
RemindArticlesWithCount infraResult = articleRepository.findTodayRemindWithCount(user.getId(), pageable, remindDateTime, remindDateTime.plusDays(1), isRead);
public RemindArticlesWithCountDto findTodayRemindWithCount(User user, LocalDateTime remindDateTime,
Pageable pageable, Boolean isRead) {
RemindArticlesWithCount infraResult = articleRepository.findTodayRemindWithCount(user.getId(), pageable,
remindDateTime, remindDateTime.plusDays(1), isRead);
return new RemindArticlesWithCountDto(
infraResult.readCount(),
infraResult.unreadCount(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void findAllByCategoryTest() {
PageRequest pageRequest = PageRequest.of(0, 10);

//when
ArticlesWithUnreadCountDto result = articleGetService.findAllByCategory(user, category1, pageRequest);
ArticlesWithUnreadCountDto result = articleGetService.findAllByCategory(user, category1, false, pageRequest);

//then
assertThat(result.article().getContent()).hasSize(1);
Expand Down