Skip to content

Commit d2d788c

Browse files
committed
last node & tree print
1 parent 486c8b0 commit d2d788c

21 files changed

+962
-136
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,15 @@ public ResponseEntity<List<BaseLineDto>> getMyBaseLines(
7575
List<BaseLineDto> list = nodeService.getMyBaseLines(me.getId());
7676
return ResponseEntity.ok(list);
7777
}
78+
79+
// 한줄 요약: 소유자 검증 후 베이스라인과 모든 연관 데이터 일괄 삭제
80+
@DeleteMapping("/{baseLineId}")
81+
public ResponseEntity<Void> deleteBaseLine(
82+
@AuthenticationPrincipal CustomUserDetails me,
83+
@PathVariable Long baseLineId
84+
) {
85+
if (me == null) throw new ApiException(ErrorCode.HANDLE_ACCESS_DENIED, "login required");
86+
nodeService.deleteBaseLineDeep(me.getId(), baseLineId); // 가장 많이 사용하는 호출: 파사드에 위임
87+
return ResponseEntity.noContent().build();
88+
}
7889
}

back/src/main/java/com/back/domain/node/dto/decision/DecNodeDto.java

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

88
import com.back.domain.node.entity.FollowPolicy;
99
import com.back.domain.node.entity.NodeCategory;
10-
1110
import java.util.List;
1211

1312
public record DecNodeDto(
@@ -46,11 +45,14 @@ public record DecNodeDto(
4645
Boolean root, // 라인 헤더면 true
4746
Long pivotLinkBaseNodeId, // 베이스 분기 슬롯에서 올라온 첫 노드면 해당 BaseNode id
4847
Integer pivotSlotIndex, // 0/1 (분기 슬롯 인덱스), 아니면 null
48+
Long pivotLinkDecisionNodeId,
4949

5050
// 단일 패스 렌더용 최소 힌트
5151
Integer renderPhase, // 1=from-base 라인, 2..N=fork 깊이(부모 라인 +1)
5252
Long incomingFromId, // 이 노드로 "들어오는" 에지의 from 노드 id(루트면 포크 원본, 아니면 parentId)
53-
String incomingEdgeType // "normal" | "fork"
53+
String incomingEdgeType, // "root","prelude","from-base","fork","normal"
54+
// 포크 원본 라인 id(디버깅/렌더 보조용)
55+
Long incomingFromLineId
5456
) {
5557
// === 호환 오버로드(기존 서비스 호출 유지) ===
5658
public DecNodeDto(
@@ -70,6 +72,6 @@ public DecNodeDto(
7072
followPolicy, pinnedCommitId, virtual, effectiveCategory, effectiveSituation,
7173
effectiveDecision, effectiveOptions, effectiveDescription,
7274
null, null, null, null,
73-
null, null, null); // 새 필드는 null 기본값
75+
null, null, null, null,null); // 새 필드는 null 기본값
7476
}
7577
}

