From 43bb2516812f1f1b9d2641a36b6e884c36705ef3 Mon Sep 17 00:00:00 2001 From: Hamm Date: Wed, 19 Jun 2024 12:39:27 +0800 Subject: [PATCH 1/8] =?UTF-8?q?docs(root-model):=20=E6=97=A0=E6=95=88?= =?UTF-8?q?=E7=9A=84=E6=B5=8B=E8=AF=95=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- airpower-core/src/main/java/cn/hamm/airpower/root/RootModel.java | 1 + 1 file changed, 1 insertion(+) diff --git a/airpower-core/src/main/java/cn/hamm/airpower/root/RootModel.java b/airpower-core/src/main/java/cn/hamm/airpower/root/RootModel.java index 423e1ed..520277f 100644 --- a/airpower-core/src/main/java/cn/hamm/airpower/root/RootModel.java +++ b/airpower-core/src/main/java/cn/hamm/airpower/root/RootModel.java @@ -80,6 +80,7 @@ public class RootModel> implements IAction { return (M) this; } + /** *

过滤和脱敏

* -- Gitee From b50779d5df4e30f074e311ead4ca8ee13a29d254 Mon Sep 17 00:00:00 2001 From: Hamm Date: Wed, 19 Jun 2024 12:39:55 +0800 Subject: [PATCH 2/8] docs(root-model): add documentation --- airpower-core/src/main/java/cn/hamm/airpower/root/RootModel.java | 1 - 1 file changed, 1 deletion(-) diff --git a/airpower-core/src/main/java/cn/hamm/airpower/root/RootModel.java b/airpower-core/src/main/java/cn/hamm/airpower/root/RootModel.java index 520277f..423e1ed 100644 --- a/airpower-core/src/main/java/cn/hamm/airpower/root/RootModel.java +++ b/airpower-core/src/main/java/cn/hamm/airpower/root/RootModel.java @@ -80,7 +80,6 @@ public class RootModel> implements IAction { return (M) this; } - /** *

过滤和脱敏

* -- Gitee From 77ebcb57599e8c8fad47c0095f3a6057224af4d3 Mon Sep 17 00:00:00 2001 From: Hamm Date: Wed, 19 Jun 2024 12:42:01 +0800 Subject: [PATCH 3/8] feat(root-service): add check for enabled entities on fetch by IDy. Signed-off-by: Hamm --- .../cn/hamm/airpower/enums/ServiceError.java | 3 ++- .../cn/hamm/airpower/root/RootService.java | 21 ++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) 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 94795b4..a3560a6 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/root/RootService.java b/airpower-core/src/main/java/cn/hamm/airpower/root/RootService.java index 65be37b..43ecc0e 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 实体 -- Gitee From d27cf117542a3618251f13ab681ca04f430e16c9 Mon Sep 17 00:00:00 2001 From: Hamm Date: Wed, 19 Jun 2024 20:28:16 +0800 Subject: [PATCH 4/8] =?UTF-8?q?docs(open-app-api):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E6=B3=A8=E9=87=8A=E6=8F=90=E9=AB=98=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E5=8F=AF=E8=AF=BB=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为`IOpenApp`接口中的每个方法添加了详细的注释说明,便于其他开发人员理解其用途和返回值。此次更新主要集中在增强API文档的清晰度和可维护性上。 Signed-off-by: Hamm --- .../src/main/java/cn/hamm/airpower/open/IOpenApp.java | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 1dcd3e0..07eba8a 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(); } -- Gitee From ee766cf49e9d356707b07bf9822e8b97856e223e Mon Sep 17 00:00:00 2001 From: Hamm Date: Wed, 19 Jun 2024 20:28:24 +0800 Subject: [PATCH 5/8] =?UTF-8?q?refactor(rsa-util):=20=E5=B0=86PEM=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2=E6=96=B9=E6=B3=95=E5=90=8D=E6=94=B9=E4=B8=BA=E5=B0=8F?= =?UTF-8?q?=E5=86=99=E4=BB=A5=E7=BB=9F=E4=B8=80=E5=91=BD=E5=90=8D=E9=A3=8E?= =?UTF-8?q?=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为保持代码风格一致性,将公钥和私钥的PEM转换方法名从大写`PEM`修改为小写`pem`。这有助于增强代码的可读性和维护性。 Signed-off-by: Hamm --- .../src/main/java/cn/hamm/airpower/util/RsaUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 b2ac03e..575bed4 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 @@ -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" + -- Gitee From 6e8bb316667496b2dff7714781eed798a75150eb Mon Sep 17 00:00:00 2001 From: Hamm Date: Wed, 19 Jun 2024 20:28:54 +0800 Subject: [PATCH 6/8] =?UTF-8?q?refactor(AccessUtil):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=9D=83=E9=99=90=E6=A0=87=E8=AF=86=E7=9A=84?= =?UTF-8?q?=E6=96=B9=E6=B3=95`getMethodPermissionIdentity`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hamm --- .../cn/hamm/airpower/util/AccessUtil.java | 38 ++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) 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 0c9404c..a138071 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; + } } -- Gitee From 760be2e98b28c1836a131c43be7c27e6df65f300 Mon Sep 17 00:00:00 2001 From: Hamm Date: Wed, 19 Jun 2024 20:37:30 +0800 Subject: [PATCH 7/8] =?UTF-8?q?refactor(RsaUtil):=20=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E5=B8=B8=E9=87=8F=E6=9B=BF=E4=BB=A3=E7=A1=AC=E7=BC=96=E7=A0=81?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hamm --- airpower-core/src/main/java/cn/hamm/airpower/util/RsaUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 575bed4..0e9b218 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(); } -- Gitee From dbb152931093a2a9022e8807a674d13b4b8f7076 Mon Sep 17 00:00:00 2001 From: Hamm Date: Wed, 19 Jun 2024 23:09:28 +0800 Subject: [PATCH 8/8] =?UTF-8?q?release(v2.0.6):=20=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E4=BA=86`v2.0.6`=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hamm --- airpower-core/pom.xml | 4 ++-- pom.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/airpower-core/pom.xml b/airpower-core/pom.xml index 3b906d2..64f8bf4 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/pom.xml b/pom.xml index a9f0c54..139da9c 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 -- Gitee