refactor: 移除接口单独添加Authorization(已配置全局)

This commit is contained in:
hxr 2024-03-04 00:03:30 +08:00
parent ff4d57c2e9
commit fcf0c3fdc5
3 changed files with 18 additions and 20 deletions

View File

@ -15,7 +15,6 @@ import com.youlai.system.service.SysDictService;
import com.youlai.system.service.SysDictTypeService; import com.youlai.system.service.SysDictTypeService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject; import org.springdoc.core.annotations.ParameterObject;

View File

@ -10,7 +10,6 @@ import com.youlai.system.model.vo.RouteVO;
import com.youlai.system.service.SysMenuService; import com.youlai.system.service.SysMenuService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -36,28 +35,28 @@ public class SysMenuController {
private final SysMenuService menuService; private final SysMenuService menuService;
@Operation(summary = "菜单列表",security = {@SecurityRequirement(name = "Authorization")}) @Operation(summary = "菜单列表")
@GetMapping @GetMapping
public Result<List<MenuVO>> listMenus( @ParameterObject MenuQuery queryParams) { public Result<List<MenuVO>> listMenus( @ParameterObject MenuQuery queryParams) {
List<MenuVO> menuList = menuService.listMenus(queryParams); List<MenuVO> menuList = menuService.listMenus(queryParams);
return Result.success(menuList); return Result.success(menuList);
} }
@Operation(summary = "菜单下拉列表",security = {@SecurityRequirement(name = "Authorization")}) @Operation(summary = "菜单下拉列表")
@GetMapping("/options") @GetMapping("/options")
public Result listMenuOptions() { public Result listMenuOptions() {
List<Option> menus = menuService.listMenuOptions(); List<Option> menus = menuService.listMenuOptions();
return Result.success(menus); return Result.success(menus);
} }
@Operation(summary = "路由列表",security = {@SecurityRequirement(name = "Authorization")}) @Operation(summary = "路由列表")
@GetMapping("/routes") @GetMapping("/routes")
public Result<List<RouteVO>> listRoutes() { public Result<List<RouteVO>> listRoutes() {
List<RouteVO> routeList = menuService.listRoutes(); List<RouteVO> routeList = menuService.listRoutes();
return Result.success(routeList); return Result.success(routeList);
} }
@Operation(summary = "菜单表单数据",security = {@SecurityRequirement(name = "Authorization")}) @Operation(summary = "菜单表单数据")
@GetMapping("/{id}/form") @GetMapping("/{id}/form")
public Result<MenuForm> getMenuForm( public Result<MenuForm> getMenuForm(
@Parameter(description = "菜单ID") @PathVariable Long id @Parameter(description = "菜单ID") @PathVariable Long id
@ -66,7 +65,7 @@ public class SysMenuController {
return Result.success(menu); return Result.success(menu);
} }
@Operation(summary = "新增菜单",security = {@SecurityRequirement(name = "Authorization")}) @Operation(summary = "新增菜单")
@PostMapping @PostMapping
@PreAuthorize("@ss.hasPerm('sys:menu:add')") @PreAuthorize("@ss.hasPerm('sys:menu:add')")
@PreventDuplicateResubmit @PreventDuplicateResubmit
@ -76,7 +75,7 @@ public class SysMenuController {
return Result.judge(result); return Result.judge(result);
} }
@Operation(summary = "修改菜单",security = {@SecurityRequirement(name = "Authorization")}) @Operation(summary = "修改菜单")
@PutMapping(value = "/{id}") @PutMapping(value = "/{id}")
@PreAuthorize("@ss.hasPerm('sys:menu:edit')") @PreAuthorize("@ss.hasPerm('sys:menu:edit')")
@CacheEvict(cacheNames = "menu", key = "'routes'") @CacheEvict(cacheNames = "menu", key = "'routes'")
@ -87,7 +86,7 @@ public class SysMenuController {
return Result.judge(result); return Result.judge(result);
} }
@Operation(summary = "删除菜单",security = {@SecurityRequirement(name = "Authorization")}) @Operation(summary = "删除菜单")
@DeleteMapping("/{id}") @DeleteMapping("/{id}")
@PreAuthorize("@ss.hasPerm('sys:menu:delete')") @PreAuthorize("@ss.hasPerm('sys:menu:delete')")
@CacheEvict(cacheNames = "menu", key = "'routes'") @CacheEvict(cacheNames = "menu", key = "'routes'")
@ -98,7 +97,7 @@ public class SysMenuController {
return Result.judge(result); return Result.judge(result);
} }
@Operation(summary = "修改菜单显示状态",security = {@SecurityRequirement(name = "Authorization")}) @Operation(summary = "修改菜单显示状态")
@PatchMapping("/{menuId}") @PatchMapping("/{menuId}")
public Result updateMenuVisible( public Result updateMenuVisible(
@Parameter(description = "菜单ID") @PathVariable Long menuId, @Parameter(description = "菜单ID") @PathVariable Long menuId,

View File

@ -11,7 +11,7 @@ import com.youlai.system.model.vo.RolePageVO;
import com.youlai.system.service.SysRoleService; import com.youlai.system.service.SysRoleService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -29,7 +29,7 @@ public class SysRoleController {
private final SysRoleService roleService; private final SysRoleService roleService;
@Operation(summary = "角色分页列表",security = {@SecurityRequirement(name = "Authorization")} ) @Operation(summary = "角色分页列表" )
@GetMapping("/page") @GetMapping("/page")
public PageResult<RolePageVO> getRolePage( public PageResult<RolePageVO> getRolePage(
@ParameterObject RolePageQuery queryParams @ParameterObject RolePageQuery queryParams
@ -38,14 +38,14 @@ public class SysRoleController {
return PageResult.success(result); return PageResult.success(result);
} }
@Operation(summary = "角色下拉列表",security = {@SecurityRequirement(name = "Authorization")}) @Operation(summary = "角色下拉列表")
@GetMapping("/options") @GetMapping("/options")
public Result<List<Option>> listRoleOptions() { public Result<List<Option>> listRoleOptions() {
List<Option> list = roleService.listRoleOptions(); List<Option> list = roleService.listRoleOptions();
return Result.success(list); return Result.success(list);
} }
@Operation(summary = "新增角色",security = {@SecurityRequirement(name = "Authorization")}) @Operation(summary = "新增角色")
@PostMapping @PostMapping
@PreAuthorize("@ss.hasPerm('sys:role:add')") @PreAuthorize("@ss.hasPerm('sys:role:add')")
@PreventDuplicateResubmit @PreventDuplicateResubmit
@ -54,7 +54,7 @@ public class SysRoleController {
return Result.judge(result); return Result.judge(result);
} }
@Operation(summary = "角色表单数据",security = {@SecurityRequirement(name = "Authorization")}) @Operation(summary = "角色表单数据")
@GetMapping("/{roleId}/form") @GetMapping("/{roleId}/form")
public Result<RoleForm> getRoleForm( public Result<RoleForm> getRoleForm(
@Parameter(description ="角色ID") @PathVariable Long roleId @Parameter(description ="角色ID") @PathVariable Long roleId
@ -63,7 +63,7 @@ public class SysRoleController {
return Result.success(roleForm); return Result.success(roleForm);
} }
@Operation(summary = "修改角色",security = {@SecurityRequirement(name = "Authorization")}) @Operation(summary = "修改角色")
@PutMapping(value = "/{id}") @PutMapping(value = "/{id}")
@PreAuthorize("@ss.hasPerm('sys:role:edit')") @PreAuthorize("@ss.hasPerm('sys:role:edit')")
public Result updateRole(@Valid @RequestBody RoleForm roleForm) { public Result updateRole(@Valid @RequestBody RoleForm roleForm) {
@ -71,7 +71,7 @@ public class SysRoleController {
return Result.judge(result); return Result.judge(result);
} }
@Operation(summary = "删除角色",security = {@SecurityRequirement(name = "Authorization")}) @Operation(summary = "删除角色")
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
@PreAuthorize("@ss.hasPerm('sys:role:delete')") @PreAuthorize("@ss.hasPerm('sys:role:delete')")
public Result deleteRoles( public Result deleteRoles(
@ -81,7 +81,7 @@ public class SysRoleController {
return Result.judge(result); return Result.judge(result);
} }
@Operation(summary = "修改角色状态",security = {@SecurityRequirement(name = "Authorization")}) @Operation(summary = "修改角色状态")
@PutMapping(value = "/{roleId}/status") @PutMapping(value = "/{roleId}/status")
public Result updateRoleStatus( public Result updateRoleStatus(
@Parameter(description ="角色ID") @PathVariable Long roleId, @Parameter(description ="角色ID") @PathVariable Long roleId,
@ -91,7 +91,7 @@ public class SysRoleController {
return Result.judge(result); return Result.judge(result);
} }
@Operation(summary = "获取角色的菜单ID集合",security = {@SecurityRequirement(name = "Authorization")}) @Operation(summary = "获取角色的菜单ID集合")
@GetMapping("/{roleId}/menuIds") @GetMapping("/{roleId}/menuIds")
public Result<List<Long>> getRoleMenuIds( public Result<List<Long>> getRoleMenuIds(
@Parameter(description ="角色ID") @PathVariable Long roleId @Parameter(description ="角色ID") @PathVariable Long roleId
@ -100,7 +100,7 @@ public class SysRoleController {
return Result.success(menuIds); return Result.success(menuIds);
} }
@Operation(summary = "分配菜单权限给角色",security = {@SecurityRequirement(name = "Authorization")}) @Operation(summary = "分配菜单权限给角色")
@PutMapping("/{roleId}/menus") @PutMapping("/{roleId}/menus")
public Result assignMenusToRole( public Result assignMenusToRole(
@PathVariable Long roleId, @PathVariable Long roleId,