-
Notifications
You must be signed in to change notification settings - Fork 75
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
[Team-16] BE 3번째 PR입니다! #184
base: team-16
Are you sure you want to change the base?
Changes from 1 commit
89273e3
c2caa8f
e817c33
9d48a39
adcd6c1
825f3bf
fb1d3a3
d3f7da8
edd99b0
e17f1bf
1ba223f
2249d49
6fd4420
63fe397
96c65c4
e5fb1d6
2dd6d86
3b895d4
e8aedc3
55f3284
a63360b
14168bc
99be57d
43121bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
/task/status 경로에 patch 요청 시 해당 idx를 가진 Task의 status를 변경하도록 구현. Service 단에서 매개변수의 범위가 올바르지 않을 때는 BAD REQUEST를 리턴하도록 하는 검증 로직(isChangeInfoInvalid) 추가.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
package kr.codesquad.todo.repository; | ||
|
||
import kr.codesquad.todo.domain.Task; | ||
import org.springframework.http.ResponseEntity; | ||
|
||
import java.util.List; | ||
|
||
public interface TaskRepository { | ||
public Task add(Task task); | ||
Task add(Task task); | ||
|
||
List<Task> getAll(); | ||
|
||
Task changeStatus(long idx, int status); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,4 +67,22 @@ public ResponseEntity<Map<Integer, List<Task>>> getAllTasks() { | |
|
||
return ResponseEntity.status(HttpStatus.OK).body(taskMap); | ||
} | ||
|
||
public ResponseEntity<Task> changeTaskStatus(long idx, int status) { | ||
if (isChangeInfoInvalid(idx, status)) { | ||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).build(); | ||
} | ||
Task task; | ||
try { | ||
task = taskRepository.changeStatus(idx, status); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
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 ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); | ||
} | ||
return ResponseEntity.status(HttpStatus.OK).body(task); | ||
} | ||
|
||
public boolean isChangeInfoInvalid(long idx, int status) { | ||
return !(status == 1 || status == 2 || status == 3) || idx < 1; | ||
} | ||
Comment on lines
+85
to
+87
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.
|
||
} |
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.
Map<Integer...
형태로 리스폰스가 넘어가야 하는것이 이해가지 않는 부분이 있긴 합니다.이런 상황을 위한 DTO가 설계되어야 하지 않나 생각이 듭니다.