-
Notifications
You must be signed in to change notification settings - Fork 0
[feat] #71 - 하위 태스크 완료/미완료 #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d8fd31a
a64656c
78cbd74
d144711
9c483cc
be3ba02
8a0ec85
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.Timo.Timo.domain.todo.dto.request; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
|
||
| import jakarta.validation.constraints.NotNull; | ||
|
|
||
| public record SubtaskStatusUpdateRequest( | ||
| @NotNull | ||
| @JsonProperty("isCompleted") | ||
| Boolean isCompleted | ||
| ) { } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.Timo.Timo.domain.todo.dto.response; | ||
|
|
||
| import com.Timo.Timo.domain.todo.entity.Subtask; | ||
|
|
||
| public record SubtaskStatusChangeResponse( | ||
| Long subtaskId, | ||
| Boolean completed | ||
| ) { | ||
| public static SubtaskStatusChangeResponse from(Subtask subtask) { | ||
| return new SubtaskStatusChangeResponse( | ||
| subtask.getId(), | ||
| subtask.isCompleted() | ||
| ); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,15 +12,18 @@ | |
| import com.Timo.Timo.domain.tag.exception.TagErrorCode; | ||
| import com.Timo.Timo.domain.tag.repository.TagRepository; | ||
| import com.Timo.Timo.domain.timer.service.TimerService; | ||
| import com.Timo.Timo.domain.todo.dto.request.SubtaskStatusUpdateRequest; | ||
| import com.Timo.Timo.domain.todo.dto.request.TodoCreateRequest; | ||
| import com.Timo.Timo.domain.todo.dto.request.TodoReorderRequest; | ||
| import com.Timo.Timo.domain.todo.dto.request.TodoStatusUpdateRequest; | ||
| import com.Timo.Timo.domain.todo.dto.request.TodoSubtaskUpdateRequest; | ||
| import com.Timo.Timo.domain.todo.dto.request.TodoUpdateRequest; | ||
| import com.Timo.Timo.domain.todo.dto.response.SubtaskStatusChangeResponse; | ||
| import com.Timo.Timo.domain.todo.dto.response.TodoCreateResponse; | ||
| import com.Timo.Timo.domain.todo.dto.response.TodoDetailResponse; | ||
| import com.Timo.Timo.domain.todo.dto.response.TodoReorderResponse; | ||
| import com.Timo.Timo.domain.todo.dto.response.TodoStatusChangeResponse; | ||
| import com.Timo.Timo.domain.todo.entity.Subtask; | ||
| import com.Timo.Timo.domain.todo.entity.Todo; | ||
| import com.Timo.Timo.domain.todo.entity.TodoInstance; | ||
| import com.Timo.Timo.domain.todo.enums.RepeatType; | ||
|
|
@@ -106,10 +109,6 @@ public TodoDetailResponse getTodoDetail(Long userId, Long todoId, String dateVal | |
|
|
||
| @Transactional | ||
| public TodoStatusChangeResponse changeCompletion(Long userId, Long todoId, TodoStatusUpdateRequest request) { | ||
| if (request.isCompleted() == null) { | ||
| throw new CustomException(TodoErrorCode.IS_COMPLETED_REQUIRED); | ||
| } | ||
|
|
||
| Todo todo = todoRepository.findByIdAndUser_Id(todoId, userId) | ||
| .orElseThrow(() -> new CustomException(TodoErrorCode.TODO_NOT_FOUND)); | ||
|
|
||
|
|
@@ -126,6 +125,21 @@ public TodoStatusChangeResponse changeCompletion(Long userId, Long todoId, TodoS | |
| return TodoStatusChangeResponse.from(todoId, instance); | ||
| } | ||
|
|
||
| @Transactional | ||
| public SubtaskStatusChangeResponse changeSubtaskCompletion( | ||
| Long userId, Long todoId, Long subtaskId, SubtaskStatusUpdateRequest request) { | ||
| Todo todo = todoRepository.findByIdAndUser_Id(todoId, userId) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 소유한 TODO를 먼저 조회한 뒤 그 안에서 하위 태스크를 찾는 흐름이라 권한 확인과 소속 검증이 같이 처리되네용 짱짱쓴 |
||
| .orElseThrow(() -> new CustomException(TodoErrorCode.TODO_NOT_FOUND)); | ||
|
|
||
| Subtask subtask = todo.getSubtasks().stream() | ||
| .filter(it -> it.getId().equals(subtaskId)) | ||
| .findFirst() | ||
| .orElseThrow(() -> new CustomException(TodoErrorCode.SUBTASK_NOT_FOUND)); | ||
|
|
||
| subtask.updateCompleted(request.isCompleted()); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. p3) 현재 Subtask 엔티티의 completed 값을 직접 변경하고 있어서, daily TODO의 오늘 하위 태스크를 완료하면 다른 날짜에서도 같은 하위 태스크가 완료 상태로 보일 수 있을 것 같아요. 하위 태스크 완료 상태도 날짜별로 관리되어야 하지 않을까용
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 입코리해드렸습니다 |
||
| return SubtaskStatusChangeResponse.from(subtask); | ||
| } | ||
|
|
||
| @Transactional | ||
| public TodoReorderResponse reorderTodo(Long userId, Long todoId, TodoReorderRequest request) { | ||
| Todo todo = todoRepository.findByIdAndUser_Id(todoId, userId) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NotNull,@Valid를 사용하면 컨트롤러 진입 전에 걸러질 수 있을 것 같은데 Service 레이어에서isCompleted가 null인 경우를 체크하는 이유가 따로 있을까용