diff --git a/airpower-core/pom.xml b/airpower-core/pom.xml index cb5bb28e0162c8557d3d904885686306eca253cf..4f3393d2801864db09bd7d6ce650ec91d67cb5e1 100644 --- a/airpower-core/pom.xml +++ b/airpower-core/pom.xml @@ -5,10 +5,10 @@ cn.hamm airpower - 2.0.7 + 2.1.0 airpower-core - 2.0.7 + 2.1.0 airpower-core AirPower is a fast backend development tool based on SpringBoot3 and JPA. It's the core of AirPower. diff --git a/airpower-core/src/main/java/cn/hamm/airpower/util/AccessUtil.java b/airpower-core/src/main/java/cn/hamm/airpower/util/AccessUtil.java index a138071dcf165ddd05d4c37e1210e25740ad24dc..a0b4fcf2d995c46b53f12c2de3c008e0ffdffc00 100644 --- a/airpower-core/src/main/java/cn/hamm/airpower/util/AccessUtil.java +++ b/airpower-core/src/main/java/cn/hamm/airpower/util/AccessUtil.java @@ -133,7 +133,7 @@ public class AccessUtil { permission.setName(customClassName).setIdentity(identity); permission.setChildren(new ArrayList<>()); - String apiPath = apiController.value(); + String apiPath = clazz.getSimpleName().replaceAll(Constant.CONTROLLER_SUFFIX, Constant.EMPTY_STRING) + Constant.UNDERLINE; // 取出所有控制器方法 Method[] methods = clazz.getMethods(); @@ -141,6 +141,7 @@ public class AccessUtil { // 取出控制器类上的Extends注解 如自己没标 则使用父类的 Extends extendsApi = Utils.getReflectUtil().getAnnotation(Extends.class, clazz); for (Method method : methods) { + if (Objects.nonNull(extendsApi)) { try { Api current = Utils.getDictionaryUtil().getDictionary(Api.class, Api::getMethodName, method.getName()); @@ -150,13 +151,11 @@ public class AccessUtil { } catch (Exception ignored) { } } - String customMethodName = Utils.getReflectUtil().getDescription(method); - String subIdentity = getMethodPermissionIdentity(method, apiPath); - if (!StringUtils.hasText(subIdentity) || (apiPath + Constant.UNDERLINE).equals(subIdentity)) { + if (apiPath.equals(subIdentity)) { continue; } - + String customMethodName = Utils.getReflectUtil().getDescription(method); Access accessConfig = Utils.getAccessUtil().getWhatNeedAccess(clazz, method); if (!accessConfig.isLogin() || !accessConfig.isAuthorize()) { // 这里可以选择是否不读取这些接口的权限,但前端可能需要 @@ -201,19 +200,13 @@ public class AccessUtil { * @return 权限标识 */ private @NotNull String getMethodPermissionIdentity(Method method, String apiPath) { - String subIdentity = (!Constant.EMPTY_STRING.equalsIgnoreCase(apiPath) ? (apiPath + Constant.UNDERLINE) : Constant.EMPTY_STRING); - RequestMapping requestMapping = Utils.getReflectUtil().getAnnotation(RequestMapping.class, method); PostMapping postMapping = Utils.getReflectUtil().getAnnotation(PostMapping.class, method); GetMapping getMapping = Utils.getReflectUtil().getAnnotation(GetMapping.class, method); - if (Objects.nonNull(requestMapping) && requestMapping.value().length > 0) { - subIdentity += requestMapping.value()[0]; - } else if (Objects.nonNull(postMapping) && postMapping.value().length > 0) { - subIdentity += postMapping.value()[0]; - } else if (Objects.nonNull(getMapping) && getMapping.value().length > 0) { - subIdentity += getMapping.value()[0]; + if (Objects.isNull(requestMapping) && Objects.isNull(postMapping) && Objects.isNull(getMapping)) { + return apiPath; } - return subIdentity; + return apiPath + method.getName(); } } diff --git a/pom.xml b/pom.xml index a32f372669bd15820c1cbf892bf68277c3461f3d..52066a2d4c4b4f0aa2a45795a6578be0406a956c 100644 --- a/pom.xml +++ b/pom.xml @@ -4,11 +4,11 @@ 4.0.0 cn.hamm airpower - 2.0.7 + 2.1.0 airpower AirPower is a fast backend development tool based on SpringBoot3 and JPA. - 2.0.7 + 2.1.0 UTF-8 UTF-8 UTF-8