Skip to content

Commit e48b295

Browse files
authored
Merge pull request #364 from DDD-Community/bug/363/todo
fix: 기존 루틴 관련 ToDo 삭제 로직 수정 및 ToDo 업데이트 방식 개선 (bug/363/todo)
2 parents ac2873d + 8ce8cc4 commit e48b295

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

app/src/main/java/com/growit/app/todo/domain/service/RoutineServiceImpl.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,7 @@ private ToDoResult updateFromDate(ToDo existingToDo, UpdateToDoCommand command)
205205
}
206206

207207
private ToDoResult updateAllRoutineToDos(ToDo existingToDo, UpdateToDoCommand command) {
208-
deleteOtherRoutineToDos(
209-
existingToDo.getRoutine().getId(), existingToDo.getId(), command.userId());
208+
deleteAllRoutineToDos(existingToDo.getRoutine().getId(), command.userId());
210209

211210
if (command.routine() != null && command.routine().isValid()) {
212211
CreateToDoCommand createCommand =
@@ -219,10 +218,17 @@ private ToDoResult updateAllRoutineToDos(ToDo existingToDo, UpdateToDoCommand co
219218
command.routine());
220219
return createRoutineToDos(createCommand);
221220
} else {
222-
existingToDo.updateBy(command);
223-
existingToDo.removeRoutine();
224-
toDoRepository.saveToDo(existingToDo);
225-
return new ToDoResult(existingToDo.getId());
221+
CreateToDoCommand createCommand =
222+
new CreateToDoCommand(
223+
command.userId(),
224+
command.goalId(),
225+
command.content(),
226+
command.date(),
227+
command.isImportant(),
228+
null);
229+
ToDo newToDo = ToDo.from(createCommand);
230+
toDoRepository.saveToDo(newToDo);
231+
return new ToDoResult(newToDo.getId());
226232
}
227233
}
228234

0 commit comments

Comments
 (0)