content: // 1. Read Collection - GET /tasks => 완료
  // 2. Read Item - GET /tasks/{id} => 완료
  // 3. Create - POST /tasks => 완료
  // 4. Update - PUT/PATCH /tasks/{id} => 완료
  // 5. Delete - DELETE /tasks/{id} => 완료
  
  package com.codesoom.demo.controllers;
  
  import com.codesoom.demo.application.TaskService;
  import com.codesoom.demo.models.Task;
  import org.springframework.http.HttpStatus;
  import org.springframework.web.bind.annotation.CrossOrigin;
  import org.springframework.web.bind.annotation.DeleteMapping;
  import org.springframework.web.bind.annotation.GetMapping;
  import org.springframework.web.bind.annotation.PatchMapping;
  import org.springframework.web.bind.annotation.PathVariable;
  import org.springframework.web.bind.annotation.PostMapping;
  import org.springframework.web.bind.annotation.PutMapping;
  import org.springframework.web.bind.annotation.RequestBody;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.ResponseStatus;
  import org.springframework.web.bind.annotation.RestController;
  
  import java.util.List;
  
  @RestController
  @RequestMapping("/tasks")
  @CrossOrigin
  public class TaskController {
      private TaskService taskService;
  
      public TaskController(TaskService taskService) {
          this.taskService = taskService;
      }
  
      @GetMapping
      public List<Task> list() {
          return taskService.getTasks();
      }
  
      @GetMapping("{id}")
      public Task detail(@PathVariable Long id) {
          return taskService.getTask(id);
      }
  
      @PostMapping
      public Task create(@RequestBody Task task) {
          return taskService.createTask(task);
      }
  
      @PutMapping("{id}")
      public Task update(@PathVariable Long id, @RequestBody Task task) {
          return taskService.updateTask(id, task);
      }
  
      @PatchMapping("{id}")
      public Task patch(@PathVariable Long id, @RequestBody Task task) {
          return taskService.updateTask(id, task);
      }
  
      @DeleteMapping("{id}")
      @ResponseStatus(HttpStatus.NO_CONTENT)
      public void delete(@PathVariable Long id) {
          taskService.deleteTask(id);
      }
  }
  