Skip to content
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

[202002578 한석진] Level8-9 미션 제출합니다 #40

Open
wants to merge 1 commit into
base: level9-initial
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/main/java/backend/likelion/todos/todo/TodoController.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.time.YearMonth;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.apache.coyote.Response;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -29,7 +30,9 @@ public ResponseEntity<Void> create(
@RequestBody TodoCreateRequest request
) {
// TODO [9단계] TodoCreateRequest에서 goalId, content, date를 추출하여 todoService의 save 메소드를 호출하고, 생성된 Todo의 ID로 URI를 생성하여 ResponseEntity를 반환하세요.
return null;
Long saveId = todoService.save(request.goalId(), memberId, request.content(), request.date());
return ResponseEntity.created(URI.create("/todos/" + saveId)).build();

}

@PostMapping("/{id}/check")
Expand All @@ -38,6 +41,7 @@ public void check(
@PathVariable("id") Long todoId
) {
// TODO [9단계] todoId와 memberId를 todoService의 check 메소드에 전달하여 Todo를 완료 상태로 변경하세요.
todoService.check(todoId, memberId);
}

@PostMapping("/{id}/uncheck")
Expand All @@ -46,6 +50,7 @@ public void uncheck(
@PathVariable("id") Long todoId
) {
// TODO [9단계] todoId와 memberId를 todoService의 uncheck 메소드에 전달하여 Todo를 미완료 상태로 변경하세요.
todoService.uncheck(todoId, memberId);
}

@PutMapping("/{id}")
Expand All @@ -55,6 +60,7 @@ public void update(
@RequestBody TodoUpdateRequest request
) {
// TODO [9단계] TodoUpdateRequest에서 content, date를 추출하고, todoId와 memberId를 함께 todoService의 update 메소드에 전달하여 Todo 정보를 업데이트하세요.
todoService.update(todoId, memberId, request.content(), request.date());
}

@DeleteMapping("/{id}")
Expand All @@ -63,6 +69,7 @@ public void delete(
@PathVariable("id") Long todoId
) {
// TODO [9단계] todoId와 memberId를 todoService의 delete 메소드에 전달하여 Todo를 삭제하세요.
todoService.delete(todoId, memberId);
}

@GetMapping("/my")
Expand All @@ -72,6 +79,8 @@ public ResponseEntity<List<TodoWithDayResponse>> findMine(
@RequestParam(value = "month", required = true) int month
) {
// TODO [9단계] memberId와 YearMonth.of(year, month)를 todoService의 findAllByMemberIdAndDate 메소드에 전달하여 해당 기간의 모든 Todo를 조회하고, 조회된 정보를 ResponseEntity.ok()에 담아 반환하세요.
return null;
List<TodoWithDayResponse> result = todoService.findAllByMemberIdAndDate(memberId,
YearMonth.of(year, month));
return ResponseEntity.ok(result);
}
}