feat: 在控制器中加入权限标识
This commit is contained in:
parent
ef5accd5e0
commit
a4211463ca
|
@ -1,11 +1,10 @@
|
|||
package cn.bunny.services.aop;
|
||||
package cn.bunny.services.aop.scanner;
|
||||
|
||||
import cn.bunny.domain.vo.result.ResultCodeEnum;
|
||||
import cn.bunny.services.exception.AuthCustomerException;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
|
||||
import org.springframework.core.type.filter.AnnotationTypeFilter;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.HashSet;
|
||||
|
@ -13,12 +12,22 @@ import java.util.Set;
|
|||
|
||||
/**
|
||||
* 扫描指定目录下所有类
|
||||
* 传入要扫描的注解类,反射拿到类信息
|
||||
*/
|
||||
@Component
|
||||
public class AnnotationScanner {
|
||||
|
||||
// 要扫描哪个包下面的注解
|
||||
private static final String basePackage = "cn.bunny.services";
|
||||
|
||||
/**
|
||||
* 传入注解,之后反射拿到对应的类
|
||||
* 相关使用示例点击引用查看
|
||||
*
|
||||
* @param annotation 要扫描的注解
|
||||
* @return 类
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Set<Class<?>> getClassesWithAnnotation(Class<?> annotation) {
|
||||
public static Set<Class<?>> getClassesWithAnnotation(Class<?> annotation) {
|
||||
// 设置是否延迟初始化
|
||||
ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false);
|
||||
// 只需要带有 Annotation 注解类的内容
|
||||
|
@ -28,7 +37,7 @@ public class AnnotationScanner {
|
|||
Set<Class<?>> classes = new HashSet<>();
|
||||
|
||||
// 只要 cn.bunny.services 包下面的全部内容
|
||||
for (BeanDefinition bd : scanner.findCandidateComponents("cn.bunny.services")) {
|
||||
for (BeanDefinition bd : scanner.findCandidateComponents(basePackage)) {
|
||||
try {
|
||||
// 通过反射加载类,并将类名转换为 Class 对象
|
||||
Class<?> clazz = Class.forName(bd.getBeanClassName());
|
|
@ -0,0 +1,34 @@
|
|||
package cn.bunny.services.aop.scanner.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 控制器信息类
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Schema(name = "ControllerInfo", title = "控制器信息类", description = "控制器信息类")
|
||||
public class ControllerInfo {
|
||||
|
||||
@Schema(name = "tagName", title = "标签")
|
||||
private String tagName;
|
||||
|
||||
@Schema(name = "tagDescription", title = "标签详情")
|
||||
private String tagDescription;
|
||||
|
||||
@Schema(name = "basePath", title = "基础请求路径,RequestMapping中的")
|
||||
private String basePath;
|
||||
|
||||
@Schema(name = "methods", title = "控制器啊中所有方法")
|
||||
private List<MethodInfo> methods;
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package cn.bunny.services.aop.scanner.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Schema(name = "MethodInfo", title = "方法信息类", description = "控制器中方法信息类")
|
||||
public class MethodInfo {
|
||||
|
||||
@Schema(name = "path", title = "方法中的路径")
|
||||
private String path;
|
||||
|
||||
@Schema(name = "httpMethod", title = "请求方法/方式")
|
||||
private String httpMethod;
|
||||
|
||||
@Schema(name = "summary", title = "请求方法简介")
|
||||
private String summary;
|
||||
|
||||
@Schema(name = "description", title = "请求方法详情")
|
||||
private String description;
|
||||
|
||||
@Schema(name = "tags", title = "标签列")
|
||||
private List<String> tags;
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package cn.bunny.services.aop.scanner.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Schema(name = "MenuIconVo对象", title = "系统菜单图标", description = "系统菜单图标")
|
||||
public class ScannerControllerInfoVo {
|
||||
|
||||
@Schema(name = "httpMethod", title = "标签")
|
||||
private String httpMethod;
|
||||
|
||||
@Schema(name = "path", title = "路径")
|
||||
private String path;
|
||||
|
||||
@Schema(name = "summary", title = "简介")
|
||||
private String summary;
|
||||
|
||||
@Schema(name = "description", title = "详情")
|
||||
private String description;
|
||||
|
||||
@Schema(name = "powerCodes", title = "权限码")
|
||||
private List<String> powerCodes;
|
||||
|
||||
@Schema(name = "description", title = "标签")
|
||||
private List<ScannerControllerInfoVo> children;
|
||||
|
||||
}
|
|
@ -0,0 +1,137 @@
|
|||
package cn.bunny.services.aop.scanner.controller.utils;
|
||||
|
||||
import cn.bunny.services.aop.scanner.AnnotationScanner;
|
||||
import cn.bunny.services.aop.scanner.controller.ControllerInfo;
|
||||
import cn.bunny.services.aop.scanner.controller.MethodInfo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 控制器扫描工具类
|
||||
*/
|
||||
public class ControllerScannerUtil {
|
||||
|
||||
/**
|
||||
* 获取所有带有@Tag注解的控制器类信息
|
||||
*
|
||||
* @return 包含控制器类信息和接口方法的列表
|
||||
*/
|
||||
public static List<ControllerInfo> scanControllerInfo() {
|
||||
Set<Class<?>> controllerClasses = AnnotationScanner.getClassesWithAnnotation(RestController.class);
|
||||
List<ControllerInfo> controllerInfos = new ArrayList<>();
|
||||
|
||||
for (Class<?> clazz : controllerClasses) {
|
||||
ControllerInfo controllerInfo = new ControllerInfo();
|
||||
|
||||
// 获取类上的Tag注解
|
||||
Tag tag = clazz.getAnnotation(Tag.class);
|
||||
if (tag != null) {
|
||||
controllerInfo.setTagName(tag.name());
|
||||
controllerInfo.setTagDescription(tag.description());
|
||||
}
|
||||
|
||||
// 获取类上的RequestMapping注解
|
||||
RequestMapping requestMapping = clazz.getAnnotation(RequestMapping.class);
|
||||
if (requestMapping != null && requestMapping.value().length > 0) {
|
||||
controllerInfo.setBasePath(requestMapping.value()[0]);
|
||||
}
|
||||
|
||||
// 获取方法上的注解信息
|
||||
List<MethodInfo> methodInfos = new ArrayList<>();
|
||||
for (Method method : clazz.getDeclaredMethods()) {
|
||||
MethodInfo methodInfo = new MethodInfo();
|
||||
|
||||
// 获取Operation注解
|
||||
Operation operation = method.getAnnotation(Operation.class);
|
||||
if (operation != null) {
|
||||
methodInfo.setSummary(operation.summary());
|
||||
methodInfo.setDescription(operation.description());
|
||||
methodInfo.setTags(Arrays.stream(operation.tags()).toList());
|
||||
}
|
||||
|
||||
// 获取请求路径和方法的组合路径
|
||||
String methodPath = getMethodPath(method);
|
||||
if (methodPath != null) {
|
||||
methodInfo.setPath(methodPath);
|
||||
}
|
||||
|
||||
// 获取请求方法类型
|
||||
String httpMethod = getHttpMethod(method);
|
||||
if (httpMethod != null) {
|
||||
methodInfo.setHttpMethod(httpMethod);
|
||||
}
|
||||
|
||||
if (operation != null || methodPath != null) {
|
||||
methodInfos.add(methodInfo);
|
||||
}
|
||||
}
|
||||
|
||||
controllerInfo.setMethods(methodInfos);
|
||||
controllerInfos.add(controllerInfo);
|
||||
}
|
||||
|
||||
return controllerInfos;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取HTTP方法类型
|
||||
*/
|
||||
private static String getHttpMethod(Method method) {
|
||||
if (method.getAnnotation(GetMapping.class) != null) return "GET";
|
||||
if (method.getAnnotation(PostMapping.class) != null) return "POST";
|
||||
if (method.getAnnotation(PutMapping.class) != null) return "PUT";
|
||||
if (method.getAnnotation(DeleteMapping.class) != null) return "DELETE";
|
||||
if (method.getAnnotation(PatchMapping.class) != null) return "PATCH";
|
||||
|
||||
RequestMapping requestMapping = method.getAnnotation(RequestMapping.class);
|
||||
if (requestMapping != null && requestMapping.method().length > 0) {
|
||||
return requestMapping.method()[0].name();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取方法上的路径注解值
|
||||
*/
|
||||
private static String getMethodPath(Method method) {
|
||||
// 检查所有可能的路径注解
|
||||
GetMapping getMapping = method.getAnnotation(GetMapping.class);
|
||||
if (getMapping != null && getMapping.value().length > 0) {
|
||||
return getMapping.value()[0];
|
||||
}
|
||||
|
||||
PostMapping postMapping = method.getAnnotation(PostMapping.class);
|
||||
if (postMapping != null && postMapping.value().length > 0) {
|
||||
return postMapping.value()[0];
|
||||
}
|
||||
|
||||
PutMapping putMapping = method.getAnnotation(PutMapping.class);
|
||||
if (putMapping != null && putMapping.value().length > 0) {
|
||||
return putMapping.value()[0];
|
||||
}
|
||||
|
||||
DeleteMapping deleteMapping = method.getAnnotation(DeleteMapping.class);
|
||||
if (deleteMapping != null && deleteMapping.value().length > 0) {
|
||||
return deleteMapping.value()[0];
|
||||
}
|
||||
|
||||
PatchMapping patchMapping = method.getAnnotation(PatchMapping.class);
|
||||
if (patchMapping != null && patchMapping.value().length > 0) {
|
||||
return patchMapping.value()[0];
|
||||
}
|
||||
|
||||
RequestMapping requestMapping = method.getAnnotation(RequestMapping.class);
|
||||
if (requestMapping != null && requestMapping.value().length > 0) {
|
||||
return requestMapping.value()[0];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
public class IndexController {
|
||||
|
||||
@Operation(summary = "访问首页", description = "访问首页")
|
||||
@GetMapping("/readme")
|
||||
@GetMapping("/index")
|
||||
public String index() {
|
||||
return "index";
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public class ConfigurationController {
|
|||
return configurationService.webConfig();
|
||||
}
|
||||
|
||||
@Operation(summary = "更新web配置文件", description = "更新web配置文件,重启应用失效")
|
||||
@Operation(summary = "更新web配置文件", description = "更新web配置文件,重启应用失效", tags = "config::update")
|
||||
@PutMapping()
|
||||
public Result<Object> updateWebConfiguration(@Valid @RequestBody WebConfigurationDto dto) {
|
||||
configurationService.updateWebConfiguration(dto);
|
||||
|
|
|
@ -36,7 +36,7 @@ public class EmailTemplateController {
|
|||
@Resource
|
||||
private EmailTemplateService emailTemplateService;
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页查询邮件模板")
|
||||
@Operation(summary = "分页查询", description = "分页查询邮件模板", tags = "emailTemplate::query")
|
||||
@GetMapping("{page}/{limit}")
|
||||
public Result<PageResult<EmailTemplateVo>> getEmailTemplatePage(
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
|
@ -49,28 +49,28 @@ public class EmailTemplateController {
|
|||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加", description = "添加邮件模板")
|
||||
@Operation(summary = "添加", description = "添加邮件模板", tags = "emailTemplate::add")
|
||||
@PostMapping()
|
||||
public Result<String> addEmailTemplate(@Valid @RequestBody EmailTemplateAddDto dto) {
|
||||
emailTemplateService.addEmailTemplate(dto);
|
||||
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新", description = "更新邮件模板")
|
||||
@Operation(summary = "更新", description = "更新邮件模板", tags = "emailTemplate::update")
|
||||
@PutMapping()
|
||||
public Result<String> updateEmailTemplate(@Valid @RequestBody EmailTemplateUpdateDto dto) {
|
||||
emailTemplateService.updateEmailTemplate(dto);
|
||||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除", description = "删除邮件模板")
|
||||
@Operation(summary = "删除", description = "删除邮件模板", tags = "emailTemplate::delete")
|
||||
@DeleteMapping()
|
||||
public Result<String> deleteEmailTemplate(@RequestBody List<Long> ids) {
|
||||
emailTemplateService.deleteEmailTemplate(ids);
|
||||
return Result.success(ResultCodeEnum.DELETE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "全部邮件类型列表", description = "获取全部邮件类型列表")
|
||||
@Operation(summary = "全部邮件类型列表", description = "获取全部邮件类型列表", tags = "emailTemplate::query")
|
||||
@GetMapping("public")
|
||||
public Result<List<Map<String, String>>> getEmailTypeList() {
|
||||
List<Map<String, String>> list = emailTemplateService.getEmailTypeList();
|
||||
|
|
|
@ -36,7 +36,7 @@ public class EmailUsersController {
|
|||
@Resource
|
||||
private EmailUsersService emailUsersService;
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页查询邮箱用户发送配置")
|
||||
@Operation(summary = "分页查询", description = "分页查询邮箱用户发送配置", tags = "emailUsers::query")
|
||||
@GetMapping("{page}/{limit}")
|
||||
public Result<PageResult<EmailUsersVo>> getEmailUserPage(
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
|
@ -49,28 +49,28 @@ public class EmailUsersController {
|
|||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加", description = "添加邮箱用户发送配置")
|
||||
@Operation(summary = "添加", description = "添加邮箱用户发送配置", tags = "emailUsers::add")
|
||||
@PostMapping()
|
||||
public Result<String> addEmailUsers(@Valid @RequestBody EmailUsersAddDto dto) {
|
||||
emailUsersService.addEmailUsers(dto);
|
||||
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新", description = "更新邮箱用户发送配置")
|
||||
@Operation(summary = "更新", description = "更新邮箱用户发送配置", tags = "emailUsers::update")
|
||||
@PutMapping()
|
||||
public Result<String> updateEmailUsers(@Valid @RequestBody EmailUsersUpdateDto dto) {
|
||||
emailUsersService.updateEmailUsers(dto);
|
||||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除", description = "删除邮箱用户")
|
||||
@Operation(summary = "删除", description = "删除邮箱用户", tags = "emailUsers::delete")
|
||||
@DeleteMapping()
|
||||
public Result<String> deleteEmailUsers(@RequestBody List<Long> ids) {
|
||||
emailUsersService.deleteEmailUsers(ids);
|
||||
return Result.success(ResultCodeEnum.DELETE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "全部邮件用户配置", description = "获取全部邮件用户配置")
|
||||
@Operation(summary = "全部邮件用户配置", description = "获取全部邮件用户配置", tags = "emailUsers::query")
|
||||
@GetMapping("private")
|
||||
public Result<List<Map<String, String>>> getEmailUserList() {
|
||||
List<Map<String, String>> list = emailUsersService.getAllMailboxConfigurationUsers();
|
||||
|
|
|
@ -38,7 +38,7 @@ public class I18nController {
|
|||
@Resource
|
||||
private I18nService i18nService;
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页查询多语言")
|
||||
@Operation(summary = "分页查询", description = "分页查询多语言", tags = "i18n::query")
|
||||
@GetMapping("{page}/{limit}")
|
||||
public Result<PageResult<I18nVo>> getI18nPage(
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
|
@ -51,41 +51,41 @@ public class I18nController {
|
|||
return Result.success(vo);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新", description = "更新多语言")
|
||||
@Operation(summary = "更新", description = "更新多语言", tags = "i18n::update")
|
||||
@PutMapping()
|
||||
public Result<String> updateI18n(@Valid @RequestBody I18nUpdateDto dto) {
|
||||
i18nService.updateI18n(dto);
|
||||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加", description = "添加多语言")
|
||||
@Operation(summary = "添加", description = "添加多语言", tags = "i18n::add")
|
||||
@PostMapping()
|
||||
public Result<String> addI18n(@Valid @RequestBody I18nAddDto dto) {
|
||||
i18nService.addI18n(dto);
|
||||
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除", description = "删除多语言")
|
||||
@Operation(summary = "删除", description = "删除多语言", tags = "i18n::delete")
|
||||
@DeleteMapping()
|
||||
public Result<String> deleteI18n(@RequestBody List<Long> ids) {
|
||||
i18nService.deleteI18n(ids);
|
||||
return Result.success(ResultCodeEnum.DELETE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取多语言内容", description = "获取多语言内容")
|
||||
@Operation(summary = "获取多语言内容", description = "获取多语言内容", tags = "i18n::query")
|
||||
@GetMapping("public")
|
||||
public Result<Map<String, Object>> getI18nMap() {
|
||||
Map<String, Object> vo = i18nService.getI18nMap();
|
||||
return Result.success(vo);
|
||||
}
|
||||
|
||||
@Operation(summary = "文件导出多语言", description = "文件导出并下载多语言")
|
||||
@Operation(summary = "文件导出多语言", description = "文件导出并下载多语言", tags = "i18n::update")
|
||||
@GetMapping("file")
|
||||
public ResponseEntity<byte[]> downloadI18n(String type) {
|
||||
return i18nService.downloadI18n(type);
|
||||
}
|
||||
|
||||
@Operation(summary = "文件导入多语言", description = "文件更新多语言可以是JSON、Excel")
|
||||
@Operation(summary = "文件导入多语言", description = "文件更新多语言可以是JSON、Excel", tags = "i18n::update")
|
||||
@PutMapping("file")
|
||||
public Result<String> uploadI18nFile(@Valid I18nUpdateByFileDto dto) {
|
||||
i18nService.uploadI18nFile(dto);
|
||||
|
|
|
@ -31,28 +31,28 @@ public class I18nTypeController {
|
|||
@Resource
|
||||
private I18nTypeService i18nTypeService;
|
||||
|
||||
@Operation(summary = "添加", description = "添加多语言类型")
|
||||
@Operation(summary = "添加", description = "添加多语言类型", tags = "i18nType::query")
|
||||
@PostMapping()
|
||||
public Result<String> addI18nType(@Valid @RequestBody I18nTypeAddDto dto) {
|
||||
i18nTypeService.addI18nType(dto);
|
||||
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新", description = "更新多语言类型")
|
||||
@Operation(summary = "更新", description = "更新多语言类型", tags = "i18nType::update")
|
||||
@PutMapping()
|
||||
public Result<String> updateI18nType(@Valid @RequestBody I18nTypeUpdateDto dto) {
|
||||
i18nTypeService.updateI18nType(dto);
|
||||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除", description = "删除多语言类型")
|
||||
@Operation(summary = "删除", description = "删除多语言类型", tags = "i18nType::delete")
|
||||
@DeleteMapping()
|
||||
public Result<String> deleteI18nType(@RequestBody List<Long> ids) {
|
||||
i18nTypeService.deleteI18nType(ids);
|
||||
return Result.success(ResultCodeEnum.DELETE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "全部多语言类型列表", description = "获取全部多语言类型列表")
|
||||
@Operation(summary = "全部多语言类型列表", description = "获取全部多语言类型列表", tags = "i18nType::query")
|
||||
@GetMapping("/public")
|
||||
public Result<List<I18nTypeVo>> getI18nTypeList(I18nTypeDto dto) {
|
||||
List<I18nTypeVo> voList = i18nTypeService.getI18nTypeList(dto);
|
||||
|
|
|
@ -35,7 +35,7 @@ public class MenuIconController {
|
|||
@Resource
|
||||
private MenuIconService menuIconService;
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页查询系统菜单图标")
|
||||
@Operation(summary = "分页查询", description = "分页查询系统菜单图标", tags = "menuIcon::query")
|
||||
@GetMapping("{page}/{limit}")
|
||||
public Result<PageResult<MenuIconVo>> getMenuIconPage(
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
|
@ -48,28 +48,28 @@ public class MenuIconController {
|
|||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加", description = "添加系统菜单图标")
|
||||
@Operation(summary = "添加", description = "添加系统菜单图标", tags = "menuIcon::add")
|
||||
@PostMapping()
|
||||
public Result<String> addMenuIcon(@Valid @RequestBody MenuIconAddDto dto) {
|
||||
menuIconService.addMenuIcon(dto);
|
||||
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新", description = "更新系统菜单图标")
|
||||
@Operation(summary = "更新", description = "更新系统菜单图标", tags = "menuIcon::update")
|
||||
@PutMapping()
|
||||
public Result<String> updateMenuIcon(@Valid @RequestBody MenuIconUpdateDto dto) {
|
||||
menuIconService.updateMenuIcon(dto);
|
||||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除", description = "删除系统菜单图标")
|
||||
@Operation(summary = "删除", description = "删除系统菜单图标", tags = "menuIcon::delete")
|
||||
@DeleteMapping()
|
||||
public Result<String> deleteMenuIcon(@RequestBody List<Long> ids) {
|
||||
menuIconService.deleteMenuIcon(ids);
|
||||
return Result.success(ResultCodeEnum.DELETE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "搜索图标", description = "根据名称搜索图标")
|
||||
@Operation(summary = "搜索图标", description = "根据名称搜索图标", tags = "menuIcon::query")
|
||||
@GetMapping("public")
|
||||
public Result<List<MenuIconVo>> getIconNameListByIconName(String iconName) {
|
||||
List<MenuIconVo> voList = menuIconService.getIconNameListByIconName(iconName);
|
||||
|
|
|
@ -32,7 +32,7 @@ public class ScheduleExecuteLogController {
|
|||
@Resource
|
||||
private ScheduleExecuteLogService scheduleExecuteLogService;
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页查询调度任务执行日志")
|
||||
@Operation(summary = "分页查询", description = "分页查询调度任务执行日志", tags = "scheduleExecuteLog::query")
|
||||
@GetMapping("{page}/{limit}")
|
||||
public Result<PageResult<ScheduleExecuteLogVo>> getScheduleExecuteLogPage(
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
|
@ -45,7 +45,7 @@ public class ScheduleExecuteLogController {
|
|||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除", description = "删除调度任务执行日志")
|
||||
@Operation(summary = "删除", description = "删除调度任务执行日志", tags = "scheduleExecuteLog::delete")
|
||||
@DeleteMapping()
|
||||
public Result<String> deleteScheduleExecuteLog(@RequestBody List<Long> ids) {
|
||||
scheduleExecuteLogService.deleteScheduleExecuteLog(ids);
|
||||
|
|
|
@ -33,7 +33,7 @@ public class UserLoginLogController {
|
|||
@Resource
|
||||
private UserLoginLogService userLoginLogService;
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页查询用户登录日志")
|
||||
@Operation(summary = "分页查询", description = "分页查询用户登录日志", tags = "userLoginLog::query")
|
||||
@GetMapping("{page}/{limit}")
|
||||
public Result<PageResult<UserLoginLogVo>> getUserLoginLogPage(
|
||||
@Parameter(name = "page", description = "当前页", required = true) @PathVariable("page") Integer page,
|
||||
|
@ -44,14 +44,14 @@ public class UserLoginLogController {
|
|||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除", description = "删除用户登录日志")
|
||||
@Operation(summary = "删除", description = "删除用户登录日志", tags = "userLoginLog::delete")
|
||||
@DeleteMapping()
|
||||
public Result<Object> deleteUserLoginLog(@RequestBody List<Long> ids) {
|
||||
userLoginLogService.deleteUserLoginLog(ids);
|
||||
return Result.success(ResultCodeEnum.DELETE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询本地用户登录日志", description = "分页查询本地用户登录日志")
|
||||
@Operation(summary = "分页查询本地用户登录日志", description = "分页查询本地用户登录日志", tags = "userLoginLog::query")
|
||||
@GetMapping("private/{page}/{limit}")
|
||||
public Result<PageResult<UserLoginLogLocalVo>> getUserLoginLogPageByUser(
|
||||
@Parameter(name = "page", description = "当前页", required = true) @PathVariable("page") Integer page,
|
||||
|
|
|
@ -37,7 +37,7 @@ public class MessageController {
|
|||
@Resource
|
||||
private MessageService messageService;
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页查询发送消息")
|
||||
@Operation(summary = "分页查询", description = "分页查询发送消息", tags = "message::query")
|
||||
@GetMapping("{page}/{limit}")
|
||||
public Result<PageResult<MessageVo>> getMessagePage(
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
|
@ -50,35 +50,35 @@ public class MessageController {
|
|||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加", description = "添加系统消息")
|
||||
@Operation(summary = "添加", description = "添加系统消息", tags = "message::add")
|
||||
@PostMapping()
|
||||
public Result<String> addMessage(@Valid @RequestBody MessageAddDto dto) {
|
||||
messageService.addMessage(dto);
|
||||
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新", description = "更新系统消息")
|
||||
@Operation(summary = "更新", description = "更新系统消息", tags = "message::update")
|
||||
@PutMapping()
|
||||
public Result<String> updateMessage(@Valid @RequestBody MessageUpdateDto dto) {
|
||||
messageService.updateMessage(dto);
|
||||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除", description = "删除系统消息")
|
||||
@Operation(summary = "删除", description = "删除系统消息", tags = "message::delete")
|
||||
@DeleteMapping()
|
||||
public Result<String> deleteMessage(@RequestBody List<Long> ids) {
|
||||
messageService.deleteMessage(ids);
|
||||
return Result.success(ResultCodeEnum.DELETE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据消息id查询消息详情", description = "根据消息id查询消息详情")
|
||||
@Operation(summary = "根据消息id查询消息详情", description = "根据消息id查询消息详情", tags = "message::query")
|
||||
@GetMapping("private/getMessageDetailById")
|
||||
public Result<MessageDetailVo> getMessageDetailById(Long id) {
|
||||
MessageDetailVo vo = messageService.getMessageDetailById(id);
|
||||
return Result.success(vo);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据消息id获取接收人信息", description = "根据消息id获取接收人信息")
|
||||
@Operation(summary = "根据消息id获取接收人信息", description = "根据消息id获取接收人信息", tags = "message::query")
|
||||
@GetMapping("private/getReceivedUserinfoByMessageId")
|
||||
public Result<List<MessageReceivedWithUserVo>> getReceivedUserinfoByMessageId(Long messageId) {
|
||||
List<MessageReceivedWithUserVo> voList = messageService.getReceivedUserinfoByMessageId(messageId);
|
||||
|
|
|
@ -36,7 +36,7 @@ public class MessageReceivedController {
|
|||
@Resource
|
||||
private MessageReceivedService messageReceivedService;
|
||||
|
||||
@Operation(summary = "分页查询", description = "管理员分页查询用户消息")
|
||||
@Operation(summary = "分页查询", description = "管理员分页查询用户消息", tags = "messageReceived::query")
|
||||
@GetMapping("{page}/{limit}")
|
||||
public Result<PageResult<MessageReceivedWithMessageVo>> getMessageReceivedPage(
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
|
@ -49,21 +49,21 @@ public class MessageReceivedController {
|
|||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新", description = "管理员将用户消息标为已读")
|
||||
@Operation(summary = "更新", description = "管理员将用户消息标为已读", tags = "messageReceived::update")
|
||||
@PutMapping()
|
||||
public Result<String> updateMarkMessageReceived(@Valid @RequestBody MessageReceivedUpdateDto dto) {
|
||||
messageReceivedService.updateMarkMessageReceived(dto);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "删除", description = "管理删除用户消息")
|
||||
@Operation(summary = "删除", description = "管理删除用户消息", tags = "messageReceived::delete")
|
||||
@DeleteMapping()
|
||||
public Result<String> deleteMessageReceived(@RequestBody List<Long> ids) {
|
||||
messageReceivedService.deleteMessageReceived(ids);
|
||||
return Result.success(ResultCodeEnum.DELETE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询用户消息", description = "分页查询用户消息")
|
||||
@Operation(summary = "分页查询用户消息", description = "分页查询用户消息", tags = "messageReceived::query")
|
||||
@GetMapping("private/{page}/{limit}")
|
||||
public Result<PageResult<MessageUserVo>> getMessagePageByUser(
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
|
@ -76,14 +76,14 @@ public class MessageReceivedController {
|
|||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "用户将消息标为已读", description = "用户将消息标为已读")
|
||||
@Operation(summary = "用户将消息标为已读", description = "用户将消息标为已读", tags = "messageReceived::update")
|
||||
@PutMapping("private/markAsRead")
|
||||
public Result<String> markAsReadByUser(@Valid @RequestBody List<Long> ids) {
|
||||
messageReceivedService.markAsReadByUser(ids);
|
||||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "用户删除消息", description = "用户删除消息")
|
||||
@Operation(summary = "用户删除消息", description = "用户删除消息", tags = "messageReceived::delete")
|
||||
@DeleteMapping("private/deleteMessage")
|
||||
public Result<String> deleteMessageByUser(@RequestBody List<Long> ids) {
|
||||
messageReceivedService.deleteMessageByUser(ids);
|
||||
|
|
|
@ -35,7 +35,7 @@ public class MessageTypeController {
|
|||
@Resource
|
||||
private MessageTypeService messageTypeService;
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页查询系统消息类型")
|
||||
@Operation(summary = "分页查询", description = "分页查询系统消息类型", tags = "messageType::query")
|
||||
@GetMapping("{page}/{limit}")
|
||||
public Result<PageResult<MessageTypeVo>> getMessageTypePage(
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
|
@ -48,28 +48,28 @@ public class MessageTypeController {
|
|||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加", description = "添加系统消息类型")
|
||||
@Operation(summary = "添加", description = "添加系统消息类型", tags = "messageType::add")
|
||||
@PostMapping()
|
||||
public Result<String> addMessageType(@Valid @RequestBody MessageTypeAddDto dto) {
|
||||
messageTypeService.addMessageType(dto);
|
||||
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新", description = "更新系统消息类型")
|
||||
@Operation(summary = "更新", description = "更新系统消息类型", tags = "messageType::update")
|
||||
@PutMapping()
|
||||
public Result<String> updateMessageType(@Valid @RequestBody MessageTypeUpdateDto dto) {
|
||||
messageTypeService.updateMessageType(dto);
|
||||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除", description = "删除系统消息类型")
|
||||
@Operation(summary = "删除", description = "删除系统消息类型", tags = "messageType::delete")
|
||||
@DeleteMapping()
|
||||
public Result<String> deleteMessageType(@RequestBody List<Long> ids) {
|
||||
messageTypeService.deleteMessageType(ids);
|
||||
return Result.success(ResultCodeEnum.DELETE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "所有消息列表", description = "获取所有消息列表")
|
||||
@Operation(summary = "所有消息列表", description = "获取所有消息列表", tags = "messageType::query")
|
||||
@GetMapping("private/getMessageList")
|
||||
public Result<List<MessageTypeVo>> getMessageList() {
|
||||
List<MessageTypeVo> voList = messageTypeService.getMessageList();
|
||||
|
|
|
@ -36,7 +36,7 @@ public class SchedulersController {
|
|||
@Resource
|
||||
private SchedulersService schedulersService;
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页查询任务执行")
|
||||
@Operation(summary = "分页查询", description = "分页查询任务执行", tags = "schedulers::query")
|
||||
@GetMapping("{page}/{limit}")
|
||||
public Result<PageResult<SchedulersVo>> getSchedulersPage(
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
|
@ -49,42 +49,42 @@ public class SchedulersController {
|
|||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加", description = "添加任务")
|
||||
@Operation(summary = "添加", description = "添加任务", tags = "schedulers::add")
|
||||
@PostMapping()
|
||||
public Result<Object> addSchedulers(@Valid @RequestBody SchedulersAddDto dto) {
|
||||
schedulersService.addSchedulers(dto);
|
||||
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新", description = "更新任务")
|
||||
@Operation(summary = "更新", description = "更新任务", tags = "schedulers::update")
|
||||
@PutMapping()
|
||||
public Result<String> updateSchedulers(@Valid @RequestBody SchedulersUpdateDto dto) {
|
||||
schedulersService.updateSchedulers(dto);
|
||||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "暂停任务", description = "暂停任务")
|
||||
@Operation(summary = "暂停任务", description = "暂停任务", tags = "schedulers::update")
|
||||
@PutMapping("pause")
|
||||
public Result<String> pause(@RequestBody SchedulersUpdateDto dto) {
|
||||
schedulersService.pauseScheduler(dto);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "恢复任务", description = "恢复任务")
|
||||
@Operation(summary = "恢复任务", description = "恢复任务", tags = "schedulers::update")
|
||||
@PutMapping("resume")
|
||||
public Result<String> resume(@RequestBody SchedulersUpdateDto dto) {
|
||||
schedulersService.resumeScheduler(dto);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "删除", description = "删除任务")
|
||||
@Operation(summary = "删除", description = "删除任务", tags = "schedulers::delete")
|
||||
@DeleteMapping()
|
||||
public Result<String> deleteSchedulers(@RequestBody SchedulersUpdateDto dto) {
|
||||
schedulersService.deleteSchedulers(dto);
|
||||
return Result.success(ResultCodeEnum.DELETE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取所有可用调度任务", description = "获取所有可用调度任务")
|
||||
@Operation(summary = "获取所有可用调度任务", description = "获取所有可用调度任务", tags = "schedulers::query")
|
||||
@GetMapping("private")
|
||||
public Result<List<Map<String, String>>> getScheduleJobList() {
|
||||
List<Map<String, String>> mapList = schedulersService.getScheduleJobList();
|
||||
|
|
|
@ -35,7 +35,7 @@ public class SchedulersGroupController {
|
|||
@Resource
|
||||
private SchedulersGroupService schedulersGroupService;
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页查询任务调度分组")
|
||||
@Operation(summary = "分页查询", description = "分页查询任务调度分组", tags = "schedulersGroup::query")
|
||||
@GetMapping("{page}/{limit}")
|
||||
public Result<PageResult<SchedulersGroupVo>> getSchedulersGroupPage(
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
|
@ -48,28 +48,28 @@ public class SchedulersGroupController {
|
|||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加", description = "添加任务调度分组")
|
||||
@Operation(summary = "添加", description = "添加任务调度分组", tags = "schedulersGroup::add")
|
||||
@PostMapping()
|
||||
public Result<String> addSchedulersGroup(@Valid @RequestBody SchedulersGroupAddDto dto) {
|
||||
schedulersGroupService.addSchedulersGroup(dto);
|
||||
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新", description = "更新任务调度分组")
|
||||
@Operation(summary = "更新", description = "更新任务调度分组", tags = "schedulersGroup::update")
|
||||
@PutMapping()
|
||||
public Result<String> updateSchedulersGroup(@Valid @RequestBody SchedulersGroupUpdateDto dto) {
|
||||
schedulersGroupService.updateSchedulersGroup(dto);
|
||||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除", description = "删除任务调度分组")
|
||||
@Operation(summary = "删除", description = "删除任务调度分组", tags = "schedulersGroup::delete")
|
||||
@DeleteMapping()
|
||||
public Result<String> deleteSchedulersGroup(@RequestBody List<Long> ids) {
|
||||
schedulersGroupService.deleteSchedulersGroup(ids);
|
||||
return Result.success(ResultCodeEnum.DELETE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取所有任务调度分组", description = "获取所有任务调度分组")
|
||||
@Operation(summary = "获取所有任务调度分组", description = "获取所有任务调度分组", tags = "schedulersGroup::query")
|
||||
@GetMapping("getSchedulersGroupList")
|
||||
public Result<List<SchedulersGroupVo>> getSchedulersGroupList() {
|
||||
List<SchedulersGroupVo> voList = schedulersGroupService.getSchedulersGroupList();
|
||||
|
|
|
@ -35,7 +35,7 @@ public class DeptController {
|
|||
@Resource
|
||||
private DeptService deptService;
|
||||
|
||||
@Operation(summary = "分页查询部门", description = "分页查询部门")
|
||||
@Operation(summary = "分页查询部门", description = "分页查询部门", tags = "schedulersGroup::query")
|
||||
@GetMapping("{page}/{limit}")
|
||||
public Result<PageResult<DeptVo>> getDeptPage(
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
|
@ -48,28 +48,28 @@ public class DeptController {
|
|||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加部门", description = "添加部门")
|
||||
@Operation(summary = "添加部门", description = "添加部门", tags = "schedulersGroup::add")
|
||||
@PostMapping()
|
||||
public Result<String> addDept(@Valid @RequestBody DeptAddDto dto) {
|
||||
deptService.addDept(dto);
|
||||
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新部门", description = "更新部门")
|
||||
@Operation(summary = "更新部门", description = "更新部门", tags = "schedulersGroup::update")
|
||||
@PutMapping()
|
||||
public Result<String> updateDept(@Valid @RequestBody DeptUpdateDto dto) {
|
||||
deptService.updateDept(dto);
|
||||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除部门", description = "删除部门")
|
||||
@Operation(summary = "删除部门", description = "删除部门", tags = "schedulersGroup::delete")
|
||||
@DeleteMapping()
|
||||
public Result<String> deleteDept(@RequestBody List<Long> ids) {
|
||||
deptService.deleteDept(ids);
|
||||
return Result.success(ResultCodeEnum.DELETE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取所有部门", description = "获取所有部门")
|
||||
@Operation(summary = "获取所有部门", description = "获取所有部门", tags = "schedulersGroup::query")
|
||||
@GetMapping("private/getDeptList")
|
||||
public Result<List<DeptVo>> getDeptPage() {
|
||||
List<DeptVo> voList = deptService.getDeptPage();
|
||||
|
|
|
@ -41,7 +41,7 @@ public class FilesController {
|
|||
@Resource
|
||||
private FilesService filesService;
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页查询系统文件")
|
||||
@Operation(summary = "分页查询", description = "分页查询系统文件", tags = "files::query")
|
||||
@GetMapping("{page}/{limit}")
|
||||
public Result<PageResult<FilesVo>> getFilesPage(
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
|
@ -54,41 +54,41 @@ public class FilesController {
|
|||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新", description = "更新系统文件")
|
||||
@Operation(summary = "更新", description = "更新系统文件", tags = "files::update")
|
||||
@PutMapping()
|
||||
public Result<String> updateFiles(@Valid FilesUpdateDto dto) {
|
||||
filesService.updateFiles(dto);
|
||||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加", description = "添加系统文件")
|
||||
@Operation(summary = "添加", description = "添加系统文件", tags = "files::add")
|
||||
@PostMapping()
|
||||
public Result<Object> addFiles(@Valid FilesAddDto dto) {
|
||||
filesService.addFiles(dto);
|
||||
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除", description = "删除系统文件")
|
||||
@Operation(summary = "删除", description = "删除系统文件", tags = "files::delete")
|
||||
@DeleteMapping()
|
||||
public Result<String> deleteFiles(@RequestBody List<Long> ids) {
|
||||
filesService.deleteFiles(ids);
|
||||
return Result.success(ResultCodeEnum.DELETE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "下载文件", description = "根据文件id下载文件")
|
||||
@Operation(summary = "下载文件", description = "根据文件id下载文件", tags = "files::query")
|
||||
@GetMapping("file/{fileId}")
|
||||
public ResponseEntity<byte[]> downloadFilesByFileId(@PathVariable Long fileId) {
|
||||
return filesService.downloadFilesByFileId(fileId);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取所有文件类型", description = "获取所有文件类型")
|
||||
@Operation(summary = "获取所有文件类型", description = "获取所有文件类型", tags = "files::query")
|
||||
@GetMapping("private/getMediaTypeList")
|
||||
public Result<Set<String>> getMediaTypeList() {
|
||||
Set<String> list = filesService.getMediaTypeList();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取所有文件存储基础路径", description = "获取所有文件存储基础路径")
|
||||
@Operation(summary = "获取所有文件存储基础路径", description = "获取所有文件存储基础路径", tags = "files::query")
|
||||
@GetMapping("private/getAllFilesStoragePath")
|
||||
public Result<List<String>> getAllFilesStoragePath() {
|
||||
Map<String, String> typeMap = MinioConstant.typeMap;
|
||||
|
@ -97,7 +97,7 @@ public class FilesController {
|
|||
return Result.success(list);
|
||||
}
|
||||
|
||||
@Operation(summary = "上传文件", description = "上传文件")
|
||||
@Operation(summary = "上传文件", description = "上传文件", tags = "files::add")
|
||||
@PostMapping("private/upload")
|
||||
public Result<FileInfoVo> upload(FileUploadDto dto) {
|
||||
FileInfoVo vo = filesService.upload(dto);
|
||||
|
|
|
@ -9,7 +9,9 @@ import cn.bunny.domain.system.vo.PermissionVo;
|
|||
import cn.bunny.domain.vo.result.PageResult;
|
||||
import cn.bunny.domain.vo.result.Result;
|
||||
import cn.bunny.domain.vo.result.ResultCodeEnum;
|
||||
import cn.bunny.services.aop.scanner.controller.ScannerControllerInfoVo;
|
||||
import cn.bunny.services.service.system.PermissionService;
|
||||
import cn.bunny.services.utils.system.PermissionUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
|
@ -38,7 +40,7 @@ public class PermissionController {
|
|||
@Resource
|
||||
private PermissionService permissionService;
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页查询权限")
|
||||
@Operation(summary = "分页查询", description = "分页查询权限", tags = {"permission::page", "permission::queryPage"})
|
||||
@GetMapping("{page}/{limit}")
|
||||
public Result<PageResult<PermissionVo>> getPermissionPage(
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
|
@ -51,48 +53,55 @@ public class PermissionController {
|
|||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加", description = "添加权限")
|
||||
@Operation(summary = "添加", description = "添加权限", tags = "permission::add")
|
||||
@PostMapping()
|
||||
public Result<String> addPermission(@Valid @RequestBody PermissionAddDto dto) {
|
||||
permissionService.addPermission(dto);
|
||||
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新", description = "更新权限")
|
||||
@Operation(summary = "更新", description = "更新权限", tags = "permission::update")
|
||||
@PutMapping()
|
||||
public Result<String> updatePermission(@Valid @RequestBody PermissionUpdateDto dto) {
|
||||
permissionService.updatePermission(dto);
|
||||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除", description = "删除权限")
|
||||
@Operation(summary = "删除", description = "删除权限", tags = "permission::delete")
|
||||
@DeleteMapping()
|
||||
public Result<Object> deletePermission(@RequestBody List<Long> ids) {
|
||||
permissionService.deletePermission(ids);
|
||||
return Result.success(ResultCodeEnum.DELETE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "导出权限", description = "导出权限为Excel")
|
||||
@Operation(summary = "导出权限", description = "导出权限为Excel", tags = "permission::update")
|
||||
@GetMapping("file/export")
|
||||
public ResponseEntity<byte[]> exportPermission(String type) {
|
||||
return permissionService.exportPermission(type);
|
||||
}
|
||||
|
||||
@Operation(summary = "导入权限", description = "导入权限")
|
||||
@Operation(summary = "导入权限", description = "导入权限", tags = "permission::update")
|
||||
@PutMapping("file/import")
|
||||
public Result<String> importPermission(@RequestParam(value = "file") MultipartFile file, String type) {
|
||||
permissionService.importPermission(file, type);
|
||||
return Result.success(ResultCodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取所有权限", description = "获取所有权限")
|
||||
@Operation(summary = "获取所有权限", description = "获取所有权限", tags = {"permission::query"})
|
||||
@GetMapping("getPermissionList")
|
||||
public Result<List<PermissionVo>> getPermissionList() {
|
||||
List<PermissionVo> voList = permissionService.getPermissionList();
|
||||
return Result.success(voList);
|
||||
}
|
||||
|
||||
@Operation(summary = "批量修改权限父级", description = "批量修改权限父级")
|
||||
@Operation(summary = "获取系统API信息列表", description = "系统接口API信息列表", tags = "permission::query")
|
||||
@GetMapping("private/getSystemApiInfoList")
|
||||
public Result<List<ScannerControllerInfoVo>> getSystemApiInfoList() {
|
||||
List<ScannerControllerInfoVo> list = PermissionUtil.getSystemApiInfoList();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
@Operation(summary = "批量修改权限父级", description = "批量修改权限父级", tags = "permission::update")
|
||||
@PutMapping("update/permissionListByParentId")
|
||||
public Result<String> updatePermissionListByParentId(@RequestBody @Valid PermissionUpdateBatchByParentIdDto dto) {
|
||||
permissionService.updatePermissionListByParentId(dto);
|
||||
|
|
|
@ -37,7 +37,7 @@ public class RoleController {
|
|||
@Resource
|
||||
private RoleService roleService;
|
||||
|
||||
@Operation(summary = "分页查询角色", description = "分页查询角色")
|
||||
@Operation(summary = "分页查询角色", description = "分页查询角色", tags = "role::query")
|
||||
@GetMapping("{page}/{limit}")
|
||||
public Result<PageResult<RoleVo>> getRolePage(
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
|
@ -50,41 +50,41 @@ public class RoleController {
|
|||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加", description = "添加角色")
|
||||
@Operation(summary = "添加", description = "添加角色", tags = "role::add")
|
||||
@PostMapping()
|
||||
public Result<Object> addRole(@Valid @RequestBody RoleAddDto dto) {
|
||||
roleService.addRole(dto);
|
||||
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新", description = "更新角色")
|
||||
@Operation(summary = "更新", description = "更新角色", tags = "role::update")
|
||||
@PutMapping()
|
||||
public Result<Object> updateRole(@Valid @RequestBody RoleUpdateDto dto) {
|
||||
roleService.updateRole(dto);
|
||||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除", description = "删除角色")
|
||||
@Operation(summary = "删除", description = "删除角色", tags = "role::delete")
|
||||
@DeleteMapping()
|
||||
public Result<Object> deleteRole(@RequestBody List<Long> ids) {
|
||||
roleService.deleteRole(ids);
|
||||
return Result.success(ResultCodeEnum.DELETE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取所有角色", description = "获取所有角色")
|
||||
@Operation(summary = "获取所有角色", description = "获取所有角色", tags = "role::query")
|
||||
@GetMapping("private/roleList")
|
||||
public Result<List<RoleVo>> roleList() {
|
||||
List<RoleVo> roleVoList = roleService.roleList();
|
||||
return Result.success(roleVoList);
|
||||
}
|
||||
|
||||
@Operation(summary = "导出角色列表", description = "使用Excel导出导出角色列表")
|
||||
@Operation(summary = "导出角色列表", description = "使用Excel导出导出角色列表", tags = "role::update")
|
||||
@GetMapping("file/export")
|
||||
public ResponseEntity<byte[]> exportByExcel() {
|
||||
return roleService.exportByExcel();
|
||||
}
|
||||
|
||||
@Operation(summary = "更新角色列表", description = "使用Excel更新角色列表")
|
||||
@Operation(summary = "更新角色列表", description = "使用Excel更新角色列表", tags = "role::update")
|
||||
@PutMapping("file/import")
|
||||
public Result<String> updateRoleByFile(MultipartFile file) {
|
||||
roleService.updateRoleByFile(file);
|
||||
|
|
|
@ -27,14 +27,14 @@ public class RolePermissionController {
|
|||
@Resource
|
||||
private RolePermissionService rolePermissionService;
|
||||
|
||||
@Operation(summary = "根据角色id获取权限内容", description = "根据角色id获取权限内容")
|
||||
@Operation(summary = "根据角色id获取权限内容", description = "根据角色id获取权限内容", tags = "rolePermission::query")
|
||||
@GetMapping("private/getPermissionListByRoleId")
|
||||
public Result<List<String>> getPermissionListByRoleId(Long id) {
|
||||
List<String> voList = rolePermissionService.getPermissionListByRoleId(id);
|
||||
return Result.success(voList);
|
||||
}
|
||||
|
||||
@Operation(summary = "为角色分配权限", description = "为角色分配权限")
|
||||
@Operation(summary = "为角色分配权限", description = "为角色分配权限", tags = "rolePermission::update")
|
||||
@PostMapping()
|
||||
public Result<String> addRolPermission(@Valid @RequestBody AssignPowersToRoleDto dto) {
|
||||
rolePermissionService.addRolPermission(dto);
|
||||
|
|
|
@ -31,35 +31,35 @@ public class RouterController {
|
|||
@Resource
|
||||
private RouterService routerService;
|
||||
|
||||
@Operation(summary = "获取用户菜单", description = "获取用户菜单")
|
||||
@Operation(summary = "获取用户菜单", description = "获取用户菜单", tags = "router::query")
|
||||
@GetMapping("private/routerAsync")
|
||||
public Result<List<WebUserRouterVo>> routerAsync() {
|
||||
List<WebUserRouterVo> voList = routerService.routerAsync();
|
||||
return Result.success(voList);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询管理菜单列表", description = "查询管理菜单列表")
|
||||
@Operation(summary = "查询管理菜单列表", description = "查询管理菜单列表", tags = "router::query")
|
||||
@GetMapping("routerList")
|
||||
public Result<List<RouterManageVo>> routerList() {
|
||||
List<RouterManageVo> voPageResult = routerService.routerList();
|
||||
return Result.success(voPageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加", description = "添加路由菜单")
|
||||
@Operation(summary = "添加", description = "添加路由菜单", tags = "router::add")
|
||||
@PostMapping()
|
||||
public Result<String> addRouter(@Valid @RequestBody RouterAddDto dto) {
|
||||
routerService.addRouter(dto);
|
||||
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新", description = "更新路由菜单")
|
||||
@Operation(summary = "更新", description = "更新路由菜单", tags = "router::update")
|
||||
@PutMapping()
|
||||
public Result<String> updateRouter(@Valid @RequestBody RouterUpdateDto dto) {
|
||||
routerService.updateRouter(dto);
|
||||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除", description = "删除路由菜单")
|
||||
@Operation(summary = "删除", description = "删除路由菜单", tags = "router::delete")
|
||||
@DeleteMapping()
|
||||
public Result<String> deletedRouterByIds(@RequestBody List<Long> ids) {
|
||||
routerService.deletedRouterByIds(ids);
|
||||
|
|
|
@ -25,14 +25,14 @@ public class RouterRoleController {
|
|||
@Resource
|
||||
private RouterRoleService routerRoleService;
|
||||
|
||||
@Operation(summary = "根据菜单id获取所有角色", description = "根据菜单id获取所有角色")
|
||||
@Operation(summary = "根据菜单id获取所有角色", description = "根据菜单id获取所有角色", tags = "routerRole::query")
|
||||
@GetMapping("private/getRoleListByRouterId")
|
||||
public Result<List<String>> getRoleListByRouterId(Long routerId) {
|
||||
List<String> roleListByRouterId = routerRoleService.getRoleListByRouterId(routerId);
|
||||
return Result.success(roleListByRouterId);
|
||||
}
|
||||
|
||||
@Operation(summary = "清除选中菜单所有角色", description = "清除选中菜单所有角色")
|
||||
@Operation(summary = "清除选中菜单所有角色", description = "清除选中菜单所有角色", tags = "routerRole::delete")
|
||||
@DeleteMapping("clearRouterRole")
|
||||
public Result<String> clearRouterRole(@RequestBody List<Long> routerIds) {
|
||||
routerRoleService.clearRouterRole(routerIds);
|
||||
|
|
|
@ -72,7 +72,7 @@ public class UserController {
|
|||
// -----------------------------------------
|
||||
// 管理用户CURD
|
||||
// -----------------------------------------
|
||||
@Operation(summary = "分页查询", description = "分页查询用户信息")
|
||||
@Operation(summary = "分页查询", description = "分页查询用户信息", tags = "user::query")
|
||||
@GetMapping("{page}/{limit}")
|
||||
public Result<PageResult<AdminUserVo>> getUserPageByAdmin(
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
|
@ -85,14 +85,14 @@ public class UserController {
|
|||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加", description = "添加用户信息")
|
||||
@Operation(summary = "添加", description = "添加用户信息", tags = "user::add")
|
||||
@PostMapping()
|
||||
public Result<Object> addUserByAdmin(@Valid @RequestBody AdminUserAddDto dto) {
|
||||
userService.addUserByAdmin(dto);
|
||||
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新", description = "更新用户信息,需要更新Redis中的内容")
|
||||
@Operation(summary = "更新", description = "更新用户信息,需要更新Redis中的内容", tags = "user::update")
|
||||
@PutMapping()
|
||||
public Result<String> updateUserByAdmin(
|
||||
@Valid AdminUserUpdateDto dto,
|
||||
|
@ -104,28 +104,28 @@ public class UserController {
|
|||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除用户", description = "删除用户")
|
||||
@Operation(summary = "删除用户", description = "删除用户", tags = "user::delete")
|
||||
@DeleteMapping()
|
||||
public Result<Object> deleteUserByAdmin(@RequestBody List<Long> ids) {
|
||||
userService.deleteUserByAdmin(ids);
|
||||
return Result.success(ResultCodeEnum.DELETE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据用户id查询", description = "根据用户ID获取用户信息,不包含Redis中的信息")
|
||||
@Operation(summary = "根据用户id查询", description = "根据用户ID获取用户信息,不包含Redis中的信息", tags = "user::query")
|
||||
@GetMapping("private/getUserinfoById")
|
||||
public Result<UserVo> getUserinfoById(Long id) {
|
||||
UserVo vo = userService.getUserinfoById(id);
|
||||
return Result.success(vo);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据用户名查询用户列表", description = "根据用户名查询用户列表")
|
||||
@Operation(summary = "根据用户名查询用户列表", description = "根据用户名查询用户列表", tags = "user::query")
|
||||
@GetMapping("private/getUserListByKeyword")
|
||||
public Result<List<UserVo>> getUserListByKeyword(String keyword) {
|
||||
List<UserVo> voList = userService.getUserListByKeyword(keyword);
|
||||
return Result.success(voList);
|
||||
}
|
||||
|
||||
@Operation(summary = "强制退出", description = "强制退出")
|
||||
@Operation(summary = "强制退出", description = "强制退出", tags = "user::update")
|
||||
@PutMapping("forcedOffline")
|
||||
public Result<String> forcedOfflineByAdmin(@RequestBody Long id) {
|
||||
userService.forcedOfflineByAdmin(id);
|
||||
|
|
|
@ -33,7 +33,7 @@ public class UserRoleController {
|
|||
return Result.success(roleVoList);
|
||||
}
|
||||
|
||||
@Operation(summary = "为用户分配角色", description = "为用户分配角色")
|
||||
@Operation(summary = "为用户分配角色", description = "为用户分配角色", tags = "user::add")
|
||||
@PostMapping()
|
||||
public Result<String> addUserRole(@RequestBody AssignRolesToUsersDto dto) {
|
||||
userRoleService.addUserRole(dto);
|
||||
|
|
|
@ -23,7 +23,7 @@ public class WebSecurityConfig {
|
|||
"/", "/ws/**", "/**.html", "/error",
|
||||
"/media.ico", "/favicon.ico", "/webjars/**", "/v3/api-docs/**", "/swagger-ui/**",
|
||||
"/*/*/login",
|
||||
"/*/*/public/**", "/*/public/**", "/public/**"
|
||||
"/*/*/public/**", "/*/public/**", "/public/**", "/*/*/public"
|
||||
};
|
||||
|
||||
// 用户登录之后才能访问,不能与接口名称重复!!!不能与接口名称包含!!!
|
||||
|
|
|
@ -114,7 +114,7 @@ public class CustomAuthorizationManagerServiceImpl implements AuthorizationManag
|
|||
boolean checkedAdmin = RoleUtil.checkAdmin(roleCodeList);
|
||||
if (checkedAdmin) return true;
|
||||
|
||||
// 判断请求地址是否是 noManage 不需要被验证的
|
||||
// 判断请求地址是否是登录之后才需要访问的,已经登录了不需要验证的
|
||||
String requestURI = request.getRequestURI();
|
||||
for (String userAuth : WebSecurityConfig.userAuths) {
|
||||
if (requestURI.contains(userAuth)) return true;
|
||||
|
@ -129,10 +129,12 @@ public class CustomAuthorizationManagerServiceImpl implements AuthorizationManag
|
|||
.filter(permission -> {
|
||||
String lowerCase = permission.getRequestMethod().toLowerCase();
|
||||
String requestMethodLowerCase = requestMethod.toLowerCase();
|
||||
return lowerCase.equals(requestMethodLowerCase);
|
||||
return lowerCase.equals(requestMethodLowerCase)
|
||||
|| requestURI.contains("/**");
|
||||
})
|
||||
.map(Permission::getRequestUrl)
|
||||
.filter(Objects::nonNull)
|
||||
|
||||
.anyMatch(requestUrl -> {
|
||||
if ((requestUrl.contains("/*") || requestUrl.contains("/**"))) {
|
||||
return new AntPathRequestMatcher(requestUrl).matches(request);
|
||||
|
|
|
@ -7,8 +7,8 @@ import cn.bunny.domain.quartz.entity.Schedulers;
|
|||
import cn.bunny.domain.quartz.vo.SchedulersVo;
|
||||
import cn.bunny.domain.vo.result.PageResult;
|
||||
import cn.bunny.domain.vo.result.ResultCodeEnum;
|
||||
import cn.bunny.services.aop.AnnotationScanner;
|
||||
import cn.bunny.services.aop.annotation.QuartzSchedulers;
|
||||
import cn.bunny.services.aop.scanner.AnnotationScanner;
|
||||
import cn.bunny.services.exception.AuthCustomerException;
|
||||
import cn.bunny.services.mapper.schedule.SchedulersMapper;
|
||||
import cn.bunny.services.service.schedule.SchedulersService;
|
||||
|
@ -37,8 +37,6 @@ public class SchedulersServiceImpl extends ServiceImpl<SchedulersMapper, Schedul
|
|||
@Resource
|
||||
private Scheduler scheduler;
|
||||
|
||||
@Resource
|
||||
private AnnotationScanner annotationScanner;
|
||||
|
||||
/**
|
||||
* * Schedulers视图 服务实现类
|
||||
|
@ -72,7 +70,8 @@ public class SchedulersServiceImpl extends ServiceImpl<SchedulersMapper, Schedul
|
|||
*/
|
||||
@Override
|
||||
public List<Map<String, String>> getScheduleJobList() {
|
||||
Set<Class<?>> classesWithAnnotation = annotationScanner.getClassesWithAnnotation(QuartzSchedulers.class);
|
||||
// 通过扫描注解拿到注解列表,反射拿到类信息和注解上标注的内容信息
|
||||
Set<Class<?>> classesWithAnnotation = AnnotationScanner.getClassesWithAnnotation(QuartzSchedulers.class);
|
||||
return classesWithAnnotation.stream().map(cls -> {
|
||||
Map<String, String> hashMap = new HashMap<>();
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cn.bunny.services.service.system.impl;
|
||||
|
||||
import cn.bunny.domain.constant.FileType;
|
||||
import cn.bunny.domain.system.dto.power.PermissionAddDto;
|
||||
import cn.bunny.domain.system.dto.power.PermissionDto;
|
||||
import cn.bunny.domain.system.dto.power.PermissionUpdateBatchByParentIdDto;
|
||||
|
@ -180,6 +181,7 @@ public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permiss
|
|||
List<PermissionExcel> permissionExcelList = list().stream().map(permission -> {
|
||||
PermissionExcel permissionExcel = new PermissionExcel();
|
||||
BeanUtils.copyProperties(permission, permissionExcel);
|
||||
|
||||
return permissionExcel;
|
||||
}).toList();
|
||||
|
||||
|
@ -193,7 +195,7 @@ public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permiss
|
|||
try (ZipOutputStream zipOutputStream = new ZipOutputStream(byteArrayOutputStream)) {
|
||||
|
||||
// 判断导出类型是什么
|
||||
if (type.equals("xlsx")) {
|
||||
if (type.equals(FileType.EXCEL)) {
|
||||
PermissionUtil.writExcel(permissionExcelList, zipOutputStream, filename + ".xlsx");
|
||||
} else {
|
||||
PermissionUtil.writeJson(buildTree, zipOutputStream, filename + ".json");
|
||||
|
@ -208,7 +210,6 @@ public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permiss
|
|||
return new ResponseEntity<>(byteArrayInputStream.readAllBytes(), headers, HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导入权限
|
||||
*
|
||||
|
@ -222,7 +223,7 @@ public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permiss
|
|||
}
|
||||
|
||||
try {
|
||||
if (type.equals("xlsx")) {
|
||||
if (type.equals(FileType.EXCEL)) {
|
||||
InputStream fileInputStream = file.getInputStream();
|
||||
EasyExcel.read(fileInputStream, PermissionExcel.class, new PermissionExcelListener(this)).sheet().doRead();
|
||||
} else {
|
||||
|
@ -236,6 +237,7 @@ public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permiss
|
|||
List<Permission> permissionList = flattenedTree.stream().map(permissionExcel -> {
|
||||
Permission permission = new Permission();
|
||||
BeanUtils.copyProperties(permissionExcel, permission);
|
||||
|
||||
return permission;
|
||||
}).toList();
|
||||
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
package cn.bunny.services.utils.system;
|
||||
|
||||
import cn.bunny.services.aop.scanner.controller.ControllerInfo;
|
||||
import cn.bunny.services.aop.scanner.controller.MethodInfo;
|
||||
import cn.bunny.services.aop.scanner.controller.ScannerControllerInfoVo;
|
||||
import cn.bunny.services.aop.scanner.controller.utils.ControllerScannerUtil;
|
||||
import cn.bunny.services.excel.entity.PermissionExcel;
|
||||
import cn.bunny.services.security.config.WebSecurityConfig;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
@ -12,6 +19,7 @@ import java.util.zip.ZipEntry;
|
|||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
public class PermissionUtil {
|
||||
private static final AntPathMatcher PATH_MATCHER = new AntPathMatcher();
|
||||
|
||||
/**
|
||||
* 构建属性结构
|
||||
|
@ -109,4 +117,106 @@ public class PermissionUtil {
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前路径是否有权限被添加
|
||||
*
|
||||
* @param path 请求路径
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isPathAuthorized(String path) {
|
||||
if (!StringUtils.hasText(path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 需要登录的路径模式检查
|
||||
if (path.equals("login")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 需要登录之后才访问的,不需要添加到要被监视的权限中
|
||||
for (String userAuth : WebSecurityConfig.userAuths) {
|
||||
if (path.contains(userAuth)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 在 WebSecurityConfig 默认配置的不需要权限的路径不添加
|
||||
for (String annotation : WebSecurityConfig.annotations) {
|
||||
if (PATH_MATCHER.match(annotation, path) || PATH_MATCHER.match(annotation, "/" + path)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到所有控制器下的接口路径
|
||||
* 其中已经被过滤掉不需要验证的,在 WebSecurityConfig 配置的 annotations
|
||||
* 其中已经过滤掉不需要验证的,在 WebSecurityConfig userAuths
|
||||
* 在 WebSecurityConfig配置的不会被添加权限中
|
||||
*
|
||||
* @return 扫描到,且可以被验证的权限
|
||||
*/
|
||||
public static List<ScannerControllerInfoVo> getSystemApiInfoList() {
|
||||
// 路径中包含 {xxx} 替换成 *
|
||||
String regex = "\\{[^}]*\\}"; // 匹配 {xxx} 格式
|
||||
String replacement = "*"; // 替换为 *
|
||||
|
||||
// 控制器中所有的方法路径等
|
||||
List<ControllerInfo> controllerInfos = ControllerScannerUtil.scanControllerInfo();
|
||||
List<ScannerControllerInfoVo> resultList = new ArrayList<>();
|
||||
|
||||
List<ControllerInfo> controllerInfoList1 = controllerInfos.stream()
|
||||
.filter(controllerInfo -> isPathAuthorized(controllerInfo.getBasePath()))
|
||||
.toList();
|
||||
|
||||
// 父级RequestMapping中的内容
|
||||
for (ControllerInfo controllerInfo : controllerInfoList1) {
|
||||
// 处理RequestMapping上开头路径
|
||||
String basePath = controllerInfo.getBasePath();
|
||||
// 在请求方法前加 /
|
||||
if (!basePath.startsWith("/")) basePath = "/" + basePath;
|
||||
// 在请求方法路径后加 /
|
||||
if (basePath.endsWith("/")) {
|
||||
basePath = basePath.substring(1);
|
||||
}
|
||||
|
||||
ScannerControllerInfoVo parentVo = ScannerControllerInfoVo.builder()
|
||||
.path(basePath + "/**")
|
||||
.summary(controllerInfo.getTagName())
|
||||
.description(controllerInfo.getTagDescription())
|
||||
.build();
|
||||
|
||||
// 子级 控制器下请求方法
|
||||
List<MethodInfo> methods = controllerInfo.getMethods();
|
||||
final String finalBasePath = basePath;
|
||||
List<ScannerControllerInfoVo> children = methods.stream()
|
||||
.filter(methodInfo -> isPathAuthorized(methodInfo.getPath()))
|
||||
.map(methodInfo -> {
|
||||
String methodInfoPath = methodInfo.getPath();
|
||||
// 为路径添加 /
|
||||
if (StringUtils.hasText(methodInfoPath) && !methodInfoPath.startsWith("/")) {
|
||||
methodInfoPath = finalBasePath + "/" + methodInfoPath;
|
||||
// 路径包含 {xxx} 替换成 *
|
||||
methodInfoPath = methodInfoPath.replaceAll(regex, replacement);
|
||||
} else {
|
||||
methodInfoPath = finalBasePath;
|
||||
}
|
||||
|
||||
return ScannerControllerInfoVo.builder()
|
||||
.path(methodInfoPath)
|
||||
.httpMethod(methodInfo.getHttpMethod())
|
||||
.summary(methodInfo.getSummary())
|
||||
.description(methodInfo.getDescription())
|
||||
.powerCodes(methodInfo.getTags())
|
||||
.build();
|
||||
}).toList();
|
||||
|
||||
parentVo.setChildren(children);
|
||||
resultList.add(parentVo);
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
and permission.request_method like CONCAT('%',#{dto.requestMethod},'%')
|
||||
</if>
|
||||
</where>
|
||||
order by permission.update_time desc
|
||||
</select>
|
||||
|
||||
<!-- 根据用户id查询当前用户所有权限 -->
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
package cn.bunny.services.controller;
|
||||
|
||||
import cn.bunny.domain.system.entity.Permission;
|
||||
import cn.bunny.services.aop.scanner.controller.ScannerControllerInfoVo;
|
||||
import cn.bunny.services.service.system.PermissionService;
|
||||
import cn.bunny.services.utils.system.PermissionUtil;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@SpringBootTest
|
||||
class TestControllerTest {
|
||||
|
||||
@Autowired
|
||||
private PermissionService permissionService;
|
||||
|
||||
@Test
|
||||
void test1() {
|
||||
List<ScannerControllerInfoVo> list = PermissionUtil.getSystemApiInfoList();
|
||||
list.forEach(parent -> {
|
||||
String parentPath = parent.getPath();
|
||||
String powerCode = parentPath.replace("/api/", "").replace("/**", "");
|
||||
powerCode = "user::" + powerCode;
|
||||
|
||||
Permission permission = new Permission();
|
||||
permission.setParentId(0L);
|
||||
permission.setPowerCode(powerCode);
|
||||
permission.setPowerName(parent.getSummary());
|
||||
permission.setRequestUrl(parentPath);
|
||||
permissionService.saveOrUpdate(permission);
|
||||
|
||||
List<Permission> permissionList = parent.getChildren().stream()
|
||||
.map(children -> {
|
||||
String childrenPath = children.getPath();
|
||||
String requestMethod = children.getHttpMethod();
|
||||
|
||||
Permission childrenPermission = new Permission();
|
||||
childrenPermission.setParentId(permission.getId());
|
||||
childrenPermission.setPowerName(children.getSummary());
|
||||
if (!children.getPowerCodes().isEmpty()) {
|
||||
String ChildrenPowerCode = children.getPowerCodes().get(0);
|
||||
childrenPermission.setPowerCode(ChildrenPowerCode);
|
||||
|
||||
}
|
||||
childrenPermission.setRequestUrl(childrenPath);
|
||||
childrenPermission.setRequestMethod(requestMethod);
|
||||
|
||||
return childrenPermission;
|
||||
}).toList();
|
||||
permissionService.saveOrUpdateBatch(permissionList);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -25,7 +25,7 @@ public class Knife4jConfig {
|
|||
.description("权限管理模板")
|
||||
.summary("Auth权限模板")
|
||||
.termsOfService("http://bunny-web.site")
|
||||
.version("v1.0.0");
|
||||
.version("v4.0.0");
|
||||
|
||||
return new OpenAPI().info(info).externalDocs(new ExternalDocumentation());
|
||||
}
|
||||
|
|
|
@ -4,11 +4,11 @@ import cn.bunny.domain.entity.BaseEntity;
|
|||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@TableName("sys_permission")
|
||||
@Schema(name = "Power对象", title = "权限", description = "权限")
|
||||
public class Permission extends BaseEntity {
|
||||
|
|
Loading…
Reference in New Issue