content: package com.taskmanager.taskmanager.web;
  
  import java.util.List;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.http.HttpStatus;
  import org.springframework.http.ResponseEntity;
  import org.springframework.web.bind.annotation.CrossOrigin;
  import org.springframework.web.bind.annotation.DeleteMapping;
  import org.springframework.web.bind.annotation.PostMapping;
  import org.springframework.web.bind.annotation.RequestBody;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RestController;
  
  import com.taskmanager.taskmanager.entity.User;
  import com.taskmanager.taskmanager.service.UserService;
  
  import jakarta.validation.Valid;
  import lombok.AllArgsConstructor;
  import org.springframework.web.bind.annotation.GetMapping;
  import org.springframework.web.bind.annotation.PathVariable;
  import org.springframework.web.bind.annotation.PutMapping;
  
  
  
  @CrossOrigin(origins = "http://localhost:5173")
  @AllArgsConstructor
  @RestController
  @RequestMapping("/user")
  public class UserController {
      
      @Autowired
      UserService userService;
  
      @GetMapping("/all")
      public ResponseEntity<List<User>> getAllUsers() {
          return new ResponseEntity<>(userService.getAllUsers(), HttpStatus.OK);
      }
  
      @GetMapping("/{userId}")
      public ResponseEntity<User> getTask(@PathVariable Long userId) {
          return new ResponseEntity<>(userService.getUser(userId), HttpStatus.OK);
      }
  
      @PostMapping
      public ResponseEntity<User> addTask(@Valid @RequestBody User user) {
          return new ResponseEntity<>(userService.saveUser(user), HttpStatus.OK);
      }
  
      @PutMapping("/{userId}")
      public ResponseEntity<User> updateUser(@PathVariable Long userId, @RequestBody @Valid User user) {
          return new ResponseEntity<>(userService.updateUser(userId, user), HttpStatus.OK);
      }
  
      @DeleteMapping("/{userId}")
      public ResponseEntity<HttpStatus> deleteTask(@PathVariable Long userId) {
          userService.deleteUser(userId);
          return new ResponseEntity<>(HttpStatus.NO_CONTENT);
      }
  }
  