Repository navigation
[feat] #223 - 하위 태스크 날짜별 순서 변경 API #231
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
Open
laura-jung
wants to merge
12
commits into
develop
Choose a base branch
from
feat/#223-subtask-reorder
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+454
−54
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
49157c9
feat: 하위 태스크를 기본 순서로 정렬하고 TODO 수정 시 순서를 유지
laura-jung e539971
feat: 하위 태스크 날짜별 순서 저장 컬럼과 정렬 기준 추가
laura-jung 20e579a
feat: TODO 상세·홈 조회에 날짜별 하위 태스크 순서 반영
laura-jung be401b0
feat: 하위 태스크 날짜별 순서 재정렬 로직 추가
laura-jung ea9727a
feat: 하위 태스크 순서 변경 API 추가
laura-jung 483b7e3
docs: TODO 수정 API의 하위 태스크 순서 처리 설명 수정
laura-jung fb86531
fix: 하위 태스크 순서 변경 시 검증 전에 레코드를 저장하지 않도록 수정
laura-jung 5c93700
fix: 같은 날짜의 하위 태스크 요청을 인스턴스 잠금으로 순차 처리
laura-jung 5509b17
feat: 하위 태스크 완료 시 TODO와 같은 규칙으로 순서 이동
laura-jung 84cf397
fix: 하위 태스크 완료 레코드를 잠금 조회로 읽어 최신 값 기준으로 처리
laura-jung 98a19f8
refactor: SubtaskStates 내부 컬렉션을 불변으로 보관
laura-jung 9bf0ede
refactor: 하위 태스크 수정 시 null 필터를 Objects::nonNull로 변경
laura-jung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/main/java/com/Timo/Timo/domain/todo/dto/request/SubtaskReorderRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.Timo.Timo.domain.todo.dto.request; | ||
|
|
||
| import java.time.LocalDate; | ||
|
|
||
| public record SubtaskReorderRequest( | ||
| Integer newIndex, | ||
|
|
||
| LocalDate date | ||
| ) { } | ||
20 changes: 20 additions & 0 deletions
20
src/main/java/com/Timo/Timo/domain/todo/dto/response/SubtaskReorderResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package com.Timo.Timo.domain.todo.dto.response; | ||
|
|
||
| import com.Timo.Timo.domain.todo.entity.SubtaskCompletion; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
|
|
||
| public record SubtaskReorderResponse( | ||
| @Schema(requiredMode = Schema.RequiredMode.REQUIRED) | ||
| Long subtaskId, | ||
| @Schema(requiredMode = Schema.RequiredMode.REQUIRED) | ||
| Integer sortOrder | ||
| ) { | ||
|
|
||
| public static SubtaskReorderResponse from(SubtaskCompletion completion) { | ||
| return new SubtaskReorderResponse( | ||
| completion.getSubtask().getId(), | ||
| completion.getSortOrder() | ||
| ); | ||
| } | ||
| } |
14 changes: 13 additions & 1 deletion
14
src/main/java/com/Timo/Timo/domain/todo/dto/response/SubtaskStatusChangeResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,23 @@ | ||
| package com.Timo.Timo.domain.todo.dto.response; | ||
|
|
||
| import com.Timo.Timo.domain.todo.entity.SubtaskCompletion; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
|
|
||
| public record SubtaskStatusChangeResponse( | ||
| @Schema(requiredMode = Schema.RequiredMode.REQUIRED) | ||
| Long subtaskId, | ||
| @Schema(requiredMode = Schema.RequiredMode.REQUIRED) | ||
| Boolean completed | ||
| Boolean completed, | ||
| @Schema(requiredMode = Schema.RequiredMode.REQUIRED) | ||
| Integer sortOrder | ||
| ) { | ||
|
|
||
| public static SubtaskStatusChangeResponse from(SubtaskCompletion completion) { | ||
| return new SubtaskStatusChangeResponse( | ||
| completion.getSubtask().getId(), | ||
| completion.isCompleted(), | ||
| completion.getSortOrder() | ||
| ); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
P4)
newIndex가 null/음수여도 DTO에서는 통과해서,SubtaskRedorderer에서 완료 레코드를 먼저 INSERT 한 뒤INVALID_INDEX로 롤백되는 것으로 이해했습니다. 잘못된 요청에 불필요한 INSERT가 나가게 되어서@NotNull @Min(0)을 붙여서 DTO에서 먼저 400으로 막는 방법을 고려해봐도 좋을 것 같습니다! 근데 이 부분은TodoReorderRequest에서도 같은 구조로 쓰이고 있는 것 같기는 합니다..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.
말씀해주신 것처럼 검증 전에 INSERT가 나가고 있었습니다! DTO에
@NotNull @Min(0)을 붙이면 이 컨트롤러에서는TodoExceptionHandler가 "필수 필드가 누락되었거나 형식이 올바르지 않습니다." 메시지로 응답해서 같은 인덱스 오류의 메시지가 둘로 나뉘고, 상한(미완료 개수 이상)은 DTO에서 검사할 수 없어서 다른 방법으로 해결했습니다.새 레코드는 메모리에서만 준비하고, 인덱스 검증을 통과한 뒤에
saveAll()로 저장하도록 순서를 바꿨습니다. 잘못된 요청에는 INSERT가 나가지 않고, 에러 응답은 기존과 같은TODO_400입니다. (fb86531)