99import io .swagger .v3 .oas .annotations .tags .Tag ;
1010import jakarta .validation .Valid ;
1111import lombok .RequiredArgsConstructor ;
12+ import org .springframework .format .annotation .DateTimeFormat ;
1213import org .springframework .http .ResponseEntity ;
1314import org .springframework .security .core .annotation .AuthenticationPrincipal ;
14- import org .springframework .web .bind .annotation .PostMapping ;
15- import org . springframework . web . bind . annotation . RequestBody ;
16- import org . springframework . web . bind . annotation . RequestMapping ;
17- import org . springframework . web . bind . annotation . RestController ;
15+ import org .springframework .web .bind .annotation .* ;
16+
17+ import java . time . LocalDate ;
18+ import java . util . List ;
1819
1920@ RestController
2021@ RequiredArgsConstructor
2324public class TodoController {
2425 private final TodoService todoService ;
2526
27+ // ==================== 생성 ===================
2628 @ PostMapping
2729 @ Operation (summary = "할 일 생성" , description = "새로운 할 일을 생성합니다." )
2830 public ResponseEntity <RsData <TodoResponseDto >> createTodo (
@@ -33,4 +35,32 @@ public ResponseEntity<RsData<TodoResponseDto>> createTodo(
3335 return ResponseEntity .ok (RsData .success ("할 일이 생성되었습니다." , response ));
3436 }
3537
38+ // ==================== 조회 ===================
39+ // 특정 날짜 조회
40+ @ GetMapping
41+ @ Operation (summary = "할 일 목록 조회" , description = "조건에 따라 할 일 목록을 조회합니다. " +
42+ "date만 제공시 해당 날짜, startDate와 endDate 제공시 기간별, 아무것도 없으면 전체 조회" )
43+ public ResponseEntity <RsData <List <TodoResponseDto >>> getTodos (
44+ @ AuthenticationPrincipal CustomUserDetails userDetails ,
45+ @ RequestParam (required = false ) @ DateTimeFormat (iso = DateTimeFormat .ISO .DATE ) LocalDate date
46+ ) {
47+ List <TodoResponseDto > response = todoService .getTodosByDate (userDetails .getUserId (), date );
48+
49+ return ResponseEntity .ok (RsData .success ("할 일 목록을 조회했습니다." , response ));
50+ }
51+
52+ // 사용자의 모든 할 일 조회
53+ @ GetMapping ("/all" )
54+ @ Operation (summary = "모든 할 일 조회" , description = "사용자의 모든 할 일을 조회합니다." )
55+ public ResponseEntity <RsData <List <TodoResponseDto >>> getAllTodos (
56+ @ AuthenticationPrincipal CustomUserDetails userDetails
57+ ) {
58+ List <TodoResponseDto > response = todoService .getAllTodos (userDetails .getUserId ());
59+ return ResponseEntity .ok (RsData .success ("모든 할 일을 조회했습니다." , response ));
60+ }
61+
62+ // ==================== 수정 ===================
63+
64+ // ==================== 삭제 ===================
65+
3666}
0 commit comments