Merged
Conversation
📊 코드 커버리지 리포트
|
Merged
Goder-0
reviewed
Dec 24, 2025
src/main/java/com/sofa/linkiving/domain/link/dto/response/LinkCardRes.java
Outdated
Show resolved
Hide resolved
src/main/java/com/sofa/linkiving/domain/link/dto/response/LinkCardRes.java
Show resolved
Hide resolved
src/main/java/com/sofa/linkiving/domain/link/repository/LinkRepository.java
Show resolved
Hide resolved
0b40596 to
12b52f6
Compare
4e18968 to
f4b169f
Compare
Contributor
Author
|
디스코드 논의 결과에 따라. 링크 카드와 링크 상세 조회 DTO 분리 하였습니다. |
f4b169f to
950356e
Compare
minibr
reviewed
Dec 26, 2025
950356e to
e7514d4
Compare
minibr
approved these changes
Dec 29, 2025
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
관련 이슈
PR 설명
개선하여Summary정보를 포함하도록 변경핵심 변경 사항
1. 커서 기반 페이징(Cursor Pagination) 도입 이유
Pageable(Offset) 방식 대신lastId를 사용하는 커서 방식을 도입했습니다.LIMIT N OFFSET M)은 페이지가 뒤로 갈수록 앞에서부터 모든 행을 읽고 버려야 하므로 데이터가 많아질수록 조회 속도가 급격히 느려집니다.WHERE id < lastId LIMIT size)은 인덱스를 타고 조회 시작 위치를 바로 찾을 수 있어 데이터 양과 관계없이 일정한 조회 성능을 보장합니다.2. 검증 책임 이동 (Validation Refactoring)
@Min,@Max,@Valid) 로직을 구현체(LinkController)에서 인터페이스(LinkApi)로 이동했습니다.ConstraintDeclarationException):Interface에만 제약 조건을 명시"하는 원칙을 적용했습니다.How)이 아닌 명세(What) 단계에서 정의되는 것이 아키텍처 관점에서 더 명확하다고 판단했습니다.@Validated는 Spring AOP 기반으로 동작합니다. 인터페이스에 제약 조건이 명시되어야 JDK Dynamic Proxy가 생성될 때 해당 메서드의 규약을 정확히 가로채어 검증할 수 있습니다.LinkApi):@Valid,@Min,@Max등 데이터 검증(Validation) 관련 어노테이션 배치.LinkController):@RequestBody,@PathVariable,@RequestParam등 데이터 바인딩(Binding) 관련 어노테이션 유지.작업 내용
1. API 명세 변경 (
LinkController)GET /v1/links/{id}):LinkRes대신 요약 정보가 포함된LinkCardRes를 반환하도록 변경했습니다.GET /v1/links):Pageable파라미터를 제거하고lastId(커서)와size를 받도록 수정했습니다.hasNext)를 반환합니다.2. DTO 설계 (데이터 전송 객체 분리)
계층 간 결합도를 낮추기 위해 내부 전달용 DTO와 외부 응답용 DTO를 명확히 분리했습니다.
LinkDto(Link+Summary 엔티티 래핑),LinksDto(hasNext포함) - Repository/Service 계층 간 이동.LinkCardRes와LinkDetailRes분리LinkCardRes: 링크 카드 정보 제공,LinkDetailRes: 링크 상세 정보 제공3. Repository 최적화 (
LinkRepository)new com.sofa...LinkDto(l, s)생성자 표현식을 사용하여 엔티티 전체를 로딩하는 대신 필요한 데이터만 DB 레벨에서 매핑했습니다.LEFT JOIN Summary s ON ... s.selected = true구문을 사용하여, 링크와 선택된 요약본을 단 한 번의 쿼리로 조회하도록 최적화했습니다 (N+1 문제 방지).4. Service 계층 분리
LinkQueryService(조회 전담):findByIdWithSummary: 요약 포함 단건 조회.findAllByMemberWithSummaryAndCursor:size + 1개를 조회하여hasNext여부를 판단하고 목록을 반환하는 핵심 로직 구현.LinkService(Facade 성격):LinkCardRes)로 변환하는 역할 수행.5. 테스트 작성
LinkRepositoryTest: 커서 페이징 쿼리(WHERE id < lastId) 동작 및 요약 데이터 조인(LEFT JOIN) 검증.LinkQueryServiceTest: 데이터 개수에 따른hasNext계산 로직 및 삭제된 링크 필터링 검증.LinkServiceTest: 내부 DTO -> 응답 DTO 변환 로직 검증.