Skip to content

Commit

Permalink
✨ Feat: 트리하우스 정보를 조회하는 API 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
koojun99 committed Jul 16, 2024
1 parent 13a5d29 commit ff16f04
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,13 @@ public static TreehouseResponseDTO.createTreehouse toCreateTreehouse(TreeHouse t
.treehouseId(treehouse.getId())
.build();
}

public static TreehouseResponseDTO.getTreehouseDetails toGetTreehouseDetails(TreeHouse treehouse) {
return TreehouseResponseDTO.getTreehouseDetails.builder()
.treehouseId(treehouse.getId())
.treehouseName(treehouse.getName())
.treehouseSize(treehouse.getMemberList().size())
.treehouseImageUrl(null) //TODO: 이미지 URL 설정
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.springframework.transaction.annotation.Transactional;
import treehouse.server.api.member.implementation.MemberQueryAdapter;
import treehouse.server.api.treehouse.implementation.TreehouseCommandAdapter;
import treehouse.server.api.treehouse.implementation.TreehouseQueryAdapter;
import treehouse.server.api.treehouse.presentation.dto.TreehouseRequestDTO;
import treehouse.server.api.treehouse.presentation.dto.TreehouseResponseDTO;
import treehouse.server.global.entity.treeHouse.TreeHouse;
Expand All @@ -17,6 +18,7 @@
public class TreehouseService {

private final TreehouseCommandAdapter treehouseCommandAdapter;
private final TreehouseQueryAdapter treehouseQueryAdapter;

private final MemberQueryAdapter memberQueryAdapter;

Expand All @@ -28,5 +30,10 @@ public TreehouseResponseDTO.createTreehouse createTreehouse(TreehouseRequestDTO.
return TreehouseMapper.toCreateTreehouse(savedTreehouse);
}

public TreehouseResponseDTO.getTreehouseDetails getTreehouseDetails(Long treehouseId) {
TreeHouse treehouse = treehouseQueryAdapter.getTreehouseById(treehouseId);
return TreehouseMapper.toGetTreehouseDetails(treehouse);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import treehouse.server.api.treehouse.business.TreehouseService;
import treehouse.server.api.treehouse.presentation.dto.TreehouseRequestDTO;
import treehouse.server.api.treehouse.presentation.dto.TreehouseResponseDTO;
Expand All @@ -31,4 +28,12 @@ public CommonResponse<TreehouseResponseDTO.createTreehouse> createTreehouse(
) {
return CommonResponse.onSuccess(treehouseService.createTreehouse(request));
}

@GetMapping("/{treehouseId}")
@Operation(summary = "트리하우스 조회 🔑", description = "트리하우스 정보를 조회합니다.")
public CommonResponse<TreehouseResponseDTO.getTreehouseDetails> getTreehouseDetails(
@PathVariable Long treehouseId
) {
return CommonResponse.onSuccess(treehouseService.getTreehouseDetails(treehouseId));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,16 @@ public static class createTreehouse {

private Long treehouseId;
}

@Builder
@Getter
@NoArgsConstructor
@AllArgsConstructor
public static class getTreehouseDetails {

private Long treehouseId;
private String treehouseName;
private Integer treehouseSize;
private String treehouseImageUrl;
}
}

0 comments on commit ff16f04

Please sign in to comment.