-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
168 additions
and
30 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
src/main/java/org/example/tree/domain/branch/controller/BranchController.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,24 @@ | ||
package org.example.tree.domain.branch.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.example.tree.domain.branch.dto.BranchResponseDTO; | ||
import org.example.tree.domain.branch.service.BranchService; | ||
import org.example.tree.global.common.ApiResponse; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class BranchController { | ||
|
||
private final BranchService branchService; | ||
|
||
@GetMapping("/trees/{treeId}/branchView") | ||
public ApiResponse<BranchResponseDTO.branchView> getBranchView( | ||
@PathVariable Long treeId, | ||
@RequestParam("memberId") Long profileId, | ||
@RequestHeader("Authorization") final String header | ||
) { | ||
String token = header.replace("Bearer ", ""); | ||
return ApiResponse.onSuccess(branchService.getBranchView(treeId, token, profileId)); | ||
} | ||
} |
This file contains 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
51 changes: 51 additions & 0 deletions
51
src/main/java/org/example/tree/domain/branch/dto/BranchResponseDTO.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,55 @@ | ||
package org.example.tree.domain.branch.dto; | ||
|
||
import lombok.*; | ||
|
||
import java.util.List; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
|
||
public class BranchResponseDTO { | ||
|
||
@Builder | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class ShortestPathResult{ | ||
private int distance; | ||
private List<Long> path; | ||
} | ||
|
||
// Node 정보를 담을 클래스 | ||
@Builder | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class NodeDTO { | ||
private Long id; | ||
private String profileImageUrl; | ||
private String memberName; | ||
|
||
// 생성자, getter, setter 생략 | ||
} | ||
|
||
// Link 정보를 담을 클래스 | ||
@Builder | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class LinkDTO { | ||
private Long sourceId; | ||
private Long targetId; | ||
|
||
// 생성자, getter, setter 생략 | ||
} | ||
|
||
@Builder | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class branchView{ | ||
private List<NodeDTO> nodes; | ||
private List<LinkDTO> links; | ||
private Long startId; | ||
private Long endId; | ||
} | ||
} |
This file contains 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