Skip to content

[DP-410] 스크랩 목록 조회 API#133

Merged
github-actions[bot] merged 1 commit intodevelopV2from
auto/feature/DP-410-scrap-list-api
Apr 24, 2026
Merged

[DP-410] 스크랩 목록 조회 API#133
github-actions[bot] merged 1 commit intodevelopV2from
auto/feature/DP-410-scrap-list-api

Conversation

@nYeonG4001
Copy link
Copy Markdown
Collaborator

작업 내용

GET /users/me/scraps — 인증된 사용자의 스크랩 목록을 페이징/검색/정렬하여 반환하는 API를 구현합니다.

주요 구현 사항

엔드포인트

  • GET /users/me/scraps?q=&sort=newest&page=0&size=10
  • 인증 필요 (Authorization: Bearer {token})

검색 (q)

  • title, sourceName, preview 3개 필드에 대해 대소문자 무관 LIKE 검색
  • q가 null이거나 blank이면 전체 조회 (null 정규화)

정렬 (sort)

  • newest (기본값): createdAt DESC
  • oldest: createdAt ASC

페이지네이션

  • 기본 page=0, size=10
  • 응답에 totalElements, totalPages 포함

AI 요약 연동

  • AiSummaryRepository.batchFindCoreSummaries로 스크랩된 콘텐츠의 AI 요약을 N+1 없이 배치 조회
  • 사용자 레벨(easy/medium/hard)에 맞는 요약 반환
  • DynamoDB 조회 실패 시 content.preview로 자동 fallback (서비스 중단 없음)
  • preview도 없으면 summary: null 반환 (프론트에서 처리)

신규 파일

파일 역할
ScrapController.java GET /users/me/scraps 엔드포인트
ScrapService.java 검색/정렬/페이지네이션 + AI 요약 배치 조회
ScrapItemResponse.java 스크랩 항목 응답 DTO (record)
ScrapListResponse.java 스크랩 목록 페이지 응답 DTO (record)

수정 파일

파일 변경 내용
ScrapRepository.java findScrapsWithSearch JPQL 쿼리 추가 (JOIN FETCH + countQuery 분리)

응답 예시

{
  "success": true,
  "data": {
    "content": [
      {
        "id": "uuid",
        "contentId": "uuid",
        "title": "Spring Boot 완전 정복",
        "sourceName": "velog",
        "thumbnail": "https://...",
        "summary": "핵심 요약 텍스트",
        "createdAt": "2026-04-20T10:00:00Z"
      }
    ],
    "page": 0,
    "size": 10,
    "totalElements": 42,
    "totalPages": 5
  }
}

테스트 커버리지

클래스 라인 브랜치
ScrapService 100% 100%
ScrapItemResponse 100% 100%
ScrapController 100% -
ScrapListResponse 100% -

ScrapServiceTest (10개)

  • 존재하지 않는 유저 → USER_NOT_FOUND 예외
  • 스크랩 없는 유저 → 빈 리스트 반환
  • 스크랩 있는 유저 → 항목 정상 반환
  • sort=oldestcreatedAt ASC 적용
  • sort=newestcreatedAt DESC 적용
  • AI 요약 있을 때 summary에 AI 요약 반환
  • AI 요약 없을 때 preview fallback
  • DynamoDB 예외 시 preview fallback
  • q 비공백 전달 시 trim된 값이 레포지토리로 전달
  • q 공백 문자열 → null 정규화
  • preview null + AI 요약 없음 → summary null
  • preview blank + AI 요약 없음 → summary null

ScrapControllerTest (3개)

  • GET /users/me/scraps 정상 조회 시 200 반환
  • 빈 결과 시 200 반환
  • q 파라미터 서비스로 정상 전달

@github-actions github-actions Bot merged commit e178806 into developV2 Apr 24, 2026
2 checks passed
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant