diff --git a/airpower-core/pom.xml b/airpower-core/pom.xml
index 3b906d2dc1a7a32cecfff9756ff80fdbcd92ad21..64f8bf47735404d437b083158c1bfef73c9881a3 100644
--- a/airpower-core/pom.xml
+++ b/airpower-core/pom.xml
@@ -5,10 +5,10 @@
cn.hamm
airpower
- 2.0.5
+ 2.0.6
airpower-core
- 2.0.5
+ 2.0.6
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/enums/ServiceError.java b/airpower-core/src/main/java/cn/hamm/airpower/enums/ServiceError.java
index 94795b41f1a92061d4ceeccd87a1f6575015a8c4..a3560a6e50dd7cf80b734c44c7d72257649eb585 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/enums/ServiceError.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/enums/ServiceError.java
@@ -39,7 +39,8 @@ public enum ServiceError implements IException, IDictionary {
FORBIDDEN_DELETE(4033, "无权删除"),
FORBIDDEN_DELETE_USED(4034, "数据正在使用中,无法被删除!"),
FORBIDDEN_UPLOAD_MAX_SIZE(4035, "上传的文件大小超过最大限制"),
- OPEN_APP_DISABLED(4036, "当前应用已被禁用"),
+ FORBIDDEN_DISABLED(4036, "ID为%s的%s已被禁用"),
+ OPEN_APP_DISABLED(4037, "当前应用已被禁用"),
// 404 没有查到数据代码
DATA_NOT_FOUND(404, "没有查到相关的数据"),
diff --git a/airpower-core/src/main/java/cn/hamm/airpower/open/IOpenApp.java b/airpower-core/src/main/java/cn/hamm/airpower/open/IOpenApp.java
index 1dcd3e07c6158dee9f3dee4b1b504ef044cce7d9..07eba8a2bf1b301aa9336513c2efcd25634eac51 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/open/IOpenApp.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/open/IOpenApp.java
@@ -9,26 +9,36 @@ package cn.hamm.airpower.open;
public interface IOpenApp {
/**
*
获取应用的AppKey
+ *
+ * @return AppKey
*/
String getAppKey();
/**
* 获取应用的AppSecret
+ *
+ * @return AppSecret
*/
String getAppSecret();
/**
* 获取应用的加密算法
+ *
+ * @return 算法
*/
Integer getArithmetic();
/**
* 获取应用的私钥
+ *
+ * @return 私钥
*/
String getPrivateKey();
/**
* 获取应用的公钥
+ *
+ * @return 公钥
*/
String getPublicKey();
}
diff --git a/airpower-core/src/main/java/cn/hamm/airpower/root/RootService.java b/airpower-core/src/main/java/cn/hamm/airpower/root/RootService.java
index 65be37be0daa9201d88c24c788a89ece43412e8a..43ecc0e2f7a1bbe151043f456dda0f11b84b4388 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/root/RootService.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/root/RootService.java
@@ -368,13 +368,32 @@ public class RootService, R extends RootRepository> {
* @param id 主键ID
* @return 实体
* @see #getMaybeNull(long)
+ * @see #getWithEnable(long)
*/
public final @NotNull E get(long id) {
return afterGet(getById(id));
}
/**
- * 🟡根据ID
查询对应的实体
+ * 🟡根据ID
查询正常启用的实体
+ *
+ * @param id 主键ID
+ * @return 实体
+ * @see #get(long)
+ * @see #getMaybeNull(long)
+ */
+ public final @NotNull E getWithEnable(long id) {
+ E entity = get(id);
+ ServiceError.FORBIDDEN_DISABLED.when(entity.getIsDisabled(), String.format(
+ ServiceError.FORBIDDEN_DISABLED.getMessage(),
+ id, Utils.getReflectUtil().getDescription(getEntityClass())
+ )
+ );
+ return entity;
+ }
+
+ /**
+ * 🟡根据ID
查询对应的实体(可能为null
)
*
* @param id 主键ID
* @return 实体
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 0c9404c2738f225f79f62b5dff2fb45dfbd03f30..a138071dcf165ddd05d4c37e1210e25740ad24dc 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
@@ -152,19 +152,7 @@ public class AccessUtil {
}
String customMethodName = Utils.getReflectUtil().getDescription(method);
- 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];
- }
+ String subIdentity = getMethodPermissionIdentity(method, apiPath);
if (!StringUtils.hasText(subIdentity) || (apiPath + Constant.UNDERLINE).equals(subIdentity)) {
continue;
}
@@ -204,4 +192,28 @@ public class AccessUtil {
}
return !includeList.contains(api);
}
+
+ /**
+ * 获取方法权限标识
+ *
+ * @param method 方法
+ * @param apiPath Api路径
+ * @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];
+ }
+ return subIdentity;
+ }
}
diff --git a/airpower-core/src/main/java/cn/hamm/airpower/util/RsaUtil.java b/airpower-core/src/main/java/cn/hamm/airpower/util/RsaUtil.java
index b2ac03ef6658ec5b2f5028a90200978d26395a77..0e9b218e85d6f3f8b9c527fc3aa43ef726b58320 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/util/RsaUtil.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/util/RsaUtil.java
@@ -215,7 +215,7 @@ public class RsaUtil {
* @return KeyPair
*/
public final KeyPair generateKeyPair() throws NoSuchAlgorithmException {
- KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
+ KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(CRYPT_METHOD);
keyPairGenerator.initialize(2048);
return keyPairGenerator.generateKeyPair();
}
@@ -226,7 +226,7 @@ public class RsaUtil {
* @param publicKey 公钥
* @return PEM
*/
- public final @NotNull String convertPublicKeyToPEM(@NotNull PublicKey publicKey) {
+ public final @NotNull String convertPublicKeyToPem(@NotNull PublicKey publicKey) {
byte[] encoded = publicKey.getEncoded();
String base64Encoded = Base64.getEncoder().encodeToString(encoded);
return "-----BEGIN PUBLIC KEY-----\n" +
@@ -240,7 +240,7 @@ public class RsaUtil {
* @param privateKey 私钥
* @return PEM
*/
- public final @NotNull String convertPrivateKeyToPEM(@NotNull PrivateKey privateKey) {
+ public final @NotNull String convertPrivateKeyToPem(@NotNull PrivateKey privateKey) {
byte[] encoded = privateKey.getEncoded();
String base64Encoded = Base64.getEncoder().encodeToString(encoded);
return "-----BEGIN RSA PRIVATE KEY-----\n" +
diff --git a/pom.xml b/pom.xml
index a9f0c54febcbb2bb7f57c2dd772a3e6f3ec30283..139da9c8626699166819df8d3a5fc218ceaac453 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,11 +4,11 @@
4.0.0
cn.hamm
airpower
- 2.0.5
+ 2.0.6
airpower
AirPower is a fast backend development tool based on SpringBoot3 and JPA.
- 2.0.5
+ 2.0.6
UTF-8
UTF-8
UTF-8