Class UserController
java.lang.Object
org.example.crmedu.application.controller.UserController
REST controller for managing users. Provides endpoints to create, retrieve, update and delete users.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity
<CreateUserResponse> createUser
(@Valid CreateUserRequest request) Creates a new user based on the provided request data.org.springframework.http.ResponseEntity
<Void> deleteUser
(Long id) Deletes a user by its unique identifier.org.springframework.http.ResponseEntity
<GetUserResponse> Retrieves a user by its unique identifier.org.springframework.http.ResponseEntity
<PageDTO<GetUserResponse>> getUsers
(org.springframework.data.domain.Pageable pageable) Retrieves a paginates list of users.org.springframework.http.ResponseEntity
<Void> updateUser
(@Valid UpdateUserRequest request, Long id) Updates an existing user by its unique identifier.
-
Constructor Details
-
UserController
public UserController()
-
-
Method Details
-
getUsers
@GetMapping @Secured({"SUPERUSER","ORG_ADMIN"}) public org.springframework.http.ResponseEntity<PageDTO<GetUserResponse>> getUsers(org.springframework.data.domain.Pageable pageable) Retrieves a paginates list of users.- Parameters:
pageable
- an object specifying pagination parameters (page number and size)- Returns:
- a
ResponseEntity
containing a paginated list of users wrapped inPageDTO
ofGetUserResponse
-
getUser
@GetMapping("/{id}") @Secured({"SUPERUSER","ORG_ADMIN"}) public org.springframework.http.ResponseEntity<GetUserResponse> getUser(@PathVariable Long id) Retrieves a user by its unique identifier.- Parameters:
id
- the unique identifier of the user- Returns:
- a
ResponseEntity
containing the subject data inGetUserResponse
-
createUser
@PostMapping @Secured({"SUPERUSER","ORG_ADMIN"}) public org.springframework.http.ResponseEntity<CreateUserResponse> createUser(@Valid @RequestBody @Valid CreateUserRequest request) Creates a new user based on the provided request data.- Parameters:
request
- an object containing the user details- Returns:
- a
ResponseEntity
with the created subject data inCreateUserResponse
-
updateUser
@PutMapping("/{id}") @Secured({"SUPERUSER","ORG_ADMIN"}) public org.springframework.http.ResponseEntity<Void> updateUser(@Valid @RequestBody @Valid UpdateUserRequest request, @PathVariable Long id) Updates an existing user by its unique identifier.- Parameters:
request
- an object containing the updated user detailsid
- the unique identifier of the user to update- Returns:
- a
ResponseEntity
-
deleteUser
@DeleteMapping("/{id}") @Secured({"SUPERUSER","ORG_ADMIN"}) public org.springframework.http.ResponseEntity<Void> deleteUser(@PathVariable Long id) Deletes a user by its unique identifier.- Parameters:
id
- the unique identifier of the user to delete- Returns:
- a
ResponseEntity
-