//package com.itsol.quantrivanphong.employee.controller;
//
//import com.example.easynotes.exception.ResourceNotFoundException;
//import com.example.easynotes.login.model.User;
//import com.example.easynotes.users.bussiness.UserBussiness;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.*;
//
//import javax.validation.Valid;
//import java.util.List;
//
//@RestController
//@RequestMapping("/api")
//public class UserController {
//
//    @Autowired
//    private UserBussiness userBussiness;
//
//    @GetMapping("/users")
//    public List<User> getAllUser(){ return userBussiness.findAll();}
//
//    @GetMapping("/users/{id}")
//    public User getUserById(@PathVariable(value = "id") Long userId){
//        return userBussiness.findById(userId).orElseThrow(()-> new ResourceNotFoundException("News", "id", userId));
//    }
//
//    @PutMapping("/users/{id}")
//    public ResponseEntity<User> updateUser(@PathVariable(value = "id") Long userId,
//                                           @Valid @RequestBody User userDetails) {
//        if (!userBussiness.findById(userId).isPresent()) {
//            throw  new ResourceNotFoundException("User", "id", userId);
//        }
//        return ResponseEntity.ok(userBussiness.updateUser(userId,userDetails));
//    }
//}
