mirror of
https://github.com/suyiiyii/SIMS.git
synced 2025-07-17 20:43:00 +08:00
docs(user): 添加用户接口的描述
This commit is contained in:
parent
55d2072fa0
commit
c484bdcf69
@ -1,13 +1,11 @@
|
|||||||
package top.suyiiyii.sims.controller;
|
package top.suyiiyii.sims.controller;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpSession;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.session.Session;
|
|
||||||
import org.springframework.session.SessionRepository;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import top.suyiiyii.sims.common.AuthAccess;
|
import top.suyiiyii.sims.common.AuthAccess;
|
||||||
import top.suyiiyii.sims.common.Result;
|
import top.suyiiyii.sims.common.Result;
|
||||||
@ -39,8 +37,6 @@ public class UserController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
RoleService roleService;
|
RoleService roleService;
|
||||||
|
|
||||||
private SessionRepository sessionRepository;
|
|
||||||
|
|
||||||
|
|
||||||
@AuthAccess
|
@AuthAccess
|
||||||
@GetMapping("/")
|
@GetMapping("/")
|
||||||
@ -63,7 +59,7 @@ public class UserController {
|
|||||||
return Result.error("用户名或密码错误");
|
return Result.error("用户名或密码错误");
|
||||||
}
|
}
|
||||||
LoginResponse response = new LoginResponse();
|
LoginResponse response = new LoginResponse();
|
||||||
response.setToken(token);
|
response.setToken(token);
|
||||||
return Result.success(response);
|
return Result.success(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,6 +84,7 @@ public class UserController {
|
|||||||
return Result.success(CommonResponse.factory("注册成功"));
|
return Result.success(CommonResponse.factory("注册成功"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(description = "删除单个用户")
|
||||||
@DeleteMapping("/admin/user/{id}")
|
@DeleteMapping("/admin/user/{id}")
|
||||||
public Result<CommonResponse> adminDelete(@PathVariable Integer id) {
|
public Result<CommonResponse> adminDelete(@PathVariable Integer id) {
|
||||||
log.info("delete request:{}", id);
|
log.info("delete request:{}", id);
|
||||||
@ -95,18 +92,28 @@ public class UserController {
|
|||||||
return Result.success(CommonResponse.factory("删除成功"));
|
return Result.success(CommonResponse.factory("删除成功"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(description = "获取所有用户信息")
|
||||||
@GetMapping("/admin/user")
|
@GetMapping("/admin/user")
|
||||||
public Result<List<UserDto>> adminGetById() {
|
public Result<List<UserDto>> adminGet() {
|
||||||
List<UserDto> allUsers = userService.findAllUsers();
|
List<UserDto> allUsers = userService.findAllUsers();
|
||||||
return Result.success(allUsers);
|
return Result.success(allUsers);
|
||||||
}
|
}
|
||||||
@GetMapping("/user/{id}")
|
|
||||||
public Result<UserDto> GetById(@PathVariable Integer id) {
|
@Operation(description = "根据 id 获取用户信息")
|
||||||
|
@GetMapping("/admin/user/{id}")
|
||||||
|
public Result<UserDto> adminGetById(@PathVariable Integer id) {
|
||||||
log.info("selectById request:{}", id);
|
log.info("selectById request:{}", id);
|
||||||
UserDto user = userService.findUser(id);
|
UserDto user = userService.findUser(id);
|
||||||
return Result.success(user);
|
return Result.success(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(description = "获取当前用户信息")
|
||||||
|
@GetMapping("/user/me")
|
||||||
|
public Result<UserDto> getSelf() {
|
||||||
|
UserDto user = userService.findUser(0);
|
||||||
|
return Result.success(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class RegisterRequest {
|
public static class RegisterRequest {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user