Skip to content

Commit a542bc7

Browse files
committed
ProblemDetail & decisionNode test
1 parent 0580d48 commit a542bc7

27 files changed

+1529
-431
lines changed

back/src/main/java/com/back/domain/node/controller/BaseLineController.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import com.back.domain.node.dto.BaseLineBulkCreateRequest;
88
import com.back.domain.node.dto.BaseLineBulkCreateResponse;
9-
import com.back.domain.node.dto.BaseLineDto;
9+
import com.back.domain.node.dto.BaseNodeDto;
1010
import com.back.domain.node.dto.PivotListDto;
1111
import com.back.domain.node.service.NodeService;
1212
import lombok.RequiredArgsConstructor;
@@ -35,16 +35,15 @@ public ResponseEntity<PivotListDto> getPivots(@PathVariable Long baseLineId) {
3535
return ResponseEntity.ok(nodeService.getPivotBaseNodes(baseLineId));
3636
}
3737

38-
// GET /api/v1/base-lines/{baseLineId}/nodes
38+
// 전체 노드 목록 반환
3939
@GetMapping("/{baseLineId}/nodes")
40-
public ResponseEntity<List<BaseLineDto>> getBaseLineNodes(@PathVariable Long baseLineId) {
40+
public ResponseEntity<List<BaseNodeDto>> getBaseLineNodes(@PathVariable Long baseLineId) {
4141
return ResponseEntity.ok(nodeService.getBaseLineNodes(baseLineId));
4242
}
4343

44-
// GET /api/v1/base-lines/node/{baseNodeId}
45-
@GetMapping("/node/{baseNodeId}")
46-
public ResponseEntity<BaseLineDto> getBaseNode(@PathVariable Long baseNodeId) {
44+
// 단일 노드 반환
45+
@GetMapping("/nodes/{baseNodeId}")
46+
public ResponseEntity<BaseNodeDto> getBaseNode(@PathVariable Long baseNodeId) {
4747
return ResponseEntity.ok(nodeService.getBaseNode(baseNodeId));
4848
}
49-
5049
}

back/src/main/java/com/back/domain/node/controller/DecisionFlowController.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
/**
22
* [API] 피벗에서 시작→연속 저장→완료/취소 흐름
3-
* - from-base: 첫 결정 생성
4-
* - next: 다음 결정 생성
3+
* - from-base: 첫 결정 생성(서버가 피벗 노드 해석)
4+
* - next: 다음 결정 생성(라인은 부모에서 해석)
55
* - cancel: 라인 취소(파기)
66
* - complete: 라인 완료(잠금)
77
*/
88
package com.back.domain.node.controller;
99

10-
import com.back.domain.node.dto.*;
10+
import com.back.domain.node.dto.DecLineDto;
11+
import com.back.domain.node.dto.DecisionLineLifecycleDto;
12+
import com.back.domain.node.dto.DecisionNodeFromBaseRequest;
13+
import com.back.domain.node.dto.DecisionNodeNextRequest;
1114
import com.back.domain.node.service.NodeService;
1215
import lombok.RequiredArgsConstructor;
1316
import org.springframework.http.*;
@@ -20,21 +23,25 @@ public class DecisionFlowController {
2023

2124
private final NodeService nodeService;
2225

26+
// from-base: 라인+피벗(순번/나이)+분기슬롯 인덱스만 받아 서버가 pivotBaseNodeId를 해석
2327
@PostMapping("/from-base")
2428
public ResponseEntity<DecLineDto> createFromBase(@RequestBody DecisionNodeFromBaseRequest request) {
2529
return ResponseEntity.status(HttpStatus.CREATED).body(nodeService.createDecisionNodeFromBase(request));
2630
}
2731

32+
// next: 부모 결정 id만 받아 서버가 라인/다음 나이/베이스 매칭을 해석
2833
@PostMapping("/next")
2934
public ResponseEntity<DecLineDto> createNext(@RequestBody DecisionNodeNextRequest request) {
3035
return ResponseEntity.status(HttpStatus.CREATED).body(nodeService.createDecisionNodeNext(request));
3136
}
3237

38+
// 라인 취소
3339
@PostMapping("/{decisionLineId}/cancel")
3440
public ResponseEntity<DecisionLineLifecycleDto> cancel(@PathVariable Long decisionLineId) {
3541
return ResponseEntity.ok(nodeService.cancelDecisionLine(decisionLineId));
3642
}
3743

44+
// 라인 완료
3845
@PostMapping("/{decisionLineId}/complete")
3946
public ResponseEntity<DecisionLineLifecycleDto> complete(@PathVariable Long decisionLineId) {
4047
return ResponseEntity.ok(nodeService.completeDecisionLine(decisionLineId));

back/src/main/java/com/back/domain/node/controller/DecisionFromBaseController.java

Lines changed: 0 additions & 26 deletions
This file was deleted.

back/src/main/java/com/back/domain/node/dto/BaseLineBulkCreateRequest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
public record BaseLineBulkCreateRequest(
1111
Long userId,
12+
String title,
1213
List<BaseNodePayload> nodes
1314
) {
1415
public record BaseNodePayload(

back/src/main/java/com/back/domain/node/dto/BaseLineDto.java

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* [DTO-RES] BaseNode 응답
3+
* - 고정 선택과 분기 2칸 및 각 타겟 링크를 포함한다
4+
*/
5+
package com.back.domain.node.dto;
6+
7+
import com.back.domain.node.entity.NodeCategory;
8+
9+
public record BaseNodeDto(
10+
Long id,
11+
Long userId,
12+
String type,
13+
NodeCategory category,
14+
String situation,
15+
String decision,
16+
Integer ageYear,
17+
Long baseLineId,
18+
Long parentId,
19+
String title,
20+
String fixedChoice,
21+
String altOpt1,
22+
String altOpt2,
23+
Long altOpt1TargetDecisionId,
24+
Long altOpt2TargetDecisionId
25+
) {}
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
/**
22
* [DTO-RES] DecisionNode 응답
3-
* - background: AI 생성 설명(옵션)
3+
* - options/selectedIndex/parentOptionIndex를 포함해 프론트 렌더 정보를 제공한다
44
*/
55
package com.back.domain.node.dto;
66

77
import com.back.domain.node.entity.NodeCategory;
8+
import java.util.List;
89

910
public record DecLineDto(
1011
Long id,
1112
Long userId,
12-
String type, // "DECISION"
13+
String type,
1314
NodeCategory category,
1415
String situation,
1516
String decision,
1617
Integer ageYear,
1718
Long decisionLineId,
1819
Long parentId,
1920
Long baseNodeId,
20-
String background
21-
) {
22-
23-
}
21+
String background,
22+
List<String> options,
23+
Integer selectedIndex,
24+
Integer parentOptionIndex
25+
) {}
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/**
22
* [DTO-REQ] DecisionNode 생성 요청
3-
* - decisionLineId 없으면 새 라인 생성
4-
* - parentId 또는 baseNodeId 중 하나 사용
3+
* - 서비스 내부 매퍼용으로 사용되며 외부 API에서는 직접 받지 않는다
54
*/
65
package com.back.domain.node.dto;
76

87
import com.back.domain.node.entity.NodeCategory;
8+
import java.util.List;
99

1010
public record DecisionNodeCreateRequestDto(
1111
Long decisionLineId,
@@ -14,5 +14,8 @@ public record DecisionNodeCreateRequestDto(
1414
NodeCategory category,
1515
String situation,
1616
String decision,
17-
Integer ageYear
17+
Integer ageYear,
18+
List<String> options,
19+
Integer selectedIndex,
20+
Integer parentOptionIndex
1821
) {}
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
/**
2-
* [DTO-REQ] BaseLine의 특정 분기점(BaseNode)에서 DecisionNode 생성 요청
3-
* - category/situation/ageYear 미지정 시 pivot 값 상속
2+
* [DTO-REQ] BaseLine 피벗에서 첫 결정 생성 요청(슬림 계약 + 옵션 지원)
3+
* - 서버가 baseLineId + (pivotOrd | pivotAge)로 피벗 노드를 해석하고, selectedAltIndex(0/1) 분기 슬롯을 링크한다
44
*/
55
package com.back.domain.node.dto;
66

77
import com.back.domain.node.entity.NodeCategory;
8+
import java.util.List;
89

910
public record DecisionNodeFromBaseRequest(
1011
Long userId,
1112
Long baseLineId,
12-
Long pivotBaseNodeId,
13-
NodeCategory category,
14-
String situation,
15-
String decision,
16-
Integer ageYear
13+
Integer pivotOrd, // 피벗 순번(중간 노드 기준, 0부터) — null이면 pivotAge 사용
14+
Integer pivotAge, // 피벗 나이 — null이면 pivotOrd 사용
15+
Integer selectedAltIndex, // 0 또는 1
16+
NodeCategory category, // 미지정 시 pivot.category 상속
17+
String situation, // 미지정 시 pivot.situation 상속
18+
List<String> options, // 1~3개, null 가능(첫 결정 노드도 옵션 보유 가능)
19+
Integer selectedIndex // 0..2, null 가능(주어지면 decision과 일치)
1720
) {}
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
/**
2-
* [DTO-REQ] 직전 DecisionNode(parent)에서 다음 DecisionNode 생성
3-
* - ageYear 미지정 시 자동으로 다음 피벗 나이 선택
2+
* [DTO-REQ] 직전 DecisionNode(parent)에서 다음 DecisionNode 생성(슬림 계약)
3+
* - 라인은 부모로부터 해석하고, ageYear 미지정 시 다음 피벗 나이 자동 선택
44
*/
55
package com.back.domain.node.dto;
66

77
import com.back.domain.node.entity.NodeCategory;
8+
import java.util.List;
89

910
public record DecisionNodeNextRequest(
1011
Long userId,
1112
Long parentDecisionNodeId,
12-
Long decisionLineId,
13-
NodeCategory category,
14-
String situation,
15-
String decision,
16-
Integer ageYear
13+
NodeCategory category, // 미지정 시 parent.category 상속
14+
String situation, // 미지정 시 parent.situation 상속
15+
Integer ageYear, // null이면 다음 피벗 자동 선택
16+
List<String> options, // 1~3개, null 가능
17+
Integer selectedIndex, // 0..2, null 가능
18+
Integer parentOptionIndex // 부모 옵션 인덱스(0..2), null 가능
1719
) {}

0 commit comments

Comments
 (0)