back/src/main/java/com/back/domain/node/entity/DecisionLine.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public class DecisionLine extends BaseEntity {
3434
@Column(nullable = false)
3535
private DecisionLineStatus status;
3636

37+
@Column(name = "parent_line_id")
38+
private Long parentLineId;
39+
3740
@OneToMany(mappedBy = "decisionLine", cascade = CascadeType.ALL, orphanRemoval = true)
3841
private List<DecisionNode> decisionNodes = new ArrayList<>();
3942

back/src/main/java/com/back/domain/node/entity/DecisionNode.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ public class DecisionNode extends BaseEntity {
8282
@JoinColumn(name = "override_version_id")
8383
private NodeAtomVersion overrideVersion;
8484

85+
@Column(name = "ai_next_situation", columnDefinition = "TEXT")
86+
private String aiNextSituation;
87+
88+
@Column(name = "ai_next_recommended_option", columnDefinition = "TEXT")
89+
private String aiNextRecommendedOption;
90+
8591
// 다음 나이 검증
8692
public void guardNextAgeValid(int nextAge) {
8793
if (nextAge <= this.getAgeYear()) {
@@ -94,4 +100,9 @@ public void setOverride(NodeAtomVersion version) {
94100
this.followPolicy = FollowPolicy.OVERRIDE;
95101
this.overrideVersion = version;
96102
}
103+
104+
public void setAiHint(String nextSituation, String nextRecommended) {
105+
this.aiNextSituation = nextSituation;
106+
this.aiNextRecommendedOption = nextRecommended;
107+
}
97108
}

back/src/main/java/com/back/domain/node/mapper/NodeMappers.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ public NodeMappers(VersionResolver resolver,
128128
e.getSelectedIndex(),
129129
e.getParentOptionIndex(),
130130
e.getDescription(),
131-
null,
132-
null,
131+
e.getAiNextSituation(),
132+
e.getAiNextRecommendedOption(),
133133
e.getFollowPolicy(),
134134
pinnedCommitId,
135135
null, // virtual 투영은 상위 레이어에서 주입

back/src/main/java/com/back/domain/node/repository/BaseLineRepository.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,8 @@ public interface BaseLineRepository extends JpaRepository<BaseLine, Long> {
3232
// 사용자별 베이스라인 목록 조회 (페이징 및 N+1 방지)
3333
@Query("SELECT DISTINCT bl FROM BaseLine bl LEFT JOIN FETCH bl.baseNodes bn WHERE bl.user.id = :userId ORDER BY bl.createdDate DESC")
3434
Page<BaseLine> findAllByUserIdWithBaseNodes(@Param("userId") Long userId, Pageable pageable);
35+
36+
boolean existsByIdAndUser_Id(Long baseLineId, Long userId);
37+
38+
void deleteByIdAndUser_Id(Long baseLineId, Long userId);
3539
}

back/src/main/java/com/back/domain/node/repository/BaseNodeRepository.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,6 @@ public interface BaseNodeRepository extends JpaRepository<BaseNode, Long> {
3939
@Query("update BaseNode b set b.altOpt2TargetDecisionId = null " +
4040
"where b.id = :id and b.altOpt2TargetDecisionId = :targetId")
4141
int unlinkAlt2IfMatches(@Param("id") Long id, @Param("targetId") Long targetId);
42+
43+
void deleteByBaseLine_Id(Long baseLineId);
4244
}

back/src/main/java/com/back/domain/node/repository/BaselineBranchRepository.java

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

88
import com.back.domain.node.entity.BaselineBranch;
99
import org.springframework.data.jpa.repository.JpaRepository;
10+
import org.springframework.data.jpa.repository.Modifying;
11+
import org.springframework.data.jpa.repository.Query;
12+
import org.springframework.data.repository.query.Param;
1013
import org.springframework.stereotype.Repository;
1114

1215
import java.util.List;
@@ -20,4 +23,10 @@ public interface BaselineBranchRepository extends JpaRepository<BaselineBranch,
2023

2124
// BaseLine 기준 브랜치 목록 조회
2225
List<BaselineBranch> findByBaseLine_Id(Long baseLineId);
26+
27+
void deleteByBaseLine_Id(Long baseLineId);
28+
29+
@Modifying
30+
@Query("update BaselineBranch b set b.headCommit = null where b.baseLine.id = :baseLineId")
31+
void clearHeadByBaseLineId(@Param("baseLineId") Long baseLineId);
2332
}

back/src/main/java/com/back/domain/node/repository/BaselineCommitRepository.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ public interface BaselineCommitRepository extends JpaRepository<BaselineCommit,
2525
// N+1 방지용: 부모 커밋 즉시 로딩
2626
@EntityGraph(attributePaths = {"parentCommit"})
2727
List<BaselineCommit> findAll();
28+
29+
void deleteByBranch_BaseLine_Id(Long baseLineId);
2830
}

back/src/main/java/com/back/domain/node/repository/BaselinePatchRepository.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ public interface BaselinePatchRepository extends JpaRepository<BaselinePatch, Lo
2121

2222
// 커밋 집합과 ageYear로 필터링하여 최신 우선 정렬
2323
List<BaselinePatch> findByCommit_IdInAndAgeYearOrderByIdDesc(Collection<Long> commitIds, Integer ageYear);
24+
25+
void deleteByCommit_Branch_BaseLine_Id(Long baseLineId);
2426
}

0 commit comments

Comments
 (0)