mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-05 23:11:24 +08:00
Refactored ResponseResult, added api documentation for PowerController, RoleController, GroupController and UserController
This commit is contained in:
@@ -5,7 +5,13 @@ import com.cfive.pinnacle.entity.Group;
|
||||
import com.cfive.pinnacle.entity.common.ResponseCode;
|
||||
import com.cfive.pinnacle.entity.common.ResponseResult;
|
||||
import com.cfive.pinnacle.service.IGroupService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
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;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -21,6 +27,7 @@ import java.util.List;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/group")
|
||||
@Tag(name = "用户组", description = "用户组相关接口")
|
||||
public class GroupController {
|
||||
private IGroupService groupService;
|
||||
|
||||
@@ -29,14 +36,18 @@ public class GroupController {
|
||||
this.groupService = groupService;
|
||||
}
|
||||
|
||||
@Operation(summary = "获取所有用户组")
|
||||
@GetMapping
|
||||
public ResponseResult getAllGroup() {
|
||||
@PreAuthorize("hasAnyAuthority('system:group:all', 'system:group:add', 'system:group:delete', 'system:group:modify', 'system:user:add', 'system:user:modify')")
|
||||
public ResponseResult<List<Group>> getAllGroup() {
|
||||
List<Group> groups = groupService.getAllGroup();
|
||||
return ResponseResult.databaseSelectSuccess(groups);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加用户组")
|
||||
@PostMapping
|
||||
public ResponseResult addGroup(@RequestBody Group group) {
|
||||
@PreAuthorize("hasAuthority('system:group:add')")
|
||||
public ResponseResult<Group> addGroup(@RequestBody Group group) {
|
||||
if (!StringUtils.hasText(group.getName())) {
|
||||
return ResponseResult.build(ResponseCode.DATABASE_SAVE_ERROR, "Name cannot be empty", null);
|
||||
}
|
||||
@@ -47,8 +58,13 @@ public class GroupController {
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "删除用户组")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "用户组ID", in = ParameterIn.PATH)
|
||||
})
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseResult deleteGroup(@PathVariable Long id) {
|
||||
@PreAuthorize("hasAuthority('system:group:delete')")
|
||||
public ResponseResult<?> deleteGroup(@PathVariable Long id) {
|
||||
LambdaQueryWrapper<Group> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(Group::getId, id);
|
||||
if (groupService.remove(wrapper)) {
|
||||
@@ -58,8 +74,10 @@ public class GroupController {
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "修改用户组")
|
||||
@PutMapping
|
||||
public ResponseResult modifyGroup(@RequestBody Group group) {
|
||||
@PreAuthorize("hasAuthority('system:group:modify')")
|
||||
public ResponseResult<Group> modifyGroup(@RequestBody Group group) {
|
||||
if (!StringUtils.hasText(group.getName())) {
|
||||
return ResponseResult.build(ResponseCode.DATABASE_UPDATE_ERROR, "Name cannot be empty", null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user