IT'S DO
728x90
public static List<ReplyResponseDto> toDtoList(List<Reply> replys) {
    NestedConvertHelper helper = NestedConvertHelper.newInstance(
            replys,
            r -> new ReplyResponseDto(r.getId(), r.isDeleted() ? null : r.getContent(), r.isDeleted() ? null : ParticipantResponseDto.toDto(r.getParticipant()), r.getCreatedDate(), new ArrayList<>()),
            r -> r.getParent(),
            r -> r.getId(),
            d -> d.getChildren());
    return helper.convert();

 

에서 ParticipantResponseDto.toDto 부분에 값을 못 받아와서 

 

Participant에 빌드 패턴으로 만들어서

값 넣어주고 아래와 같이 불러온 다음.

 

아래와 같이 만들어 준 다음.

public ParticipantResponseDto(Participant entity) {
    this.id = entity.getId();
    this.event = entity.getEvent();
    this.user = entity.getUser();
    this.name = entity.getName();
    this.state = entity.getState();
    this.createDate = entity.getCreatedDate();
    this.modifiedDate = entity.getModifiedDate();
}

 

public static List<ReplyResponseDto> toDtoList(List<Reply> replys) {
    NestedConvertHelper helper = NestedConvertHelper.newInstance(
            replys,
            r -> new ReplyResponseDto(r.getId(), r.isDeleted() ? null : r.getContent(), r.isDeleted() ? null : new ParticipantResponseDto(r.getParticipant()), r.getCreatedDate(), new ArrayList<>()),
            r -> r.getParent(),
            r -> r.getId(),
            d -> d.getChildren());
    return helper.convert();
}

 

new ParticipantResponseDto(r.getParticipant())

 만들어주어서 해결함

 

 

 

 

# api 테스트 할 때 사용

 

http://localhost:8080/api/v1/reply?opinionId=1 ==> get 조회 



{
  "title" : "제목
  "content" : "내용",
}


생성
http://localhost:8080/api/v1/reply

{
  "content" : "hi",
  "participantId" : 1,
  "opinionId" : 1,
  "parentId" : 2
}

삭제 
http://localhost:8080/api/v1/reply/9

 

profile

IT'S DO

@멋진놈

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!