Core 모듈과 API 모듈 간 데이터 전달을 위한 DTO를 응답에도 계속 사용해도 괜찮을까 #33
hwangdaesun
started this conversation in
General
Replies: 1 comment
-
모놀리식Controller - Service - Repository (3 layered) 멀티 모듈하지만, 현재 프로젝트 환경은 다음과 같음
이러한 구조를 가진 상태에서 DTO가 여러 모듈을 넘어다니는게 맞는지에 대한 의문이 생기는 상황,, graph TD
A[API Module] --> B[Core Module]
B --> C[BookResponseDTO]
A --> C
현재 상황DTO 재사용을 할 경우 모듈 결합도가 증가하는 점을 고려하여 중간 변경 과정을 추가 example // FindAllBookResponse.java
public record FindAllBookResponse(
List<BookResponseDTO> bookList
) {
public static FindAllBookResponse of(List<BookResponseDTO> response) {
return new FindAllBookResponse(response);
}
}
// FindBookUseCase.java
@Service
@RequiredArgsConstructor
public class FindBookUseCase {
private final MemberBookRepository memberBookRepository;
@Transactional(readOnly = true)
public FindAllBookResponse findAllMemberBooks(Long memberId, ReadStatus readStatus) {
return FindAllBookResponse.of(
memberBookRepository.findMemberBookByMemberIdAndReadStatus(memberId, readStatus));
}
} 더 좋은 방안이 있는지 찾아봐야 할 것으로 보입니다. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
각각의 장단점을 정리하고 규칙을 정하면 좋을 거 같습니다.
Beta Was this translation helpful? Give feedback.
All reactions