1
0
mirror of https://github.com/FatttSnake/Pinnacle-OA.git synced 2026-04-05 23:11:24 +08:00

Added api document in UserController

This commit is contained in:
2023-05-21 18:41:10 +08:00
parent 6bbddc128a
commit 39189fd886

View File

@@ -5,6 +5,8 @@ import com.cfive.pinnacle.entity.User;
import com.cfive.pinnacle.entity.common.ResponseCode;
import com.cfive.pinnacle.entity.common.ResponseResult;
import com.cfive.pinnacle.service.IUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.StringUtils;
@@ -22,6 +24,7 @@ import java.util.List;
*/
@RestController
@RequestMapping("/user")
@Tag(name = "用户", description = "用户相关接口")
public class UserController {
private IUserService userService;
@@ -32,6 +35,7 @@ public class UserController {
@GetMapping
@PreAuthorize("hasAnyAuthority('system:user:all', 'system:user:add', 'system:user:modify')")
@Operation(summary = "获取所有用户(权限管理相关)")
public ResponseResult<List<User>> getAllUser() {
List<User> users = userService.getAllUser();
return ResponseResult.databaseSelectSuccess(users);
@@ -39,6 +43,7 @@ public class UserController {
@GetMapping("/{id}")
@PreAuthorize("hasAuthority('system:user:one')")
@Operation(summary = "获取单个用户(权限管理相关)")
public ResponseResult<User> getUser(@PathVariable Long id) {
User user = userService.getUser(id);
return ResponseResult.databaseSelectSuccess(user);
@@ -46,6 +51,7 @@ public class UserController {
@PostMapping
@PreAuthorize("hasAuthority('system:user:add')")
@Operation(summary = "添加用户(权限管理相关)")
public ResponseResult<User> addUser(@RequestBody User user) {
if (!StringUtils.hasText(user.getUsername())) {
return ResponseResult.build(ResponseCode.DATABASE_SAVE_ERROR, "Username cannot be empty", null);
@@ -62,6 +68,7 @@ public class UserController {
@DeleteMapping("/{id}")
@PreAuthorize("hasAuthority('system:user:delete')")
@Operation(summary = "删除用户(权限管理相关)")
public ResponseResult<?> deleteUser(@PathVariable Long id) {
if (id == 1L) {
return ResponseResult.build(ResponseCode.DATABASE_DELETE_ERROR, "Unable to remove super admin", null);
@@ -77,6 +84,7 @@ public class UserController {
@PutMapping()
@PreAuthorize("hasAuthority('system:user:modify')")
@Operation(summary = "修改用户(权限管理相关)")
public ResponseResult<User> modifyUser(@RequestBody User user) {
if (!StringUtils.hasText(user.getUsername())) {
return ResponseResult.build(ResponseCode.DATABASE_UPDATE_ERROR, "Username cannot be empty", null);