| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package com.nju.edu.gitlab.controller;
- import com.nju.edu.gitlab.service.api.UserService;
- import com.nju.edu.gitlab.dto.ChangePasswordDTO;
- import com.nju.edu.gitlab.dto.GitlabUserDTO;
- import com.nju.edu.gitlab.web.response.ResourceResponse;
- import com.nju.edu.gitlab.web.response.Response;
- import org.gitlab4j.api.GitLabApiException;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- @RestController
- @RequestMapping("/api/user")
- public class GitlabUserController {
- private final UserService userService;
- @Autowired
- public GitlabUserController(UserService userService) {
- this.userService = userService;
- }
- @PostMapping("/")
- public Response createGitlabUser(@RequestBody GitlabUserDTO gitlabUserDTO) throws GitLabApiException {
- return new ResourceResponse(userService.createGitlabUser(gitlabUserDTO));
- }
- @PostMapping("/changePassword")
- public Response changePassword(@RequestBody ChangePasswordDTO changePasswordDTO) throws GitLabApiException {
- return new ResourceResponse(userService.changePassword(changePasswordDTO));
- }
- @DeleteMapping("/{userId}")
- public Response deleteUser(@PathVariable(name = "userId") Integer userId) throws GitLabApiException {
- return new ResourceResponse(userService.deleteUser(userId));
- }
- @GetMapping("/{userId}/email")
- public Response getUserEmail(@PathVariable(name = "userId") Integer userId) throws GitLabApiException {
- return new ResourceResponse(userService.getUserEmail(userId));
- }
- }
|