Skip to content

Commit 0b6a84c

Browse files
committed
fix(goal): plans 업데이트 제거
1 parent 99c78d7 commit 0b6a84c

File tree

2 files changed

+0
-52
lines changed

2 files changed

+0
-52
lines changed

app/src/main/java/com/growit/app/goal/domain/goal/Goal.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,9 @@ public void updateByCommand(UpdateGoalCommand command) {
6262
this.duration = command.duration();
6363
this.toBe = command.toBe();
6464
this.category = command.category();
65-
this.plans = updatePlans(command);
6665
}
6766

6867
public boolean checkProgress(GoalStatus status) {
69-
7068
if (status == GoalStatus.NONE) {
7169
return true;
7270
} else if (status == GoalStatus.PROGRESS) {
@@ -80,31 +78,6 @@ public void updateByGoalUpdateStatus(GoalUpdateStatus updateStatus) {
8078
this.updateStatus = updateStatus;
8179
}
8280

83-
// 기존 존재하는 범위의 계획인 경우 업데이트 존재하지 않은경우 새로 생성
84-
// 1. 기존 plans duration 을 키로 map 구성
85-
// 2. command.plans loop
86-
// 3. duration 구하기
87-
// 4. duration 키로 존재 여부 체크
88-
// 5. 존재하면 업데이트 존재하지 않으면 새로 생성
89-
private List<Plan> updatePlans(UpdateGoalCommand command) {
90-
Map<PlanDuration, Plan> existingPlanMap =
91-
this.plans.stream().collect(toMap(Plan::getPlanDuration, plan -> plan));
92-
List<Plan> updatedPlans = new ArrayList<>();
93-
for (var planDto : command.plans()) {
94-
PlanDuration planDuration =
95-
PlanDuration.calculateDuration(planDto.weekOfMonth(), command.duration().startDate());
96-
Plan existing = existingPlanMap.get(planDuration);
97-
if (existing != null) {
98-
existing.updateByPlan(planDto, planDuration);
99-
updatedPlans.add(existing);
100-
} else {
101-
updatedPlans.add(Plan.from(planDto, command.duration().startDate()));
102-
}
103-
}
104-
105-
return updatedPlans;
106-
}
107-
10881
public void deleted() {
10982
this.isDelete = true;
11083
}

app/src/main/java/com/growit/app/goal/infrastructure/persistence/goal/source/entity/GoalEntity.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -66,31 +66,6 @@ public void updateToByDomain(Goal goal) {
6666
this.toBe = goal.getToBe();
6767
this.category = goal.getCategory();
6868
this.updateStatus = goal.getUpdateStatus();
69-
// 다르면 insert
70-
Map<String, PlanEntity> existingPlanMap =
71-
this.plans.stream().collect(toMap(PlanEntity::getUid, plan -> plan));
72-
73-
List<PlanEntity> updatedPlans =
74-
goal.getPlans().stream()
75-
.map(
76-
plan -> {
77-
PlanEntity existing = existingPlanMap.get(plan.getId());
78-
if (existing != null) {
79-
existing.updateByDomain(plan);
80-
return existing;
81-
} else {
82-
return new PlanEntity(
83-
plan.getId(),
84-
plan.getWeekOfMonth(),
85-
plan.getContent(),
86-
plan.getPlanDuration().startDate(),
87-
plan.getPlanDuration().endDate(),
88-
this);
89-
}
90-
})
91-
.toList();
92-
this.plans.clear();
93-
this.plans.addAll(updatedPlans);
9469
if (goal.getDeleted()) setDeletedAt(LocalDateTime.now());
9570
}
9671
}

0 commit comments

Comments
 (0)