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