Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.backend.elearning.domain.review.ReviewVM;
import com.backend.elearning.exception.ErrorVm;
import com.backend.elearning.utils.Constants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
Expand Down Expand Up @@ -33,11 +34,13 @@ public UserController(UserService userService, CourseService courseService) {
}

@GetMapping("/admin/users/{id}")
@Operation(method = "GET", summary = "Get information of user by id", description ="Send a request via API with role ADMIN to get information of user" )
public ResponseEntity<UserGetDetailVm> getUser (@PathVariable("id") Long id) {
return ResponseEntity.ok().body(userService.getUser(id));
}

@GetMapping("/users/{id}")
@Operation(method = "GET", summary = "Get information of user by id", description ="Send a request via API to get information of user" )
public ResponseEntity<UserGetDetailVm> getUserProfile (@PathVariable("id") Long id) {
UserGetDetailVm userProfile = userService.getUserProfile(id);
List<CourseListGetVM> courseListGetVMS = courseService.getByUserId(id);
Expand All @@ -46,6 +49,7 @@ public ResponseEntity<UserGetDetailVm> getUserProfile (@PathVariable("id") Long
}

@GetMapping("/admin/users/paging")
@Operation(method = "GET", summary = "Get list information of user by pageNum, pageSize, keyword", description ="Send a request via API to get information of user" )
public ResponseEntity<PageableData<UserVm>> getUser (
@RequestParam(value = "pageNum", defaultValue = Constants.PageableConstant.DEFAULT_PAGE_NUMBER) int pageNum,
@RequestParam(value = "pageSize", defaultValue = Constants.PageableConstant.DEFAULT_PAGE_SIZE) int pageSize,
Expand All @@ -54,7 +58,8 @@ public ResponseEntity<PageableData<UserVm>> getUser (
return ResponseEntity.ok().body(userService.getUsers(pageNum, pageSize, keyword));
}

@PostMapping({"/admin/users"})
@PostMapping("/admin/users")
@Operation(method = "POST", summary = "Save information of user", description ="Send a request via API to save user" )
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "Created", content =
@Content(schema = @Schema(implementation = UserVm.class))),
Expand All @@ -67,6 +72,7 @@ public ResponseEntity<UserVm> create (@Valid @RequestBody UserPostVm userPostVm)
}

@PutMapping("/admin/users/{id}")
@Operation(method = "PUT", summary = "Update information of user by id", description ="Send a request via API to update user" )
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "No content"),
@ApiResponse(responseCode = "404", description = "Not found", content =
Expand All @@ -82,6 +88,7 @@ public ResponseEntity<UserVm> update (@Valid @RequestBody UserPutVm userPostVm,
}

@DeleteMapping("/admin/users/{id}")
@Operation(method = "DELETE", summary = "Delete information of user by id", description ="Send a request via API by ROLE ADMIN to delete user" )
public ResponseEntity<Void> delete (
@PathVariable("id") Long id
) {
Expand All @@ -90,6 +97,7 @@ public ResponseEntity<Void> delete (
}

@PutMapping("/admin/users/{id}/status/{status}")
@Operation(method = "PUT", summary = "Update status of user by id", description ="Send a request via API to update status of user" )
public ResponseEntity<ReviewVM> updateReview(@PathVariable("status") boolean status, @PathVariable("id") Long userId){
userService.updateStatus(status, userId);
return ResponseEntity.noContent().build();
Expand Down
Loading