From 213212436a9f16570b85ffd71208e3fce6760f94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=98xcsnx=E2=80=99?= <‘1192709687@qq.com’> Date: Sat, 21 Sep 2024 00:41:17 +0800 Subject: [PATCH 1/4] auth --- db/init/mysql/schema.sql | 4 +- db/init/ob/schema.sql | 4 +- db/init/og/create-table.sql | 5 ++- db/init/oracle/schema.sql | 5 ++- db/init/pg/create-table.sql | 5 ++- db/upgrade/2.6.1-upgrade-2.7.0-mysql.sql | 5 +++ db/upgrade/2.6.1-upgrade-2.7.0-og.sql | 8 +++- db/upgrade/2.6.1-upgrade-2.7.0-oracle.sql | 7 ++- db/upgrade/2.6.1-upgrade-2.7.0-pg.sql | 8 +++- .../admin/controller/AppAuthController.java | 7 ++- .../shenyu/admin/model/dto/AppAuthDTO.java | 31 ++++++++++++- .../shenyu/admin/model/dto/AuthApplyDTO.java | 33 +++++++++++++- .../admin/model/dto/AuthPathWarpDTO.java | 4 +- .../shenyu/admin/model/entity/AppAuthDO.java | 43 ++++++++++++++++-- .../admin/model/query/AppAuthQuery.java | 31 +++++++++++-- .../shenyu/admin/model/vo/AppAuthVO.java | 20 +++++++++ .../service/impl/AppAuthServiceImpl.java | 3 ++ .../admin/transfer/AppAuthTransfer.java | 2 + .../src/main/resources/application-mysql.yml | 2 +- .../src/main/resources/application.yml | 2 +- .../resources/mappers/app-auth-sqlmap.xml | 9 +++- .../main/resources/sql-script/h2/schema.sql | 4 +- .../controller/AppAuthControllerTest.java | 3 +- .../apache/shenyu/common/dto/AppAuthData.java | 44 ++++++++++++++++++- .../src/main/resources/application.yml | 2 +- 25 files changed, 262 insertions(+), 29 deletions(-) diff --git a/db/init/mysql/schema.sql b/db/init/mysql/schema.sql index 4a96c40970db..da43e0559c7f 100644 --- a/db/init/mysql/schema.sql +++ b/db/init/mysql/schema.sql @@ -2375,4 +2375,6 @@ ALTER TABLE `shenyu`.`selector` ADD COLUMN `namespace_id` varchar(50) NULL COMME ALTER TABLE `shenyu`.`rule` ADD COLUMN `namespace_id` varchar(50) NULL COMMENT 'namespaceId' AFTER `match_restful`; -ALTER TABLE `shenyu`.`meta_data` ADD COLUMN `namespace_id` varchar(50) NULL COMMENT 'namespaceId'; \ No newline at end of file +ALTER TABLE `shenyu`.`meta_data` ADD COLUMN `namespace_id` varchar(50) NULL COMMENT 'namespaceId'; + +ALTER TABLE `shenyu`.`app_auth` ADD COLUMN `namespace_id` varchar(50) NULL COMMENT 'namespaceId' AFTER `enabled`; \ No newline at end of file diff --git a/db/init/ob/schema.sql b/db/init/ob/schema.sql index 4a96c40970db..da43e0559c7f 100644 --- a/db/init/ob/schema.sql +++ b/db/init/ob/schema.sql @@ -2375,4 +2375,6 @@ ALTER TABLE `shenyu`.`selector` ADD COLUMN `namespace_id` varchar(50) NULL COMME ALTER TABLE `shenyu`.`rule` ADD COLUMN `namespace_id` varchar(50) NULL COMMENT 'namespaceId' AFTER `match_restful`; -ALTER TABLE `shenyu`.`meta_data` ADD COLUMN `namespace_id` varchar(50) NULL COMMENT 'namespaceId'; \ No newline at end of file +ALTER TABLE `shenyu`.`meta_data` ADD COLUMN `namespace_id` varchar(50) NULL COMMENT 'namespaceId'; + +ALTER TABLE `shenyu`.`app_auth` ADD COLUMN `namespace_id` varchar(50) NULL COMMENT 'namespaceId' AFTER `enabled`; \ No newline at end of file diff --git a/db/init/og/create-table.sql b/db/init/og/create-table.sql index 398a487ca125..86099a8afad8 100644 --- a/db/init/og/create-table.sql +++ b/db/init/og/create-table.sql @@ -2681,4 +2681,7 @@ ALTER TABLE "public"."rule" ADD COLUMN namespace_id VARCHAR(50) NULL; COMMENT ON COLUMN "public"."rule"."namespace_id" IS 'namespaceId'; ALTER TABLE "public"."meta_data" ADD COLUMN namespace_id VARCHAR(50) NULL; -COMMENT ON COLUMN "public"."meta_data"."namespace_id" IS 'namespaceId'; \ No newline at end of file +COMMENT ON COLUMN "public"."meta_data"."namespace_id" IS 'namespaceId'; + +ALTER TABLE "public"."app_auth" ADD COLUMN namespace_id VARCHAR(50) NULL; +COMMENT ON COLUMN "public"."app_auth"."namespace_id" IS 'namespaceId'; \ No newline at end of file diff --git a/db/init/oracle/schema.sql b/db/init/oracle/schema.sql index 27d708d87c36..62c66c98dda7 100644 --- a/db/init/oracle/schema.sql +++ b/db/init/oracle/schema.sql @@ -2866,4 +2866,7 @@ ALTER TABLE rule ADD namespace_id VARCHAR2(50) NULL; COMMENT ON COLUMN rule.namespace_id IS 'namespaceId'; ALTER TABLE meta_data ADD namespace_id VARCHAR2(50) NULL; -COMMENT ON COLUMN meta_data.namespace_id IS 'namespaceId'; \ No newline at end of file +COMMENT ON COLUMN meta_data.namespace_id IS 'namespaceId'; + +ALTER TABLE app_auth ADD namespace_id VARCHAR2(50) NULL; +COMMENT ON COLUMN app_auth.namespace_id IS 'namespaceId'; \ No newline at end of file diff --git a/db/init/pg/create-table.sql b/db/init/pg/create-table.sql index bae10afbc3a2..f4a6d4a5b8c5 100644 --- a/db/init/pg/create-table.sql +++ b/db/init/pg/create-table.sql @@ -2798,4 +2798,7 @@ ALTER TABLE "public"."rule" ADD COLUMN namespace_id VARCHAR(50) NULL; COMMENT ON COLUMN "public"."rule"."namespace_id" IS 'namespaceId'; ALTER TABLE "public"."meta_data" ADD COLUMN namespace_id VARCHAR(50) NULL; -COMMENT ON COLUMN "public"."meta_data"."namespace_id" IS 'namespaceId'; \ No newline at end of file +COMMENT ON COLUMN "public"."meta_data"."namespace_id" IS 'namespaceId'; + +ALTER TABLE "public"."app_auth" ADD COLUMN namespace_id VARCHAR(50) NULL; +COMMENT ON COLUMN "public"."app_auth"."namespace_id" IS 'namespaceId'; \ No newline at end of file diff --git a/db/upgrade/2.6.1-upgrade-2.7.0-mysql.sql b/db/upgrade/2.6.1-upgrade-2.7.0-mysql.sql index b83bd1cc78f2..d444a7e21d05 100755 --- a/db/upgrade/2.6.1-upgrade-2.7.0-mysql.sql +++ b/db/upgrade/2.6.1-upgrade-2.7.0-mysql.sql @@ -189,3 +189,8 @@ UPDATE meta_data SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385' WHERE namespace_id IS NULL; +ALTER TABLE `shenyu`.`app_auth` ADD COLUMN `namespace_id` varchar(50) NULL COMMENT 'namespaceId' AFTER `enabled`; + +UPDATE app_auth +SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385' +WHERE namespace_id IS NULL; \ No newline at end of file diff --git a/db/upgrade/2.6.1-upgrade-2.7.0-og.sql b/db/upgrade/2.6.1-upgrade-2.7.0-og.sql index 1ae2f669e541..6231fa87bde7 100644 --- a/db/upgrade/2.6.1-upgrade-2.7.0-og.sql +++ b/db/upgrade/2.6.1-upgrade-2.7.0-og.sql @@ -206,4 +206,10 @@ UPDATE "public"."rule" SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385' ALTER TABLE "public"."meta_data" ADD COLUMN namespace_id VARCHAR(50) NULL; COMMENT ON COLUMN "public"."meta_data"."namespace_id" IS 'namespaceId'; -UPDATE "public"."meta_data" SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385' WHERE namespace_id IS NULL; \ No newline at end of file +UPDATE "public"."meta_data" SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385' WHERE namespace_id IS NULL; + +ALTER TABLE "public"."app_auth" ADD COLUMN namespace_id VARCHAR(50) NULL; +COMMENT ON COLUMN "public"."app_auth"."namespace_id" IS 'namespaceId'; + +UPDATE "public"."app_auth" SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385' WHERE namespace_id IS NULL; + diff --git a/db/upgrade/2.6.1-upgrade-2.7.0-oracle.sql b/db/upgrade/2.6.1-upgrade-2.7.0-oracle.sql index b31e9c814730..6dd02b04a2f7 100755 --- a/db/upgrade/2.6.1-upgrade-2.7.0-oracle.sql +++ b/db/upgrade/2.6.1-upgrade-2.7.0-oracle.sql @@ -232,4 +232,9 @@ UPDATE rule SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385' WHERE name ALTER TABLE meta_data ADD namespace_id VARCHAR2(50) NULL; COMMENT ON COLUMN meta_data.namespace_id IS 'namespaceId'; -UPDATE meta_data SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385' WHERE namespace_id IS NULL; \ No newline at end of file +UPDATE meta_data SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385' WHERE namespace_id IS NULL; + +ALTER TABLE app_auth ADD namespace_id VARCHAR2(50) NULL; +COMMENT ON COLUMN app_auth.namespace_id IS 'namespaceId'; + +UPDATE app_auth SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385' WHERE namespace_id IS NULL; diff --git a/db/upgrade/2.6.1-upgrade-2.7.0-pg.sql b/db/upgrade/2.6.1-upgrade-2.7.0-pg.sql index 55d068f2b537..581459bafbd4 100755 --- a/db/upgrade/2.6.1-upgrade-2.7.0-pg.sql +++ b/db/upgrade/2.6.1-upgrade-2.7.0-pg.sql @@ -207,4 +207,10 @@ UPDATE "public"."rule" SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385' ALTER TABLE "public"."meta_data" ADD COLUMN namespace_id VARCHAR(50) NULL; COMMENT ON COLUMN "public"."meta_data"."namespace_id" IS 'namespaceId'; -UPDATE "public"."meta_data" SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385' WHERE namespace_id IS NULL; \ No newline at end of file +UPDATE "public"."meta_data" SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385' WHERE namespace_id IS NULL; + +ALTER TABLE "public"."app_auth" ADD COLUMN namespace_id VARCHAR(50) NULL; +COMMENT ON COLUMN "public"."app_auth"."namespace_id" IS 'namespaceId'; + +UPDATE "public"."app_auth" SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385' WHERE namespace_id IS NULL; + diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/AppAuthController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/AppAuthController.java index aa85bcff396c..d96d6839c7d0 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/AppAuthController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/AppAuthController.java @@ -21,6 +21,7 @@ import org.apache.shenyu.admin.aspect.annotation.RestApi; import org.apache.shenyu.admin.mapper.AppAuthMapper; import org.apache.shenyu.admin.mapper.AuthPathMapper; +import org.apache.shenyu.admin.mapper.NamespaceMapper; import org.apache.shenyu.admin.model.dto.AppAuthDTO; import org.apache.shenyu.admin.model.dto.AuthApplyDTO; import org.apache.shenyu.admin.model.dto.AuthPathWarpDTO; @@ -96,17 +97,21 @@ public ShenyuAdminResult updateSk(@RequestParam("appKey") * @param phone specific phone * @param currentPage current page of list * @param pageSize page size of query + * @param namespaceId namespaceId * @return the shenyu result */ @GetMapping("/findPageByQuery") @RequiresPermissions("system:authen:list") public ShenyuAdminResult findPageByQuery(final String appKey, final String phone, @RequestParam @NotNull(message = "currentPage not null") final Integer currentPage, - @RequestParam @NotNull(message = "pageSize not null") final Integer pageSize) { + @RequestParam @NotNull(message = "pageSize not null") final Integer pageSize, + @Valid @Existed(message = "namespaceId is not existed", + provider = NamespaceMapper.class) final String namespaceId) { AppAuthQuery query = new AppAuthQuery(); query.setPhone(phone); query.setAppKey(appKey); query.setPageParameter(new PageParameter(currentPage, pageSize)); + query.setNamespaceId(namespaceId); CommonPager commonPager = appAuthService.listByPage(query); return ShenyuAdminResult.success(ShenyuResultMessage.QUERY_SUCCESS, commonPager); } diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/AppAuthDTO.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/AppAuthDTO.java index 0cfdecd2ea38..662b8bf5f6fa 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/AppAuthDTO.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/AppAuthDTO.java @@ -18,6 +18,7 @@ package org.apache.shenyu.admin.model.dto; import org.apache.shenyu.admin.mapper.AppAuthMapper; +import org.apache.shenyu.admin.mapper.NamespaceMapper; import org.apache.shenyu.admin.validation.annotation.Existed; import jakarta.validation.Valid; @@ -75,6 +76,13 @@ public class AppAuthDTO implements Serializable { @Valid private List authPathList; + + /** + * namespaceId. + */ + @NotBlank + @Existed(message = "namespaceId is not existed", provider = NamespaceMapper.class) + private String namespaceId; /** * Gets the value of id. @@ -255,6 +263,24 @@ public List getAuthPathList() { public void setAuthPathList(final List authPathList) { this.authPathList = authPathList; } + + /** + * get namespaceId. + * + * @return namespaceId + */ + public String getNamespaceId() { + return namespaceId; + } + + /** + * set namespaceId. + * + * @param namespaceId namespaceId + */ + public void setNamespaceId(final String namespaceId) { + this.namespaceId = namespaceId; + } @Override public boolean equals(final Object o) { @@ -274,11 +300,12 @@ public boolean equals(final Object o) { && Objects.equals(open, that.open) && Objects.equals(enabled, that.enabled) && Objects.equals(authParamList, that.authParamList) - && Objects.equals(authPathList, that.authPathList); + && Objects.equals(authPathList, that.authPathList) + && Objects.equals(namespaceId, that.namespaceId); } @Override public int hashCode() { - return Objects.hash(id, appKey, appSecret, userId, phone, extInfo, open, enabled, authParamList, authPathList); + return Objects.hash(id, appKey, appSecret, userId, phone, extInfo, open, enabled, authParamList, authPathList, namespaceId); } } diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/AuthApplyDTO.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/AuthApplyDTO.java index 0d42edfa42b9..0c816273c775 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/AuthApplyDTO.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/AuthApplyDTO.java @@ -19,6 +19,9 @@ import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Pattern; +import org.apache.shenyu.admin.mapper.NamespaceMapper; +import org.apache.shenyu.admin.validation.annotation.Existed; + import java.io.Serializable; import java.util.List; import java.util.Objects; @@ -49,6 +52,13 @@ public class AuthApplyDTO implements Serializable { private List pathList; + /** + * namespaceId. + */ + @NotBlank + @Existed(message = "namespaceId is not existed", provider = NamespaceMapper.class) + private String namespaceId; + /** * Gets the value of appKey. * @@ -193,6 +203,24 @@ public void setPathList(final List pathList) { this.pathList = pathList; } + /** + * get namespaceId. + * + * @return namespaceId + */ + public String getNamespaceId() { + return namespaceId; + } + + /** + * set namespaceId. + * + * @param namespaceId namespaceId + */ + public void setNamespaceId(final String namespaceId) { + this.namespaceId = namespaceId; + } + @Override public boolean equals(final Object o) { if (this == o) { @@ -209,11 +237,12 @@ public boolean equals(final Object o) { && Objects.equals(appParam, that.appParam) && Objects.equals(extInfo, that.extInfo) && Objects.equals(open, that.open) - && Objects.equals(pathList, that.pathList); + && Objects.equals(pathList, that.pathList) + && Objects.equals(namespaceId, that.namespaceId); } @Override public int hashCode() { - return Objects.hash(appKey, userId, phone, appName, appParam, extInfo, open, pathList); + return Objects.hash(appKey, userId, phone, appName, appParam, extInfo, open, pathList, namespaceId); } } diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/AuthPathWarpDTO.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/AuthPathWarpDTO.java index 60658e8e073d..238b73dfe803 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/AuthPathWarpDTO.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/AuthPathWarpDTO.java @@ -17,11 +17,11 @@ package org.apache.shenyu.admin.model.dto; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotEmpty; import org.apache.shenyu.admin.mapper.AppAuthMapper; import org.apache.shenyu.admin.validation.annotation.Existed; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotEmpty; import java.io.Serializable; import java.util.List; import java.util.Objects; diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/AppAuthDO.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/AppAuthDO.java index 087757ddbbde..4c050968a7af 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/AppAuthDO.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/AppAuthDO.java @@ -60,10 +60,12 @@ public final class AppAuthDO extends BaseDO { private String extInfo; + private String namespaceId; + public AppAuthDO() { } - public AppAuthDO(final String appKey, final String appSecret, final Boolean enabled, final Boolean open, final String userId, final String phone, final String extInfo) { + public AppAuthDO(final String appKey, final String appSecret, final Boolean enabled, final Boolean open, final String userId, final String phone, final String extInfo, final String namespaceId) { this.appKey = appKey; this.appSecret = appSecret; this.enabled = enabled; @@ -71,6 +73,7 @@ public AppAuthDO(final String appKey, final String appSecret, final Boolean enab this.userId = userId; this.phone = phone; this.extInfo = extInfo; + this.namespaceId = namespaceId; } /** @@ -199,6 +202,24 @@ public void setExtInfo(final String extInfo) { this.extInfo = extInfo; } + /** + * get namespaceId. + * + * @return namespaceId + */ + public String getNamespaceId() { + return namespaceId; + } + + /** + * set namespaceId. + * + * @param namespaceId namespaceId + */ + public void setNamespaceId(final String namespaceId) { + this.namespaceId = namespaceId; + } + /** * Build AppAuthDO object with given AppAuthDTO object. * @@ -243,6 +264,7 @@ public static AppAuthDO create(final AuthApplyDTO authApplyDTO) { .appSecret(SignUtils.generateKey()) .open(item.getOpen()) .enabled(true) + .namespaceId(item.getNamespaceId()) .dateCreated(currentTime) .dateUpdated(currentTime) .build(); @@ -276,12 +298,13 @@ public boolean equals(final Object o) { && open.equals(appAuthDO.open) && userId.equals(appAuthDO.userId) && phone.equals(appAuthDO.phone) - && extInfo.equals(appAuthDO.extInfo); + && extInfo.equals(appAuthDO.extInfo) + && namespaceId.equals(appAuthDO.namespaceId); } @Override public int hashCode() { - return Objects.hash(appKey, appSecret, enabled, open, userId, phone, extInfo); + return Objects.hash(appKey, appSecret, enabled, open, userId, phone, extInfo, namespaceId); } public static final class AppAuthDOBuilder { @@ -302,6 +325,8 @@ public static final class AppAuthDOBuilder { private String id; + private String namespaceId; + private Timestamp dateCreated; private Timestamp dateUpdated; @@ -397,6 +422,17 @@ public AppAuthDOBuilder id(final String id) { return this; } + /** + * namespaceId. + * + * @param namespaceId namespaceId + * @return AppAuthDOBuilder + */ + public AppAuthDOBuilder namespaceId(final String namespaceId) { + this.namespaceId = namespaceId; + return this; + } + /** * dateCreated. * @@ -436,6 +472,7 @@ public AppAuthDO build() { appAuthDO.setId(id); appAuthDO.setDateCreated(dateCreated); appAuthDO.setDateUpdated(dateUpdated); + appAuthDO.setNamespaceId(namespaceId); return appAuthDO; } } diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/query/AppAuthQuery.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/query/AppAuthQuery.java index 6abbbb969233..0b69b23aa2a2 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/query/AppAuthQuery.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/query/AppAuthQuery.java @@ -44,13 +44,19 @@ public class AppAuthQuery implements Serializable { */ private PageParameter pageParameter; + /** + * namespace id. + */ + private String namespaceId; + public AppAuthQuery() { } - public AppAuthQuery(final String appKey, final String phone, final PageParameter pageParameter) { + public AppAuthQuery(final String appKey, final String phone, final PageParameter pageParameter, final String namespaceId) { this.appKey = appKey; this.phone = phone; this.pageParameter = pageParameter; + this.namespaceId = namespaceId; } /** @@ -107,6 +113,24 @@ public void setPageParameter(final PageParameter pageParameter) { this.pageParameter = pageParameter; } + /** + * Gets the value of name. + * + * @return the value of name + */ + public String getNamespaceId() { + return namespaceId; + } + + /** + * Sets the namespaceId. + * + * @param namespaceId namespaceId + */ + public void setNamespaceId(final String namespaceId) { + this.namespaceId = namespaceId; + } + @Override public boolean equals(final Object o) { if (this == o) { @@ -116,11 +140,12 @@ public boolean equals(final Object o) { return false; } AppAuthQuery that = (AppAuthQuery) o; - return Objects.equals(appKey, that.appKey) && Objects.equals(phone, that.phone) && Objects.equals(pageParameter, that.pageParameter); + return Objects.equals(appKey, that.appKey) && Objects.equals(phone, that.phone) && Objects.equals(pageParameter, that.pageParameter) + && Objects.equals(namespaceId, that.namespaceId); } @Override public int hashCode() { - return Objects.hash(appKey, phone, pageParameter); + return Objects.hash(appKey, phone, pageParameter, namespaceId); } } diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/AppAuthVO.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/AppAuthVO.java index ca34670e2390..4aae4b0d81ec 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/AppAuthVO.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/AppAuthVO.java @@ -62,6 +62,8 @@ public class AppAuthVO implements Serializable { private List authPathList; + private String namespaceId; + /** * updated time. */ @@ -274,6 +276,24 @@ public void setAuthPathList(final List authPathList) { this.authPathList = authPathList; } + /** + * get namespaceId. + * + * @return namespaceId + */ + public String getNamespaceId() { + return namespaceId; + } + + /** + * set namespaceId. + * + * @param namespaceId namespaceId + */ + public void setNamespaceId(final String namespaceId) { + this.namespaceId = namespaceId; + } + /** * Gets the value of dateUpdated. * diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/AppAuthServiceImpl.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/AppAuthServiceImpl.java index 36bc10cfb394..b1f780fe1c02 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/AppAuthServiceImpl.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/AppAuthServiceImpl.java @@ -117,6 +117,7 @@ public ShenyuAdminResult applyCreate(final AuthApplyDTO authApplyDTO) { .appSecret(appAuthDO.getAppSecret()) .open(appAuthDO.getOpen()) .enabled(appAuthDO.getEnabled()) + .namespaceId(appAuthDO.getNamespaceId()) .paramDataList(Lists.newArrayList(new AuthParamData(authParamDO.getAppName(), authParamDO.getAppParam()))) .build(); @@ -546,6 +547,7 @@ private AppAuthData buildByEntity(final AppAuthDO appAuthDO) { .appSecret(appAuthDO.getAppSecret()) .open(appAuthDO.getOpen()) .enabled(appAuthDO.getEnabled()) + .namespaceId(appAuthDO.getNamespaceId()) .build(); List authParamDOList = authParamMapper.findByAuthId(appAuthDO.getId()); if (CollectionUtils.isNotEmpty(authParamDOList)) { @@ -571,6 +573,7 @@ private AppAuthData buildByEntityWithParamAndPath(final AppAuthDO appAuthDO, fin .appSecret(appAuthDO.getAppSecret()) .open(appAuthDO.getOpen()) .enabled(appAuthDO.getEnabled()) + .namespaceId(appAuthDO.getNamespaceId()) .build(); if (CollectionUtils.isNotEmpty(authParamDataList)) { data.setParamDataList(authParamDataList); diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/transfer/AppAuthTransfer.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/transfer/AppAuthTransfer.java index 915aab49214b..f49c93b04a29 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/transfer/AppAuthTransfer.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/transfer/AppAuthTransfer.java @@ -56,6 +56,7 @@ public AppAuthDO mapToEntity(final AppAuthDTO appAuthDTO) { appAuthDO.userId(v.getUserId()); appAuthDO.phone(v.getPhone()); appAuthDO.extInfo(v.getExtInfo()); + appAuthDO.namespaceId(v.getNamespaceId()); return appAuthDO.build(); }) .orElse(null); @@ -79,6 +80,7 @@ public AppAuthVO mapToVO(final AppAuthDO appAuthDO) { appAuthVO.setExtInfo(v.getExtInfo()); appAuthVO.setOpen(v.getOpen()); appAuthVO.setEnabled(appAuthDO.getEnabled()); + appAuthVO.setNamespaceId(appAuthDO.getNamespaceId()); appAuthVO.setDateUpdated(Optional.ofNullable(appAuthDO.getDateUpdated()) .map(u -> DateUtils.localDateTimeToString(u.toLocalDateTime())) .orElse(null)); diff --git a/shenyu-admin/src/main/resources/application-mysql.yml b/shenyu-admin/src/main/resources/application-mysql.yml index ec2d602b2d19..cb9f4e0db0ab 100755 --- a/shenyu-admin/src/main/resources/application-mysql.yml +++ b/shenyu-admin/src/main/resources/application-mysql.yml @@ -22,7 +22,7 @@ spring: datasource: url: jdbc:mysql://localhost:3306/shenyu?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull username: root - password: 12345678 + password: 123 driver-class-name: com.mysql.cj.jdbc.Driver hikari: connection-timeout: 30000 diff --git a/shenyu-admin/src/main/resources/application.yml b/shenyu-admin/src/main/resources/application.yml index dd8bbdef7bcc..bab1b3de2779 100755 --- a/shenyu-admin/src/main/resources/application.yml +++ b/shenyu-admin/src/main/resources/application.yml @@ -19,7 +19,7 @@ server: spring: profiles: - active: h2 + active: mysql thymeleaf: cache: true encoding: utf-8 diff --git a/shenyu-admin/src/main/resources/mappers/app-auth-sqlmap.xml b/shenyu-admin/src/main/resources/mappers/app-auth-sqlmap.xml index 32d08a8b2d91..2df1f1a83ced 100644 --- a/shenyu-admin/src/main/resources/mappers/app-auth-sqlmap.xml +++ b/shenyu-admin/src/main/resources/mappers/app-auth-sqlmap.xml @@ -37,7 +37,9 @@ app_secret,user_id, phone, ext_info, - open,enabled, + open, + enabled, + namespace_id, date_created, date_updated @@ -85,6 +87,7 @@ FROM app_auth + namespace_id = #{namespaceId, jdbcType=VARCHAR} AND app_key = #{appKey, jdbcType=VARCHAR} @@ -98,6 +101,7 @@ SELECT count(1) FROM app_auth + namespace_id = #{namespaceId, jdbcType=VARCHAR} AND app_key = #{appKey, jdbcType=VARCHAR} @@ -137,6 +141,7 @@ ext_info, open, enabled, + namespace_id, date_created, date_updated) VALUES @@ -148,6 +153,7 @@ #{extInfo, jdbcType=VARCHAR}, #{open, jdbcType=TINYINT}, #{enabled, jdbcType=TINYINT}, + #{namespaceId, jdbcType=VARCHAR}, #{dateCreated, jdbcType=TIMESTAMP}, #{dateUpdated, jdbcType=TIMESTAMP}) @@ -227,6 +233,7 @@ open = #{open, jdbcType=TINYINT}, enabled = #{enabled, jdbcType=TINYINT} WHERE id = #{id, jdbcType=VARCHAR} + AND namespace_id = #{namespaceId, jdbcType=VARCHAR} diff --git a/shenyu-admin/src/main/resources/sql-script/h2/schema.sql b/shenyu-admin/src/main/resources/sql-script/h2/schema.sql index 0803c80123fc..3c8a0da2c7ce 100755 --- a/shenyu-admin/src/main/resources/sql-script/h2/schema.sql +++ b/shenyu-admin/src/main/resources/sql-script/h2/schema.sql @@ -1346,4 +1346,6 @@ ALTER TABLE `selector` ADD COLUMN `namespace_id` varchar(50) NULL COMMENT 'names ALTER TABLE `rule` ADD COLUMN `namespace_id` varchar(50) NULL COMMENT 'namespaceId' AFTER `match_restful`; -ALTER TABLE `meta_data` ADD COLUMN `namespace_id` varchar(50) NULL COMMENT 'namespaceId' ; \ No newline at end of file +ALTER TABLE `meta_data` ADD COLUMN `namespace_id` varchar(50) NULL COMMENT 'namespaceId' ; + +ALTER TABLE `app_auth` ADD COLUMN `namespace_id` varchar(50) NULL COMMENT 'namespaceId' ; \ No newline at end of file diff --git a/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/AppAuthControllerTest.java b/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/AppAuthControllerTest.java index 039441e76da0..1f7e9bfd7910 100644 --- a/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/AppAuthControllerTest.java +++ b/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/AppAuthControllerTest.java @@ -61,6 +61,7 @@ import java.util.Collections; import java.util.List; +import static org.apache.shenyu.common.constant.Constants.SYS_DEFAULT_NAMESPACE_ID; import static org.hamcrest.core.Is.is; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; @@ -183,7 +184,7 @@ public void testUpdateSk() throws Exception { @Test public void testFindPageByQuery() throws Exception { final PageParameter pageParameter = new PageParameter(); - final AppAuthQuery appAuthQuery = new AppAuthQuery("testAppKey", "18600000000", pageParameter); + final AppAuthQuery appAuthQuery = new AppAuthQuery("testAppKey", "18600000000", pageParameter, SYS_DEFAULT_NAMESPACE_ID); final CommonPager commonPager = new CommonPager<>(pageParameter, Collections.singletonList(appAuthVO)); given(this.appAuthService.listByPage(appAuthQuery)).willReturn(commonPager); this.mockMvc.perform(MockMvcRequestBuilders.get("/appAuth/findPageByQuery") diff --git a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/AppAuthData.java b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/AppAuthData.java index e3ab6b321315..6b753d343530 100644 --- a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/AppAuthData.java +++ b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/AppAuthData.java @@ -39,6 +39,8 @@ public class AppAuthData { private List pathDataList; + private String namespaceId; + /** * no args constructor. */ @@ -57,6 +59,7 @@ private AppAuthData(final Builder builder) { this.open = builder.open; this.paramDataList = builder.paramDataList; this.pathDataList = builder.pathDataList; + this.namespaceId = builder.namespaceId; } /** @@ -176,6 +179,24 @@ public void setPathDataList(final List pathDataList) { this.pathDataList = pathDataList; } + /** + * get namespaceId. + * + * @return namespaceId + */ + public String getNamespaceId() { + return namespaceId; + } + + /** + * set namespaceId. + * + * @param namespaceId namespaceId + */ + public void setNamespaceId(final String namespaceId) { + this.namespaceId = namespaceId; + } + @Override public boolean equals(final Object o) { if (this == o) { @@ -186,12 +207,13 @@ public boolean equals(final Object o) { } AppAuthData that = (AppAuthData) o; return Objects.equals(appKey, that.appKey) && Objects.equals(appSecret, that.appSecret) && Objects.equals(enabled, that.enabled) - && Objects.equals(open, that.open) && Objects.equals(paramDataList, that.paramDataList) && Objects.equals(pathDataList, that.pathDataList); + && Objects.equals(open, that.open) && Objects.equals(paramDataList, that.paramDataList) && Objects.equals(pathDataList, that.pathDataList) + && Objects.equals(namespaceId, that.namespaceId); } @Override public int hashCode() { - return Objects.hash(appKey, appSecret, enabled, open, paramDataList, pathDataList); + return Objects.hash(appKey, appSecret, enabled, open, paramDataList, pathDataList, namespaceId); } @Override @@ -211,6 +233,8 @@ public String toString() { + paramDataList + ", pathDataList=" + pathDataList + + ", namespaceId=" + + namespaceId + '}'; } @@ -249,6 +273,11 @@ public static final class Builder { */ private List pathDataList; + /** + * namespaceId. + */ + private String namespaceId; + /** * no args constructor. */ @@ -329,5 +358,16 @@ public Builder pathDataList(final List pathDataList) { this.pathDataList = pathDataList; return this; } + + /** + * namespaceId. + * + * @param namespaceId namespaceId + * @return this + */ + public Builder namespaceId(final String namespaceId) { + this.namespaceId = namespaceId; + return this; + } } } diff --git a/shenyu-examples/shenyu-examples-http/src/main/resources/application.yml b/shenyu-examples/shenyu-examples-http/src/main/resources/application.yml index e1bd53dc1f05..3bd8d2600f7a 100644 --- a/shenyu-examples/shenyu-examples-http/src/main/resources/application.yml +++ b/shenyu-examples/shenyu-examples-http/src/main/resources/application.yml @@ -32,7 +32,7 @@ shenyu: props: contextPath: /http appName: http - # port: 8189 + port: 8189 # discovery: # enable: true # protocol: http:// # https:// From 6a746404e606b5c32408a6f966ec28f4011fcd80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=98xcsnx=E2=80=99?= <‘1192709687@qq.com’> Date: Sat, 21 Sep 2024 00:44:16 +0800 Subject: [PATCH 2/4] reset --- shenyu-admin/src/main/resources/application-mysql.yml | 2 +- shenyu-admin/src/main/resources/application.yml | 2 +- .../shenyu-examples-http/src/main/resources/application.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/shenyu-admin/src/main/resources/application-mysql.yml b/shenyu-admin/src/main/resources/application-mysql.yml index cb9f4e0db0ab..ec2d602b2d19 100755 --- a/shenyu-admin/src/main/resources/application-mysql.yml +++ b/shenyu-admin/src/main/resources/application-mysql.yml @@ -22,7 +22,7 @@ spring: datasource: url: jdbc:mysql://localhost:3306/shenyu?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull username: root - password: 123 + password: 12345678 driver-class-name: com.mysql.cj.jdbc.Driver hikari: connection-timeout: 30000 diff --git a/shenyu-admin/src/main/resources/application.yml b/shenyu-admin/src/main/resources/application.yml index bab1b3de2779..dd8bbdef7bcc 100755 --- a/shenyu-admin/src/main/resources/application.yml +++ b/shenyu-admin/src/main/resources/application.yml @@ -19,7 +19,7 @@ server: spring: profiles: - active: mysql + active: h2 thymeleaf: cache: true encoding: utf-8 diff --git a/shenyu-examples/shenyu-examples-http/src/main/resources/application.yml b/shenyu-examples/shenyu-examples-http/src/main/resources/application.yml index 3bd8d2600f7a..e1bd53dc1f05 100644 --- a/shenyu-examples/shenyu-examples-http/src/main/resources/application.yml +++ b/shenyu-examples/shenyu-examples-http/src/main/resources/application.yml @@ -32,7 +32,7 @@ shenyu: props: contextPath: /http appName: http - port: 8189 + # port: 8189 # discovery: # enable: true # protocol: http:// # https:// From baa6f8101b4ade6ed5c3f78bf7c12bc67e596805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=98xcsnx=E2=80=99?= <‘1192709687@qq.com’> Date: Sat, 21 Sep 2024 10:56:16 +0800 Subject: [PATCH 3/4] fix cr --- .../resources/mappers/app-auth-sqlmap.xml | 4 +++- .../controller/AppAuthControllerTest.java | 21 ++++++++++++++++++- .../admin/mapper/AppAuthMapperTest.java | 4 ++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/shenyu-admin/src/main/resources/mappers/app-auth-sqlmap.xml b/shenyu-admin/src/main/resources/mappers/app-auth-sqlmap.xml index 2df1f1a83ced..6c8e17d79b31 100644 --- a/shenyu-admin/src/main/resources/mappers/app-auth-sqlmap.xml +++ b/shenyu-admin/src/main/resources/mappers/app-auth-sqlmap.xml @@ -87,7 +87,9 @@ FROM app_auth - namespace_id = #{namespaceId, jdbcType=VARCHAR} + + AND namespace_id = #{namespaceId, jdbcType=VARCHAR} + AND app_key = #{appKey, jdbcType=VARCHAR} diff --git a/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/AppAuthControllerTest.java b/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/AppAuthControllerTest.java index 1f7e9bfd7910..ba2d4356524b 100644 --- a/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/AppAuthControllerTest.java +++ b/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/AppAuthControllerTest.java @@ -21,6 +21,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.shenyu.admin.mapper.AppAuthMapper; import org.apache.shenyu.admin.mapper.AuthPathMapper; +import org.apache.shenyu.admin.mapper.NamespaceMapper; import org.apache.shenyu.admin.model.dto.AppAuthDTO; import org.apache.shenyu.admin.model.dto.AuthApplyDTO; import org.apache.shenyu.admin.model.dto.AuthPathDTO; @@ -90,6 +91,9 @@ public final class AppAuthControllerTest { @Mock private AppAuthMapper appAuthMapper; + @Mock + private NamespaceMapper namespaceMapper; + private final AppAuthVO appAuthVO = new AppAuthVO("0001", "testAppKey", "testAppSecret", "testUser", "18600000000", "{\"extInfo\": \"test\"}", true, true, null, null, @@ -139,8 +143,12 @@ public void testApply() throws Exception { authApplyDTO.setExtInfo("{\"extInfo\": \"test\"}"); authApplyDTO.setOpen(true); authApplyDTO.setPathList(pathList); + authApplyDTO.setNamespaceId(SYS_DEFAULT_NAMESPACE_ID); given(this.appAuthService.applyCreate(authApplyDTO)).willReturn( ShenyuAdminResult.success(ShenyuResultMessage.CREATE_SUCCESS)); + SpringBeanUtils.getInstance().setApplicationContext(mock(ConfigurableApplicationContext.class)); + when(SpringBeanUtils.getInstance().getBean(NamespaceMapper.class)).thenReturn(namespaceMapper); + when(namespaceMapper.existed(SYS_DEFAULT_NAMESPACE_ID)).thenReturn(true); this.mockMvc.perform(MockMvcRequestBuilders.post("/appAuth/apply") .contentType(MediaType.APPLICATION_JSON) .content(GsonUtils.getInstance().toJson(authApplyDTO))) @@ -162,6 +170,10 @@ public void testApplyWithAppKey() throws Exception { authApplyDTO.setExtInfo("{\"extInfo\": \"test\"}"); authApplyDTO.setOpen(true); authApplyDTO.setPathList(pathList); + authApplyDTO.setNamespaceId(SYS_DEFAULT_NAMESPACE_ID); + SpringBeanUtils.getInstance().setApplicationContext(mock(ConfigurableApplicationContext.class)); + when(SpringBeanUtils.getInstance().getBean(NamespaceMapper.class)).thenReturn(namespaceMapper); + when(namespaceMapper.existed(SYS_DEFAULT_NAMESPACE_ID)).thenReturn(true); given(this.appAuthService.applyUpdate(authApplyDTO)).willReturn( ShenyuAdminResult.success(ShenyuResultMessage.CREATE_SUCCESS)); this.mockMvc.perform(MockMvcRequestBuilders.post("/appAuth/apply") @@ -187,11 +199,15 @@ public void testFindPageByQuery() throws Exception { final AppAuthQuery appAuthQuery = new AppAuthQuery("testAppKey", "18600000000", pageParameter, SYS_DEFAULT_NAMESPACE_ID); final CommonPager commonPager = new CommonPager<>(pageParameter, Collections.singletonList(appAuthVO)); given(this.appAuthService.listByPage(appAuthQuery)).willReturn(commonPager); + SpringBeanUtils.getInstance().setApplicationContext(mock(ConfigurableApplicationContext.class)); + when(SpringBeanUtils.getInstance().getBean(NamespaceMapper.class)).thenReturn(namespaceMapper); + when(namespaceMapper.existed(SYS_DEFAULT_NAMESPACE_ID)).thenReturn(true); this.mockMvc.perform(MockMvcRequestBuilders.get("/appAuth/findPageByQuery") .param("appKey", "testAppKey") .param("phone", "18600000000") .param("currentPage", String.valueOf(pageParameter.getCurrentPage())) - .param("pageSize", String.valueOf(pageParameter.getPageSize()))) + .param("pageSize", String.valueOf(pageParameter.getPageSize())) + .param("namespaceId",SYS_DEFAULT_NAMESPACE_ID)) .andExpect(status().isOk()) .andExpect(jsonPath("$.message", is(ShenyuResultMessage.QUERY_SUCCESS))) .andExpect(jsonPath("$.data.dataList[0].appKey", is(appAuthVO.getAppKey()))) @@ -216,12 +232,15 @@ public void testUpdateDetail() throws Exception { appAuthDTO.setAppKey("app key"); appAuthDTO.setAppSecret("app secret"); appAuthDTO.setPhone("1234567"); + appAuthDTO.setNamespaceId(SYS_DEFAULT_NAMESPACE_ID); given(this.appAuthService.updateDetail(appAuthDTO)).willReturn( ShenyuAdminResult.success(ShenyuResultMessage.UPDATE_SUCCESS)); ConfigurableApplicationContext context = mock(ConfigurableApplicationContext.class); SpringBeanUtils.getInstance().setApplicationContext(context); when(SpringBeanUtils.getInstance().getBean(AppAuthMapper.class)).thenReturn(appAuthMapper); when(appAuthMapper.existed(appAuthDTO.getId())).thenReturn(true); + when(SpringBeanUtils.getInstance().getBean(NamespaceMapper.class)).thenReturn(namespaceMapper); + when(namespaceMapper.existed(SYS_DEFAULT_NAMESPACE_ID)).thenReturn(true); this.mockMvc.perform(MockMvcRequestBuilders.post("/appAuth/updateDetail") .contentType(MediaType.APPLICATION_JSON) .content(GsonUtils.getInstance().toJson(appAuthDTO))) diff --git a/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/AppAuthMapperTest.java b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/AppAuthMapperTest.java index f1c68ff7d4b0..c288e0b82018 100644 --- a/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/AppAuthMapperTest.java +++ b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/AppAuthMapperTest.java @@ -29,6 +29,7 @@ import java.sql.Timestamp; import java.util.List; +import static org.apache.shenyu.common.constant.Constants.SYS_DEFAULT_NAMESPACE_ID; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.greaterThan; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -66,6 +67,7 @@ public void testSelectById() { @Test public void testByQuery() { AppAuthQuery appAuthQuery = new AppAuthQuery(); + appAuthQuery.setNamespaceId(SYS_DEFAULT_NAMESPACE_ID); List appAuthDOsWithQuery = appAuthMapper.selectByQuery(appAuthQuery); assertThat(appAuthDOsWithQuery.size(), greaterThan(0)); @@ -90,6 +92,7 @@ public void testCountByQuery() { AppAuthQuery appAuthQuery = new AppAuthQuery(); appAuthQuery.setPhone(appAuthDO.getPhone()); appAuthQuery.setAppKey(appAuthDO.getAppKey()); + appAuthQuery.setNamespaceId(SYS_DEFAULT_NAMESPACE_ID); int count = appAuthMapper.countByQuery(appAuthQuery); assertEquals(1, count); } @@ -145,6 +148,7 @@ private AppAuthDO buildAppAuthDO() { .enabled(false) .phone("18800000000") .userId(UUIDUtils.getInstance().generateShortUuid()) + .namespaceId(SYS_DEFAULT_NAMESPACE_ID) .dateCreated(now) .dateUpdated(now) .build(); From 93e9a39bf86b662d77bc47aa6d929ab13374cb54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=98xcsnx=E2=80=99?= <‘1192709687@qq.com’> Date: Sat, 21 Sep 2024 11:14:10 +0800 Subject: [PATCH 4/4] fix --- .../apache/shenyu/admin/controller/AppAuthControllerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/AppAuthControllerTest.java b/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/AppAuthControllerTest.java index ba2d4356524b..14244f643b0c 100644 --- a/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/AppAuthControllerTest.java +++ b/shenyu-admin/src/test/java/org/apache/shenyu/admin/controller/AppAuthControllerTest.java @@ -207,7 +207,7 @@ public void testFindPageByQuery() throws Exception { .param("phone", "18600000000") .param("currentPage", String.valueOf(pageParameter.getCurrentPage())) .param("pageSize", String.valueOf(pageParameter.getPageSize())) - .param("namespaceId",SYS_DEFAULT_NAMESPACE_ID)) + .param("namespaceId", SYS_DEFAULT_NAMESPACE_ID)) .andExpect(status().isOk()) .andExpect(jsonPath("$.message", is(ShenyuResultMessage.QUERY_SUCCESS))) .andExpect(jsonPath("$.data.dataList[0].appKey", is(appAuthVO.getAppKey())))