본문 바로가기
TIL

레벨 테스트 작업 로그 #10 - 중첩 DTO 를 사용할 때 (22.12.08 TIL)

by winteringg 2022. 12. 8.

주문 조회 페이지를 구현 중..백엔드 코드는 구현되었고 프론트에서 내가 주문한 상품 목록이 나와야 하는데 아무것도 찍히지 않는 상황이 발생했다. OrderDto 안에서 ProductDto 를 사용한 중첩 DTO 를 구현했는데 아무 생각 없이 getter 를 만든 것이 패인이었다.

public class OrderDto {
    private Long id;
    private Integer quantity;
    private Long totalPrice;
    private String receiver;
    private String address;
    private String message;
    private ProductDto product;
    private LocalDateTime createdAt;

    public OrderDto() {
    }

    public OrderDto(Long id, Integer quantity, Long totalPrice, String receiver,
                    String address, String message, ProductDto product, LocalDateTime createdAt) {
        this.id = id;
        this.quantity = quantity;
        this.totalPrice = totalPrice;
        this.receiver = receiver;
        this.address = address;
        this.message = message;
        this.product = product;
        this.createdAt = createdAt;
    }

	....생략....

    public ProductDto getProductDto() {
        return product;
    }
}


중첩된 DTO 를 사용하려면 getter 뒤의 이름을 수정하면 된다. 해당 에러는 우리 기수인 Boni 가 올린 TIL 을 통해 해결할 수 있었는데, 그 덕에 아샬님 피드백도 다시 보고 내가 너무 기계적으로 코드를 치지 않았나 다시 생각하는 계기가 되었다.

 

12/7 TIL | 레벨 테스트 작업 일지 Day 10. 오늘은 TIL이 긴데.. 그만큼 한 게 많다는 것이겠죠(찡긋)

🔙 이전 시리즈 12/6 TIL | 레벨 테스트 작업 일지 Day 9. 집중 집중 집중👏 🔙 이전 시리즈 12/5 TIL | 레벨 테스트 작업 일지 Day 7-8. 로그인 & 회원가입 구현! 🔙 이전 시리즈 12/3 TIL | 레벨 테스트 작

bohyunkang.tistory.com

Boni 덕에 헤매고 있던 오류를 고치고 내역 불러오기 완성!

댓글