added GET /user/{id}
This commit is contained in:
parent
7a23dcc96a
commit
2fb6aef67c
@ -40,6 +40,16 @@ public class UserController {
|
|||||||
return new ResponseEntity<>(ProtectionService.userWithoutPassword(user), HttpStatus.OK);
|
return new ResponseEntity<>(ProtectionService.userWithoutPassword(user), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/user/{id}")
|
||||||
|
public ResponseEntity<HashMap<String ,Object>> getUserById(@RequestHeader("Authorization") String token, @PathVariable Long id){
|
||||||
|
|
||||||
|
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.InscriptionService},token))
|
||||||
|
return new UnauthorizedResponse<>(null);
|
||||||
|
|
||||||
|
return new ResponseEntity<>(ProtectionService.userWithoutPassword(userService.getUserById(id)), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/user")
|
@PostMapping("/user")
|
||||||
public ResponseEntity<Map<String ,Object>> postUser(@RequestBody User user,@RequestHeader("Authorization") String token){
|
public ResponseEntity<Map<String ,Object>> postUser(@RequestBody User user,@RequestHeader("Authorization") String token){
|
||||||
|
|
||||||
|
@ -122,4 +122,8 @@ public class UserService {
|
|||||||
public Iterable<User> getAllTeachers (){return userRepo.findAllTeachers();}
|
public Iterable<User> getAllTeachers (){return userRepo.findAllTeachers();}
|
||||||
|
|
||||||
public Iterable<User> getAllStudents(){return userRepo.findAllStudents();}
|
public Iterable<User> getAllStudents(){return userRepo.findAllStudents();}
|
||||||
|
|
||||||
|
public User getUserById(long id) {
|
||||||
|
return userRepo.findById(id);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user