Skip to content

Commit 84fe179

Browse files
committed
BaseNodeCreate
1 parent 4b7c7ad commit 84fe179

29 files changed

+1093
-86
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* [API] BaseLine 전용 엔드포인트
3+
* - 라인 단위 일괄 생성 / 중간 분기점(pivot) 조회
4+
*/
5+
package com.back.domain.node.controller;
6+
7+
import com.back.domain.node.dto.BaseLineBulkCreateRequest;
8+
import com.back.domain.node.dto.BaseLineBulkCreateResponse;
9+
import com.back.domain.node.dto.BaseLineDto;
10+
import com.back.domain.node.dto.PivotListDto;
11+
import com.back.domain.node.service.NodeService;
12+
import lombok.RequiredArgsConstructor;
13+
import org.springframework.http.HttpStatus;
14+
import org.springframework.http.ResponseEntity;
15+
import org.springframework.web.bind.annotation.*;
16+
17+
import java.util.List;
18+
19+
@RestController
20+
@RequestMapping("/api/v1/base-lines")
21+
@RequiredArgsConstructor
22+
public class BaseLineController {
23+
24+
private final NodeService nodeService;
25+
26+
// 라인 단위 일괄 생성(헤더~꼬리까지)
27+
@PostMapping("/bulk")
28+
public ResponseEntity<BaseLineBulkCreateResponse> createBaseLineBulk(@RequestBody BaseLineBulkCreateRequest request) {
29+
return ResponseEntity.status(HttpStatus.CREATED).body(nodeService.createBaseLineWithNodes(request));
30+
}
31+
32+
// 헤더/꼬리 제외 pivot 목록 반환
33+
@GetMapping("/{baseLineId}/pivots")
34+
public ResponseEntity<PivotListDto> getPivots(@PathVariable Long baseLineId) {
35+
return ResponseEntity.ok(nodeService.getPivotBaseNodes(baseLineId));
36+
}
37+
38+
// GET /api/v1/base-lines/{baseLineId}/nodes
39+
@GetMapping("/{baseLineId}/nodes")
40+
public ResponseEntity<List<BaseLineDto>> getBaseLineNodes(@PathVariable Long baseLineId) {
41+
return ResponseEntity.ok(nodeService.getBaseLineNodes(baseLineId));
42+
}
43+
44+
// GET /api/v1/base-lines/node/{baseNodeId}
45+
@GetMapping("/node/{baseNodeId}")
46+
public ResponseEntity<BaseLineDto> getBaseNode(@PathVariable Long baseNodeId) {
47+
return ResponseEntity.ok(nodeService.getBaseNode(baseNodeId));
48+
}
49+
50+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* [API] 피벗에서 시작→연속 저장→완료/취소 흐름
3+
* - from-base: 첫 결정 생성
4+
* - next: 다음 결정 생성
5+
* - cancel: 라인 취소(파기)
6+
* - complete: 라인 완료(잠금)
7+
*/
8+
package com.back.domain.node.controller;
9+
10+
import com.back.domain.node.dto.*;
11+
import com.back.domain.node.service.NodeService;
12+
import lombok.RequiredArgsConstructor;
13+
import org.springframework.http.*;
14+
import org.springframework.web.bind.annotation.*;
15+
16+
@RestController
17+
@RequestMapping("/api/v1/decision-flow")
18+
@RequiredArgsConstructor
19+
public class DecisionFlowController {
20+
21+
private final NodeService nodeService;
22+
23+
@PostMapping("/from-base")
24+
public ResponseEntity<DecLineDto> createFromBase(@RequestBody DecisionNodeFromBaseRequest request) {
25+
return ResponseEntity.status(HttpStatus.CREATED).body(nodeService.createDecisionNodeFromBase(request));
26+
}
27+
28+
@PostMapping("/next")
29+
public ResponseEntity<DecLineDto> createNext(@RequestBody DecisionNodeNextRequest request) {
30+
return ResponseEntity.status(HttpStatus.CREATED).body(nodeService.createDecisionNodeNext(request));
31+
}
32+
33+
@PostMapping("/{decisionLineId}/cancel")
34+
public ResponseEntity<DecisionLineLifecycleDto> cancel(@PathVariable Long decisionLineId) {
35+
return ResponseEntity.ok(nodeService.cancelDecisionLine(decisionLineId));
36+
}
37+
38+
@PostMapping("/{decisionLineId}/complete")
39+
public ResponseEntity<DecisionLineLifecycleDto> complete(@PathVariable Long decisionLineId) {
40+
return ResponseEntity.ok(nodeService.completeDecisionLine(decisionLineId));
41+
}
42+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* [API] BaseLine의 pivot에서 DecisionNode 생성
3+
* - 사용자가 선택한 중간 시점(BaseNode)에서 파생
4+
*/
5+
package com.back.domain.node.controller;
6+
7+
import com.back.domain.node.dto.DecLineDto;
8+
import com.back.domain.node.dto.DecisionNodeFromBaseRequest;
9+
import com.back.domain.node.service.NodeService;
10+
import lombok.RequiredArgsConstructor;
11+
import org.springframework.http.*;
12+
import org.springframework.web.bind.annotation.*;
13+
14+
@RestController
15+
@RequestMapping("/api/v1/decision-nodes")
16+
@RequiredArgsConstructor
17+
public class DecisionFromBaseController {
18+
19+
private final NodeService nodeService;
20+
21+
// pivot(BaseNode)에서 DecisionNode 생성
22+
@PostMapping("/from-base")
23+
public ResponseEntity<DecLineDto> createDecisionFromBase(@RequestBody DecisionNodeFromBaseRequest request) {
24+
return ResponseEntity.status(HttpStatus.CREATED).body(nodeService.createDecisionNodeFromBase(request));
25+
}
26+
}

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

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* [DTO-REQ] BaseLine을 라인 단위로 일괄 생성 요청(헤더~꼬리까지)
3+
* - nodes: 0=헤더, 마지막=꼬리, 사이가 피벗(분기점)
4+
*/
5+
package com.back.domain.node.dto;
6+
7+
import com.back.domain.node.entity.NodeCategory;
8+
import java.util.List;
9+
10+
public record BaseLineBulkCreateRequest(
11+
Long userId,
12+
List<BaseNodePayload> nodes
13+
) {
14+
public record BaseNodePayload(
15+
NodeCategory category,
16+
String situation,
17+
String decision,
18+
Integer ageYear
19+
) {}
20+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* [DTO-RES] BaseLine 일괄 생성 응답
3+
* - 생성된 BaseLine id와 각 노드의 id/인덱스 반환
4+
*/
5+
package com.back.domain.node.dto;
6+
7+
import java.util.List;
8+
9+
public record BaseLineBulkCreateResponse(
10+
Long baseLineId,
11+
List<CreatedNode> nodes
12+
) {
13+
public record CreatedNode(
14+
Integer index,
15+
Long nodeId
16+
) {}
17+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* [DTO-RES] BaseNode 응답
3+
* - 프론트 전송 전용: 최소 필드만 노출
4+
*/
5+
package com.back.domain.node.dto;
6+
7+
import com.back.domain.node.entity.NodeCategory;
8+
9+
public record BaseLineDto(
10+
Long id,
11+
Long userId,
12+
String type, // "BASE"
13+
NodeCategory category,
14+
String situation,
15+
String decision,
16+
Integer ageYear,
17+
Long baseLineId,
18+
Long parentId
19+
) {
20+
21+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* [DTO-REQ] BaseNode 단건 생성 요청
3+
* - nodeKind는 BASE 권장
4+
*/
5+
package com.back.domain.node.dto;
6+
7+
import com.back.domain.node.entity.NodeCategory;
8+
import com.back.domain.node.entity.NodeType;
9+
10+
public record BaseNodeCreateRequestDto(
11+
NodeType nodeKind,
12+
NodeCategory category,
13+
String situation,
14+
Integer ageYear
15+
) {}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* [DTO-RES] DecisionNode 응답
3+
* - background: AI 생성 설명(옵션)
4+
*/
5+
package com.back.domain.node.dto;
6+
7+
import com.back.domain.node.entity.NodeCategory;
8+
9+
public record DecLineDto(
10+
Long id,
11+
Long userId,
12+
String type, // "DECISION"
13+
NodeCategory category,
14+
String situation,
15+
String decision,
16+
Integer ageYear,
17+
Long decisionLineId,
18+
Long parentId,
19+
Long baseNodeId,
20+
String background
21+
) {
22+
23+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* [DTO-RES] 결정 라인 라이프사이클 상태 응답
3+
* - 취소/완료 후 상태 반환
4+
*/
5+
package com.back.domain.node.dto;
6+
7+
import com.back.domain.node.entity.DecisionLineStatus;
8+
9+
public record DecisionLineLifecycleDto(
10+
Long decisionLineId,
11+
DecisionLineStatus status
12+
) {}

0 commit comments

Comments
 (0)