Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
package com.back.domain.node.controller;

import com.back.domain.node.dto.*;
import com.back.domain.node.dto.base.BaseLineBulkCreateRequest;
import com.back.domain.node.dto.base.BaseLineBulkCreateResponse;
import com.back.domain.node.dto.base.BaseNodeDto;
import com.back.domain.node.service.NodeService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
*/
package com.back.domain.node.controller;

import com.back.domain.node.dto.DecLineDto;
import com.back.domain.node.dto.DecisionLineLifecycleDto;
import com.back.domain.node.dto.DecisionNodeFromBaseRequest;
import com.back.domain.node.dto.DecisionNodeNextRequest;
import com.back.domain.node.dto.decision.*;
import com.back.domain.node.service.NodeService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.*;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
Expand All @@ -25,13 +23,13 @@ public class DecisionFlowController {

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

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

Expand All @@ -46,4 +44,10 @@ public ResponseEntity<DecisionLineLifecycleDto> cancel(@PathVariable Long decisi
public ResponseEntity<DecisionLineLifecycleDto> complete(@PathVariable Long decisionLineId) {
return ResponseEntity.ok(nodeService.completeDecisionLine(decisionLineId));
}

// 분기점까지의 라인 복제(포크) 및 새로운 라인 생성
@PostMapping("/fork")
public ResponseEntity<DecNodeDto> fork(@RequestBody ForkFromDecisionRequest request) {
return ResponseEntity.status(HttpStatus.CREATED).body(nodeService.forkFromDecision(request));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/
package com.back.domain.node.controller;

import com.back.domain.node.dto.DecisionLineDetailDto;
import com.back.domain.node.dto.DecisionLineListDto;
import com.back.domain.node.dto.decision.DecisionLineDetailDto;
import com.back.domain.node.dto.decision.DecisionLineListDto;
import com.back.domain.node.service.NodeQueryService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public record PivotDto(
Long baseNodeId,
NodeCategory category,
String situation,
Integer ageYear
Integer ageYear,
String description
) {}
}
5 changes: 4 additions & 1 deletion back/src/main/java/com/back/domain/node/dto/TreeDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
*/
package com.back.domain.node.dto;

import com.back.domain.node.dto.base.BaseNodeDto;
import com.back.domain.node.dto.decision.DecNodeDto;

import java.util.List;

public record TreeDto(
List<BaseNodeDto> baseNodes,
List<DecLineDto> decisionNodes
List<DecNodeDto> decisionNodes
) {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* [DTO-REQ] BaseLine을 라인 단위로 일괄 생성 요청(헤더~꼬리까지)
* - nodes: 0=헤더, 마지막=꼬리, 사이가 피벗(분기점)
*/
package com.back.domain.node.dto;
package com.back.domain.node.dto.base;

import com.back.domain.node.entity.NodeCategory;
import java.util.List;
Expand All @@ -16,6 +16,7 @@ public record BaseNodePayload(
NodeCategory category,
String situation,
String decision,
Integer ageYear
Integer ageYear,
String description
) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* [DTO-RES] BaseLine 일괄 생성 응답
* - 생성된 BaseLine id와 각 노드의 id/인덱스 반환
*/
package com.back.domain.node.dto;
package com.back.domain.node.dto.base;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* [DTO-REQ] BaseNode 단건 생성 요청
* - nodeKind는 BASE 권장
*/
package com.back.domain.node.dto;
package com.back.domain.node.dto.base;

import com.back.domain.node.entity.NodeCategory;
import com.back.domain.node.entity.NodeType;
Expand All @@ -11,5 +11,6 @@ public record BaseNodeCreateRequestDto(
NodeType nodeKind,
NodeCategory category,
String situation,
Integer ageYear
Integer ageYear,
String description
) {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* [DTO-RES] BaseNode 응답
* - 고정 선택과 분기 2칸 및 각 타겟 링크를 포함한다
*/
package com.back.domain.node.dto;
package com.back.domain.node.dto.base;

import com.back.domain.node.entity.NodeCategory;

Expand All @@ -21,5 +21,6 @@ public record BaseNodeDto(
String altOpt1,
String altOpt2,
Long altOpt1TargetDecisionId,
Long altOpt2TargetDecisionId
Long altOpt2TargetDecisionId,
String description
) {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
* [DTO-RES] DecisionNode 응답
* - options/selectedIndex/parentOptionIndex를 포함해 프론트 렌더 정보를 제공한다
*/
package com.back.domain.node.dto;
package com.back.domain.node.dto.decision;

import com.back.domain.node.entity.NodeCategory;
import java.util.List;

public record DecLineDto(
public record DecNodeDto(
Long id,
Long userId,
String type,
Expand All @@ -21,5 +21,6 @@ public record DecLineDto(
String background,
List<String> options,
Integer selectedIndex,
Integer parentOptionIndex
Integer parentOptionIndex,
String description
) {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* [DTO-RES] 결정 라인 상세(라인 메타 + 노드 목록)
* - nodes는 시간축(ageYear asc)으로 정렬
*/
package com.back.domain.node.dto;
package com.back.domain.node.dto.decision;

import com.back.domain.node.entity.DecisionLineStatus;
import java.util.List;
Expand All @@ -12,5 +12,5 @@ public record DecisionLineDetailDto(
Long userId,
Long baseLineId,
DecisionLineStatus status,
List<DecLineDto> nodes
List<DecNodeDto> nodes
) {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* [DTO-RES] 결정 라인 라이프사이클 상태 응답
* - 취소/완료 후 상태 반환
*/
package com.back.domain.node.dto;
package com.back.domain.node.dto.decision;

import com.back.domain.node.entity.DecisionLineStatus;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* [DTO-RES] 결정 라인 목록(요약) 응답
*/
package com.back.domain.node.dto;
package com.back.domain.node.dto.decision;

import com.back.domain.node.entity.DecisionLineStatus;
import java.time.LocalDateTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* [DTO-REQ] DecisionNode 생성 요청
* - 서비스 내부 매퍼용으로 사용되며 외부 API에서는 직접 받지 않는다
*/
package com.back.domain.node.dto;
package com.back.domain.node.dto.decision;

import com.back.domain.node.entity.NodeCategory;
import java.util.List;
Expand All @@ -17,5 +17,6 @@ public record DecisionNodeCreateRequestDto(
Integer ageYear,
List<String> options,
Integer selectedIndex,
Integer parentOptionIndex
Integer parentOptionIndex,
String description
) {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* [DTO-REQ] BaseLine 피벗에서 첫 결정 생성 요청(슬림 계약 + 옵션 지원)
* - 서버가 baseLineId + (pivotOrd | pivotAge)로 피벗 노드를 해석하고, selectedAltIndex(0/1) 분기 슬롯을 링크한다
*/
package com.back.domain.node.dto;
package com.back.domain.node.dto.decision;

import com.back.domain.node.entity.NodeCategory;
import java.util.List;
Expand All @@ -16,5 +16,6 @@ public record DecisionNodeFromBaseRequest(
NodeCategory category, // 미지정 시 pivot.category 상속
String situation, // 미지정 시 pivot.situation 상속
List<String> options, // 1~3개, null 가능(첫 결정 노드도 옵션 보유 가능)
Integer selectedIndex // 0..2, null 가능(주어지면 decision과 일치)
Integer selectedIndex, // 0..2, null 가능(주어지면 decision과 일치)
String description
) {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* [DTO-REQ] 직전 DecisionNode(parent)에서 다음 DecisionNode 생성(슬림 계약)
* - 라인은 부모로부터 해석하고, ageYear 미지정 시 다음 피벗 나이 자동 선택
*/
package com.back.domain.node.dto;
package com.back.domain.node.dto.decision;

import com.back.domain.node.entity.NodeCategory;
import java.util.List;
Expand All @@ -15,5 +15,6 @@ public record DecisionNodeNextRequest(
Integer ageYear, // null이면 다음 피벗 자동 선택
List<String> options, // 1~3개, null 가능
Integer selectedIndex, // 0..2, null 가능
Integer parentOptionIndex // 부모 옵션 인덱스(0..2), null 가능
Integer parentOptionIndex, // 부모 옵션 인덱스(0..2), null 가능
String description
) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* [DTO-REQ] 결정 노드에서 세계선 포크(새 DecisionLine 생성)
* - parentDecisionNodeId: 포크 기준이 되는 기존 결정 노드
* - targetOptionIndex: 이 노드에서 새 라인에 적용할 선택지(0..2)
* - keepUntilParent: true면 부모까지 복제(기본 true) — false면 부모 이전까지만 복제 후 새 노드부터 시작
* - lineTitle: 새 라인에 붙일 식별용 메모(선택)
*/
package com.back.domain.node.dto.decision;

public record ForkFromDecisionRequest(
Long userId,
Long parentDecisionNodeId,
Integer targetOptionIndex,
Boolean keepUntilParent,
String lineTitle
) {}
3 changes: 3 additions & 0 deletions back/src/main/java/com/back/domain/node/entity/BaseNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public class BaseNode extends BaseEntity {

private Long altOpt2TargetDecisionId; // 분기2 연결 대상 결정노드 id

@Column(columnDefinition = "TEXT")
private String description; // 추가 설명

// 헤더 판단 헬퍼
public boolean isHeaderOf(BaseLine baseLine) {
if (baseLine == null) return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public class DecisionNode extends BaseEntity {

private Integer parentOptionIndex; // 부모 결정의 어떤 옵션(0..2)에서 파생됐는지

@Column(columnDefinition = "TEXT")
private String description; // 추가 설명

// 다음 나이 검증
public void guardNextAgeValid(int nextAge) {
if (nextAge <= this.getAgeYear()) {
Expand Down
Loading