This is an automated email from the ASF dual-hosted git repository.
hefengen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 9a3b741237 New API: supports batch modification of PathAuth status
(#5488)
9a3b741237 is described below
commit 9a3b741237852da0abf7bce184c01f85faf9bb95
Author: Kerwin Bryant <[email protected]>
AuthorDate: Thu Mar 21 14:20:45 2024 +0800
New API: supports batch modification of PathAuth status (#5488)
* New API: supports batch modification of PathAuth status
* change name of method
* Fixed incorrect resource name references
---------
Co-authored-by: moremind <[email protected]>
---
db/init/mysql/schema.sql | 4 +-
db/init/og/create-table.sql | 2 +
db/init/oracle/schema.sql | 2 +
db/init/pg/create-table.sql | 2 +
db/upgrade/2.6.1-upgrade-2.7.0-mysql.sql | 3 ++
db/upgrade/2.6.1-upgrade-2.7.0-og.sql | 3 ++
db/upgrade/2.6.1-upgrade-2.7.0-oracle.sql | 3 ++
db/upgrade/2.6.1-upgrade-2.7.0-pg.sql | 3 ++
.../shenyu/admin/controller/AppAuthController.java | 42 +++++++++++++------
.../apache/shenyu/admin/mapper/AppAuthMapper.java | 47 +++++++++++++---------
.../shenyu/admin/service/AppAuthService.java | 10 +++++
.../admin/service/impl/AppAuthServiceImpl.java | 27 +++++++++++++
.../src/main/resources/mappers/app-auth-sqlmap.xml | 9 +++++
.../src/main/resources/sql-script/h2/schema.sql | 4 +-
.../admin/controller/AppAuthControllerTest.java | 34 +++++++++++++++-
.../shenyu/admin/service/AppAuthServiceTest.java | 14 +++++++
16 files changed, 173 insertions(+), 36 deletions(-)
diff --git a/db/init/mysql/schema.sql b/db/init/mysql/schema.sql
index 2470d058f7..b47e665791 100644
--- a/db/init/mysql/schema.sql
+++ b/db/init/mysql/schema.sql
@@ -369,6 +369,7 @@ INSERT INTO `permission` VALUES ('1351007708736266240',
'1346358560427216896', '
INSERT INTO `permission` VALUES ('1351007708740460544', '1346358560427216896',
'1347048004105940992', '2022-05-25 18:02:53', '2022-05-25 18:02:53');
INSERT INTO `permission` VALUES ('1351007708744654848', '1346358560427216896',
'1347048101875167232', '2022-05-25 18:02:53', '2022-05-25 18:02:53');
INSERT INTO `permission` VALUES ('1351007708744654849', '1346358560427216896',
'1347048145877610496', '2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `permission` VALUES ('1351007708748849151', '1346358560427216896',
'1347048240677269503', '2022-05-25 18:02:53', '2022-05-25 18:02:53');
INSERT INTO `permission` VALUES ('1351007708748849152', '1346358560427216896',
'1347048240677269504', '2022-05-25 18:02:53', '2022-05-25 18:02:53');
INSERT INTO `permission` VALUES ('1351007708753043456', '1346358560427216896',
'1347048316216684544', '2022-05-25 18:02:53', '2022-05-25 18:02:53');
INSERT INTO `permission` VALUES ('1351007708757237760', '1346358560427216896',
'1347048776029843456', '2022-05-25 18:02:53', '2022-05-25 18:02:53');
@@ -839,7 +840,7 @@ INSERT INTO `plugin` VALUES ('42', 'tcp', NULL, 'Proxy',
320, 1, '2023-05-30 18:
INSERT INTO `plugin` VALUES ('43', 'loggingHuaweiLts',
'{\"totalSizeInBytes\":\"104857600\",\"maxBlockMs\":\"0\",\"ioThreadCount\":\"1\",\"batchSizeThresholdInBytes\":\"524288\",\"batchCountThreshold\":\"4096\",\"lingerMs\":\"2000\",\"retries\":\"100\",\"baseRetryBackoffMs\":\"100\",\"maxRetryBackoffMs\":\"100\",\"enableLocalTest\":\"true\",\"setGiveUpExtraLongSingleLog\":\"false\"}',
'Logging', 177, 0, '2023-07-05 14:03:53.686', '2023-07-06 12:42:07.234', NULL);
INSERT INTO `plugin` VALUES ('44', 'basicAuth',
'{\"defaultHandleJson\":\"{\\\"authorization\\\":\\\"test:test123\\\"}\"}',
'Authentication', 150, 0, '2022-07-24 19:00:00', '2022-07-24 19:00:00', null);
INSERT INTO `plugin` VALUES ('45', 'loggingRabbitMQ',
'{\"host\":\"127.0.0.1\",\"port\":5672,\"password\":\"admin\",\"username\":\"admin\",\"exchangeName\":\"exchange.logging.plugin\",\"queueName\":\"queue.logging.plugin\",\"routingKey\":\"topic.logging\",\"virtualHost\":\"/\",\"exchangeType\":\"direct\",\"durable\":\"true\",\"exclusive\":\"false\",\"autoDelete\":\"false\"}',
'Logging', 171, 0, '2023-11-06 15:49:56.454', '2023-11-10 10:40:58.447', NULL);
-
+
-- ----------------------------
-- Table structure for plugin_handle
-- ----------------------------
@@ -1257,6 +1258,7 @@ INSERT INTO `resource` VALUES ('1347047747305484288',
'1346777623011880960', 'SH
INSERT INTO `resource` VALUES ('1347048004105940992', '1346777766301888512',
'SHENYU.BUTTON.SYSTEM.LIST', '', '', '', 2, 0, '', 1, 0, 'system:authen:list',
1, '2022-05-25 18:02:53', '2022-05-25 18:02:53');
INSERT INTO `resource` VALUES ('1347048101875167232', '1346777766301888512',
'SHENYU.BUTTON.SYSTEM.DELETE', '', '', '', 2, 1, '', 1, 0,
'system:authen:delete', 1, '2022-05-25 18:02:53', '2022-05-25 18:02:53');
INSERT INTO `resource` VALUES ('1347048145877610496', '1346777766301888512',
'SHENYU.BUTTON.SYSTEM.ADD', '', '', '', 2, 2, '', 1, 0, 'system:authen:add', 1,
'2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `resource` VALUES ('1347048240677269503', '1346777766301888512',
'SHENYU.PLUGIN.BATCH.OPENED', '', '', '', 2, 3, '', 1, 0, 'system:authen:open',
1, '2022-05-25 18:02:53', '2022-05-25 18:02:53');
INSERT INTO `resource` VALUES ('1347048240677269504', '1346777766301888512',
'SHENYU.BUTTON.SYSTEM.ENABLE', '', '', '', 2, 3, '', 1, 0,
'system:authen:disable', 1, '2022-05-25 18:02:53', '2022-05-25 18:02:53');
INSERT INTO `resource` VALUES ('1347048316216684544', '1346777766301888512',
'SHENYU.BUTTON.SYSTEM.SYNCHRONIZE', '', '', '', 2, 4, '', 1, 0,
'system:authen:modify', 1, '2022-05-25 18:02:53', '2022-05-25 18:02:53');
INSERT INTO `resource` VALUES ('1347048776029843456', '1346777766301888512',
'SHENYU.BUTTON.SYSTEM.EDIT', '', '', '', 2, 5, '', 1, 0, 'system:authen:edit',
1, '2022-05-25 18:02:53', '2022-05-25 18:02:53');
diff --git a/db/init/og/create-table.sql b/db/init/og/create-table.sql
index 13ad474795..c50f5f0c62 100644
--- a/db/init/og/create-table.sql
+++ b/db/init/og/create-table.sql
@@ -490,6 +490,7 @@ INSERT INTO "public"."permission" VALUES
('1351007708740460544', '13463585604272
INSERT INTO "public"."permission" VALUES ('1351007708614631424',
'1346358560427216896', '1346777907096285184', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
INSERT INTO "public"."permission" VALUES ('1351007708744654848',
'1346358560427216896', '1347048101875167232', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
INSERT INTO "public"."permission" VALUES ('1351007708744654849',
'1346358560427216896', '1347048145877610496', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
+INSERT INTO "public"."permission" VALUES ('1351007708748849151',
'1346358560427216896', '1347048240677269503', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
INSERT INTO "public"."permission" VALUES ('1351007708748849152',
'1346358560427216896', '1347048240677269504', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
INSERT INTO "public"."permission" VALUES ('1351007708753043456',
'1346358560427216896', '1347048316216684544', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
INSERT INTO "public"."permission" VALUES ('1351007708757237760',
'1346358560427216896', '1347048776029843456', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
@@ -1420,6 +1421,7 @@ INSERT INTO "public"."resource" VALUES
('1347047747305484288', '1346777623011880
INSERT INTO "public"."resource" VALUES ('1347048004105940992',
'1346777766301888512', 'SHENYU.BUTTON.SYSTEM.LIST', '', '', '', 2, 0, '', 1, 0,
'system:authen:list', 1, '2022-05-25 18:08:01', '2022-05-25 18:08:01');
INSERT INTO "public"."resource" VALUES ('1347048101875167232',
'1346777766301888512', 'SHENYU.BUTTON.SYSTEM.DELETE', '', '', '', 2, 1, '', 1,
0, 'system:authen:delete', 1, '2022-05-25 18:08:01', '2022-05-25 18:08:01');
INSERT INTO "public"."resource" VALUES ('1347048145877610496',
'1346777766301888512', 'SHENYU.BUTTON.SYSTEM.ADD', '', '', '', 2, 2, '', 1, 0,
'system:authen:add', 1, '2022-05-25 18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."resource" VALUES ('1347048240677269503',
'1346777766301888512', 'SHENYU.PLUGIN.BATCH.OPENED', '', '', '', 2, 3, '', 1,
0, 'system:authen:open', 1, '2022-05-25 18:08:01', '2022-05-25 18:08:01');
INSERT INTO "public"."resource" VALUES ('1347048240677269504',
'1346777766301888512', 'SHENYU.BUTTON.SYSTEM.ENABLE', '', '', '', 2, 3, '', 1,
0, 'system:authen:disable', 1, '2022-05-25 18:08:01', '2022-05-25 18:08:01');
INSERT INTO "public"."resource" VALUES ('1347048316216684544',
'1346777766301888512', 'SHENYU.BUTTON.SYSTEM.SYNCHRONIZE', '', '', '', 2, 4,
'', 1, 0, 'system:authen:modify', 1, '2022-05-25 18:08:01', '2022-05-25
18:08:01');
INSERT INTO "public"."resource" VALUES ('1347048776029843456',
'1346777766301888512', 'SHENYU.BUTTON.SYSTEM.EDIT', '', '', '', 2, 5, '', 1, 0,
'system:authen:edit', 1, '2022-05-25 18:08:01', '2022-05-25 18:08:01');
diff --git a/db/init/oracle/schema.sql b/db/init/oracle/schema.sql
index 20d70b2a8f..154c35ab17 100644
--- a/db/init/oracle/schema.sql
+++ b/db/init/oracle/schema.sql
@@ -2247,6 +2247,7 @@ INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX("resource" (id)) */
INTO "resource" (id,
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX("resource" (id)) */ INTO "resource"
(id, parent_id, title, name, url, component, resource_type, sort, icon,
is_leaf, is_route, perms, status)
VALUES('1347048004105940992','1346777766301888512','SHENYU.BUTTON.SYSTEM.LIST','','','','2','0','','1','0','system:authen:list','1');
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX("resource" (id)) */ INTO "resource"
(id, parent_id, title, name, url, component, resource_type, sort, icon,
is_leaf, is_route, perms, status)
VALUES('1347048101875167232','1346777766301888512','SHENYU.BUTTON.SYSTEM.DELETE','','','','2','1','','1','0','system:authen:delete','1');
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX("resource" (id)) */ INTO "resource"
(id, parent_id, title, name, url, component, resource_type, sort, icon,
is_leaf, is_route, perms, status)
VALUES('1347048145877610496','1346777766301888512','SHENYU.BUTTON.SYSTEM.ADD','','','','2','2','','1','0','system:authen:add','1');
+INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX("resource" (id)) */ INTO "resource"
(id, parent_id, title, name, url, component, resource_type, sort, icon,
is_leaf, is_route, perms, status)
VALUES('1347048240677269503','1346777766301888512','SHENYU.PLUGIN.BATCH.OPENED','','','','2','3','','1','0','system:authen:open','1');
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX("resource" (id)) */ INTO "resource"
(id, parent_id, title, name, url, component, resource_type, sort, icon,
is_leaf, is_route, perms, status)
VALUES('1347048240677269504','1346777766301888512','SHENYU.BUTTON.SYSTEM.ENABLE','','','','2','3','','1','0','system:authen:disable','1');
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX("resource" (id)) */ INTO "resource"
(id, parent_id, title, name, url, component, resource_type, sort, icon,
is_leaf, is_route, perms, status)
VALUES('1347048316216684544','1346777766301888512','SHENYU.BUTTON.SYSTEM.SYNCHRONIZE','','','','2','4','','1','0','system:authen:modify','1');
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX("resource" (id)) */ INTO "resource"
(id, parent_id, title, name, url, component, resource_type, sort, icon,
is_leaf, is_route, perms, status)
VALUES('1347048776029843456','1346777766301888512','SHENYU.BUTTON.SYSTEM.EDIT','','','','2','5','','1','0','system:authen:edit','1');
@@ -2319,6 +2320,7 @@ INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */
INTO permission (id, o
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */ INTO permission (id,
object_id, resource_id) VALUES ('1351007708740460544', '1346358560427216896',
'1347048004105940992');
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */ INTO permission (id,
object_id, resource_id) VALUES ('1351007708744654848', '1346358560427216896',
'1347048101875167232');
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */ INTO permission (id,
object_id, resource_id) VALUES ('1351007708744654849', '1346358560427216896',
'1347048145877610496');
+INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */ INTO permission (id,
object_id, resource_id) VALUES ('1351007708748849151', '1346358560427216896',
'1347048240677269503');
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */ INTO permission (id,
object_id, resource_id) VALUES ('1351007708748849152', '1346358560427216896',
'1347048240677269504');
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */ INTO permission (id,
object_id, resource_id) VALUES ('1351007708753043456', '1346358560427216896',
'1347048316216684544');
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */ INTO permission (id,
object_id, resource_id) VALUES ('1351007708757237760', '1346358560427216896',
'1347048776029843456');
diff --git a/db/init/pg/create-table.sql b/db/init/pg/create-table.sql
index 1ecd4590ed..cb5e0f306e 100644
--- a/db/init/pg/create-table.sql
+++ b/db/init/pg/create-table.sql
@@ -490,6 +490,7 @@ INSERT INTO "public"."permission" VALUES
('1351007708740460544', '13463585604272
INSERT INTO "public"."permission" VALUES ('1351007708614631424',
'1346358560427216896', '1346777907096285184', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
INSERT INTO "public"."permission" VALUES ('1351007708744654848',
'1346358560427216896', '1347048101875167232', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
INSERT INTO "public"."permission" VALUES ('1351007708744654849',
'1346358560427216896', '1347048145877610496', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
+INSERT INTO "public"."permission" VALUES ('1351007708748849151',
'1346358560427216896', '1347048240677269503', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
INSERT INTO "public"."permission" VALUES ('1351007708748849152',
'1346358560427216896', '1347048240677269504', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
INSERT INTO "public"."permission" VALUES ('1351007708753043456',
'1346358560427216896', '1347048316216684544', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
INSERT INTO "public"."permission" VALUES ('1351007708757237760',
'1346358560427216896', '1347048776029843456', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
@@ -1419,6 +1420,7 @@ INSERT INTO "public"."resource" VALUES
('1347047747305484288', '1346777623011880
INSERT INTO "public"."resource" VALUES ('1347048004105940992',
'1346777766301888512', 'SHENYU.BUTTON.SYSTEM.LIST', '', '', '', 2, 0, '', 1, 0,
'system:authen:list', 1, '2022-05-25 18:08:01', '2022-05-25 18:08:01');
INSERT INTO "public"."resource" VALUES ('1347048101875167232',
'1346777766301888512', 'SHENYU.BUTTON.SYSTEM.DELETE', '', '', '', 2, 1, '', 1,
0, 'system:authen:delete', 1, '2022-05-25 18:08:01', '2022-05-25 18:08:01');
INSERT INTO "public"."resource" VALUES ('1347048145877610496',
'1346777766301888512', 'SHENYU.BUTTON.SYSTEM.ADD', '', '', '', 2, 2, '', 1, 0,
'system:authen:add', 1, '2022-05-25 18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."resource" VALUES ('1347048240677269503',
'1346777766301888512', 'SHENYU.PLUGIN.BATCH.OPENED', '', '', '', 2, 3, '', 1,
0, 'system:authen:open', 1, '2022-05-25 18:08:01', '2022-05-25 18:08:01');
INSERT INTO "public"."resource" VALUES ('1347048240677269504',
'1346777766301888512', 'SHENYU.BUTTON.SYSTEM.ENABLE', '', '', '', 2, 3, '', 1,
0, 'system:authen:disable', 1, '2022-05-25 18:08:01', '2022-05-25 18:08:01');
INSERT INTO "public"."resource" VALUES ('1347048316216684544',
'1346777766301888512', 'SHENYU.BUTTON.SYSTEM.SYNCHRONIZE', '', '', '', 2, 4,
'', 1, 0, 'system:authen:modify', 1, '2022-05-25 18:08:01', '2022-05-25
18:08:01');
INSERT INTO "public"."resource" VALUES ('1347048776029843456',
'1346777766301888512', 'SHENYU.BUTTON.SYSTEM.EDIT', '', '', '', 2, 5, '', 1, 0,
'system:authen:edit', 1, '2022-05-25 18:08:01', '2022-05-25 18:08:01');
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 f4066c22d4..92c6bd59c6 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
@@ -32,3 +32,6 @@ CREATE TABLE IF NOT EXISTS INT_LOCK (
`CREATED_DATE` TIMESTAMP NOT NULL,
constraint INT_LOCK_PK primary key (LOCK_KEY, REGION)
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci
ROW_FORMAT = Dynamic;
+
+INSERT INTO `resource` VALUES ('1347048240677269503', '1346777766301888512',
'SHENYU.PLUGIN.BATCH.OPENED', '', '', '', 2, 3, '', 1, 0, 'system:authen:open',
1, '2022-05-25 18:02:53', '2022-05-25 18:02:53');
+INSERT INTO `permission` VALUES ('1351007708748849151', '1346358560427216896',
'1347048240677269503', '2022-05-25 18:02:53', '2022-05-25 18:02:53');
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 f31f2e5364..e80e5511b6 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
@@ -34,3 +34,6 @@ COMMENT ON COLUMN "public"."int_lock"."lock_key" IS
'lock_key';
COMMENT ON COLUMN "public"."int_lock"."region" IS 'region';
COMMENT ON COLUMN "public"."int_lock"."client_id" IS 'client_id';
COMMENT ON COLUMN "public"."int_lock"."created_date" IS 'created_date';
+
+INSERT INTO "public"."resource" VALUES ('1347048240677269503',
'1346777766301888512', 'SHENYU.PLUGIN.BATCH.OPENED', '', '', '', 2, 3, '', 1,
0, 'system:authen:open', 1, '2022-05-25 18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."permission" VALUES ('1351007708748849151',
'1346358560427216896', '1347048240677269503', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
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 c964fb46b2..51848ca94d 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
@@ -46,3 +46,6 @@ comment on column INT_LOCK.CLIENT_ID
is 'CLIENT_ID';
comment on column INT_LOCK.CREATED_DATE
is 'CREATED_DATE';
+
+INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX("resource" (id)) */ INTO "resource"
(id, parent_id, title, name, url, component, resource_type, sort, icon,
is_leaf, is_route, perms, status)
VALUES('1347048240677269503','1346777766301888512','SHENYU.PLUGIN.BATCH.OPENED','','','','2','3','','1','0','system:authen:open','1');
+INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */ INTO permission (id,
object_id, resource_id) VALUES ('1351007708748849151', '1346358560427216896',
'1347048240677269503');
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 bfe98b8af7..010159ff4e 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
@@ -34,3 +34,6 @@ COMMENT ON COLUMN "public"."int_lock"."lock_key" IS
'lock_key';
COMMENT ON COLUMN "public"."int_lock"."region" IS 'region';
COMMENT ON COLUMN "public"."int_lock"."client_id" IS 'client_id';
COMMENT ON COLUMN "public"."int_lock"."created_date" IS 'created_date';
+
+INSERT INTO "public"."resource" VALUES ('1347048240677269503',
'1346777766301888512', 'SHENYU.PLUGIN.BATCH.OPENED', '', '', '', 2, 3, '', 1,
0, 'system:authen:open', 1, '2022-05-25 18:08:01', '2022-05-25 18:08:01');
+INSERT INTO "public"."permission" VALUES ('1351007708748849151',
'1346358560427216896', '1347048240677269503', '2022-05-25 18:08:01',
'2022-05-25 18:08:01');
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 ce014b9eda..f3abe094f0 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
@@ -52,13 +52,13 @@ import java.util.List;
*/
@RestApi("/appAuth")
public class AppAuthController implements PagedController<AppAuthQuery,
AppAuthVO> {
-
+
private final AppAuthService appAuthService;
-
+
public AppAuthController(final AppAuthService appAuthService) {
this.appAuthService = appAuthService;
}
-
+
/**
* Apply App auth.
*
@@ -73,7 +73,7 @@ public class AppAuthController implements
PagedController<AppAuthQuery, AppAuthV
}
return appAuthService.applyCreate(authApplyDTO);
}
-
+
/**
* Update sk of App auth.
*
@@ -88,7 +88,7 @@ public class AppAuthController implements
PagedController<AppAuthQuery, AppAuthV
@RequestParam("appSecret") final String
appSecret) {
return appAuthService.updateAppSecretByAppKey(appKey, appSecret);
}
-
+
/**
* Find App auth page by query.
*
@@ -110,7 +110,7 @@ public class AppAuthController implements
PagedController<AppAuthQuery, AppAuthV
CommonPager<AppAuthVO> commonPager = appAuthService.listByPage(query);
return ShenyuAdminResult.success(ShenyuResultMessage.QUERY_SUCCESS,
commonPager);
}
-
+
/**
* Get detail of App auth.
*
@@ -124,7 +124,7 @@ public class AppAuthController implements
PagedController<AppAuthQuery, AppAuthV
provider = AppAuthMapper.class)
final String id) {
return ShenyuAdminResult.success(ShenyuResultMessage.DETAIL_SUCCESS,
appAuthService.findById(id));
}
-
+
/**
* Update App auth.
*
@@ -136,7 +136,7 @@ public class AppAuthController implements
PagedController<AppAuthQuery, AppAuthV
public ShenyuAdminResult updateDetail(@RequestBody @Valid final AppAuthDTO
appAuthDTO) {
return appAuthService.updateDetail(appAuthDTO);
}
-
+
/**
* Detail path of App auth.
*
@@ -152,7 +152,7 @@ public class AppAuthController implements
PagedController<AppAuthQuery, AppAuthV
@NotBlank final String authId) {
return ShenyuAdminResult.success(ShenyuResultMessage.DETAIL_SUCCESS,
appAuthService.detailPath(authId));
}
-
+
/**
* Update detail path.
*
@@ -164,7 +164,7 @@ public class AppAuthController implements
PagedController<AppAuthQuery, AppAuthV
public ShenyuAdminResult updateDetailPath(@RequestBody @Valid final
AuthPathWarpDTO authPathWarpDTO) {
return appAuthService.updateDetailPath(authPathWarpDTO);
}
-
+
/**
* delete application authorities.
*
@@ -177,7 +177,7 @@ public class AppAuthController implements
PagedController<AppAuthQuery, AppAuthV
Integer deleteCount = appAuthService.delete(ids);
return ShenyuAdminResult.success(ShenyuResultMessage.DELETE_SUCCESS,
deleteCount);
}
-
+
/**
* Batch enabled App auth.
*
@@ -193,7 +193,23 @@ public class AppAuthController implements
PagedController<AppAuthQuery, AppAuthV
}
return ShenyuAdminResult.success(ShenyuResultMessage.ENABLE_SUCCESS);
}
-
+
+ /**
+ * Batch opened App auth.
+ *
+ * @param batchCommonDTO the batch common dto
+ * @return the shenyu result
+ */
+ @PostMapping("/batchOpened")
+ @RequiresPermissions("system:authen:open")
+ public ShenyuAdminResult batchOpended(@Valid @RequestBody final
BatchCommonDTO batchCommonDTO) {
+ final String result = appAuthService.opened(batchCommonDTO.getIds(),
batchCommonDTO.getEnabled());
+ if (StringUtils.isNoneBlank(result)) {
+ return ShenyuAdminResult.error(result);
+ }
+ return ShenyuAdminResult.success(ShenyuResultMessage.ENABLE_SUCCESS);
+ }
+
/**
* Sync App auth data.
*
@@ -204,7 +220,7 @@ public class AppAuthController implements
PagedController<AppAuthQuery, AppAuthV
public ShenyuAdminResult syncData() {
return appAuthService.syncData();
}
-
+
@Override
public PageService<AppAuthQuery, AppAuthVO> pageService() {
return appAuthService;
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/AppAuthMapper.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/AppAuthMapper.java
index 2f33323dce..0aef0d76c6 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/AppAuthMapper.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/AppAuthMapper.java
@@ -32,7 +32,7 @@ import java.util.List;
*/
@Mapper
public interface AppAuthMapper extends ExistProvider {
-
+
/**
* exited.
*
@@ -41,7 +41,7 @@ public interface AppAuthMapper extends ExistProvider {
*/
@Override
Boolean existed(@Param("id") Serializable id);
-
+
/**
* exited.
*
@@ -49,7 +49,7 @@ public interface AppAuthMapper extends ExistProvider {
* @return existed
*/
Boolean appKeyExisted(@Param("appKey") Serializable appKey);
-
+
/**
* select application authority by id.
*
@@ -57,7 +57,7 @@ public interface AppAuthMapper extends ExistProvider {
* @return {@linkplain AppAuthDO}
*/
AppAuthDO selectById(String id);
-
+
/**
* select application authority by id.
*
@@ -65,7 +65,7 @@ public interface AppAuthMapper extends ExistProvider {
* @return {@linkplain AppAuthDO}
*/
List<AppAuthDO> selectByIds(List<String> ids);
-
+
/**
* select application authority by query.
*
@@ -73,14 +73,14 @@ public interface AppAuthMapper extends ExistProvider {
* @return {@linkplain List}
*/
List<AppAuthDO> selectByQuery(AppAuthQuery appAuthQuery);
-
+
/**
* select all.
*
* @return {@linkplain List}
*/
List<AppAuthDO> selectAll();
-
+
/**
* count application authority by query.
*
@@ -88,7 +88,7 @@ public interface AppAuthMapper extends ExistProvider {
* @return {@linkplain Integer}
*/
Integer countByQuery(AppAuthQuery appAuthQuery);
-
+
/**
* insert application authority.
*
@@ -96,7 +96,7 @@ public interface AppAuthMapper extends ExistProvider {
* @return rows int
*/
int insert(AppAuthDO appAuthDO);
-
+
/**
* insert selective application authority.
*
@@ -104,7 +104,7 @@ public interface AppAuthMapper extends ExistProvider {
* @return rows int
*/
int insertSelective(AppAuthDO appAuthDO);
-
+
/**
* update application authority.
*
@@ -112,7 +112,7 @@ public interface AppAuthMapper extends ExistProvider {
* @return rows int
*/
int update(AppAuthDO appAuthDO);
-
+
/**
* Update enable int.
*
@@ -120,7 +120,7 @@ public interface AppAuthMapper extends ExistProvider {
* @return the int
*/
int updateEnable(AppAuthDO appAuthDO);
-
+
/**
* update enable batch.
*
@@ -129,8 +129,17 @@ public interface AppAuthMapper extends ExistProvider {
* @return the count
*/
int updateEnableBatch(@Param("idList") List<String> idList,
@Param("enabled") Boolean enabled);
-
-
+
+ /**
+ * update open batch.
+ *
+ * @param idList the ids
+ * @param enabled the status
+ * @return the count
+ */
+ int batchUpdateAppAuth(@Param("idList") List<String> idList,
@Param("enabled") Boolean enabled);
+
+
/**
* Update app secret by app key int.
*
@@ -139,7 +148,7 @@ public interface AppAuthMapper extends ExistProvider {
* @return the int
*/
int updateAppSecretByAppKey(@Param("appKey") String appKey,
@Param("appSecret") String appSecret);
-
+
/**
* update selective application authority.
*
@@ -147,7 +156,7 @@ public interface AppAuthMapper extends ExistProvider {
* @return rows int
*/
int updateSelective(AppAuthDO appAuthDO);
-
+
/**
* deleteSelector application authority.
*
@@ -155,7 +164,7 @@ public interface AppAuthMapper extends ExistProvider {
* @return rows int
*/
int delete(String id);
-
+
/**
* deleteSelector application authority.
*
@@ -163,7 +172,7 @@ public interface AppAuthMapper extends ExistProvider {
* @return rows int
*/
int deleteByIds(List<String> ids);
-
+
/**
* Find by app key app auth do.
*
@@ -171,7 +180,7 @@ public interface AppAuthMapper extends ExistProvider {
* @return the app auth do
*/
AppAuthDO findByAppKey(String appKey);
-
+
/**
* select by condition.
*
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/AppAuthService.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/AppAuthService.java
index 7dcbc34a70..f2b30250b2 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/AppAuthService.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/AppAuthService.java
@@ -97,6 +97,16 @@ public interface AppAuthService extends
PageService<AppAuthQuery, AppAuthVO> {
*/
String enabled(List<String> ids, Boolean enabled);
+
+ /**
+ * Opened string.
+ *
+ * @param ids the ids
+ * @param enabled the enable
+ * @return the string
+ */
+ String opened(List<String> ids, Boolean enabled);
+
/**
* find application authority by id.
*
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 49ed0403c4..72d369f355 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
@@ -410,6 +410,33 @@ public class AppAuthServiceImpl implements AppAuthService {
return StringUtils.EMPTY;
}
+ @Override
+ public String opened(final List<String> ids, final Boolean enabled) {
+ List<String> distinctIds =
ids.stream().distinct().collect(Collectors.toList());
+ List<AppAuthDO> appAuthDOList = appAuthMapper.selectByIds(distinctIds);
+ if (CollectionUtils.isEmpty(appAuthDOList)) {
+ return AdminConstants.ID_NOT_EXIST;
+ }
+
+ Map<String, List<AuthParamData>> paramMap =
this.prepareAuthParamData(distinctIds);
+ Map<String, List<AuthPathData>> pathMap =
this.prepareAuthPathData(distinctIds);
+
+ List<AppAuthData> authDataList = appAuthDOList.stream().map(appAuthDO
-> {
+ String id = appAuthDO.getId();
+ appAuthDO.setEnabled(enabled);
+ return this.buildByEntityWithParamAndPath(appAuthDO,
paramMap.get(id), pathMap.get(id));
+ }).collect(Collectors.toList());
+
+ appAuthMapper.batchUpdateAppAuth(distinctIds, enabled);
+
+ // publish change event.
+ if (CollectionUtils.isNotEmpty(authDataList)) {
+ eventPublisher.publishEvent(new
DataChangedEvent(ConfigGroupEnum.APP_AUTH, DataEventTypeEnum.UPDATE,
+ authDataList));
+ }
+ return StringUtils.EMPTY;
+ }
+
/**
* find application authority by id.
*
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 5192d82565..32d08a8b2d 100644
--- a/shenyu-admin/src/main/resources/mappers/app-auth-sqlmap.xml
+++ b/shenyu-admin/src/main/resources/mappers/app-auth-sqlmap.xml
@@ -285,6 +285,15 @@
</foreach>
</update>
+ <update id="batchUpdateAppAuth">
+ UPDATE app_auth
+ SET open = #{enabled,jdbcType=TINYINT}
+ WHERE id IN
+ <foreach collection="idList" index="index" item="id" open="("
separator="," close=")">
+ #{id, jdbcType=VARCHAR}
+ </foreach>
+ </update>
+
<update id="updateAppSecretByAppKey">
UPDATE app_auth
SET app_secret = #{appSecret, 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 05d5411af8..7a3b5299c6 100755
--- a/shenyu-admin/src/main/resources/sql-script/h2/schema.sql
+++ b/shenyu-admin/src/main/resources/sql-script/h2/schema.sql
@@ -871,7 +871,7 @@ INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1678997557628272642', '15', 'loadBalance', 'loadBalance', 3, 2, 3,
'{"required":"0","defaultValue":"random","rule":""}');
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1678997557628272643', '44', 'defaultHandleJson', 'defaultHandleJson', 2, 3,
2,
'{"required":"0","defaultValue":"{\"authorization\":\"test:test123\"}","placeholder":""}');
-
+
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1721435546642157568', '45', 'host', 'host', 2, 3, 0,
'{"required":"1","defaultValue":"127.0.0.1","rule":""}');
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1721435708743618560', '45', 'port', 'port', 1, 3, 0,
'{"required":"1","defaultValue":"15672","rule":""}');
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1721436368046264320', '45', 'password', 'password', 2, 3, 0,
'{"required":"0","defaultValue":"admin","rule":""}');
@@ -931,6 +931,7 @@ INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`,
`name`, `url`, `compo
INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`,
`component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`,
`status`)
VALUES('1347048004105940992','1346777766301888512','SHENYU.BUTTON.SYSTEM.LIST','','','','2','0','','1','0','system:authen:list','1');
INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`,
`component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`,
`status`)
VALUES('1347048101875167232','1346777766301888512','SHENYU.BUTTON.SYSTEM.DELETE','','','','2','1','','1','0','system:authen:delete','1');
INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`,
`component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`,
`status`)
VALUES('1347048145877610496','1346777766301888512','SHENYU.BUTTON.SYSTEM.ADD','','','','2','2','','1','0','system:authen:add','1');
+INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`,
`component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`,
`status`)
VALUES('1347048240677269503','1346777766301888512','SHENYU.PLUGIN.BATCH.OPENED','','','','2','3','','1','0','system:authen:open','1');
INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`,
`component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`,
`status`)
VALUES('1347048240677269504','1346777766301888512','SHENYU.BUTTON.SYSTEM.ENABLE','','','','2','3','','1','0','system:authen:disable','1');
INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`,
`component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`,
`status`)
VALUES('1347048316216684544','1346777766301888512','SHENYU.BUTTON.SYSTEM.SYNCHRONIZE','','','','2','4','','1','0','system:authen:modify','1');
INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`,
`component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`,
`status`)
VALUES('1347048776029843456','1346777766301888512','SHENYU.BUTTON.SYSTEM.EDIT','','','','2','5','','1','0','system:authen:edit','1');
@@ -1003,6 +1004,7 @@ INSERT IGNORE INTO `permission` (`id`, `object_id`,
`resource_id`) VALUES ('1351
INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`) VALUES
('1351007708740460544', '1346358560427216896', '1347048004105940992');
INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`) VALUES
('1351007708744654848', '1346358560427216896', '1347048101875167232');
INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`) VALUES
('1351007708744654849', '1346358560427216896', '1347048145877610496');
+INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`) VALUES
('1351007708748849151', '1346358560427216896', '1347048240677269503');
INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`) VALUES
('1351007708748849152', '1346358560427216896', '1347048240677269504');
INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`) VALUES
('1351007708753043456', '1346358560427216896', '1347048316216684544');
INSERT IGNORE INTO `permission` (`id`, `object_id`, `resource_id`) VALUES
('1351007708757237760', '1346358560427216896', '1347048776029843456');
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 5424031a83..039441e76d 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
@@ -82,10 +82,10 @@ public final class AppAuthControllerTest {
@Mock
private AppAuthService appAuthService;
-
+
@Mock
private AuthPathMapper authPathMapper;
-
+
@Mock
private AppAuthMapper appAuthMapper;
@@ -284,6 +284,21 @@ public final class AppAuthControllerTest {
.andReturn();
}
+ @Test
+ public void testBatchOpened() throws Exception {
+ final BatchCommonDTO batchCommonDTO = new BatchCommonDTO();
+ batchCommonDTO.setIds(Arrays.asList("0001", "0002"));
+ batchCommonDTO.setEnabled(true);
+ given(this.appAuthService.enabled(batchCommonDTO.getIds(),
batchCommonDTO.getEnabled()))
+ .willReturn(StringUtils.EMPTY);
+
this.mockMvc.perform(MockMvcRequestBuilders.post("/appAuth/batchOpened")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(GsonUtils.getInstance().toJson(batchCommonDTO)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.message",
is(ShenyuResultMessage.ENABLE_SUCCESS)))
+ .andReturn();
+ }
+
@Test
public void testBatchEnabled() throws Exception {
final BatchCommonDTO batchCommonDTO = new BatchCommonDTO();
@@ -299,6 +314,21 @@ public final class AppAuthControllerTest {
.andReturn();
}
+ @Test
+ public void testBatchOpenedWithError() throws Exception {
+ final BatchCommonDTO batchCommonDTO = new BatchCommonDTO();
+ batchCommonDTO.setIds(Arrays.asList("0001", "0002"));
+ batchCommonDTO.setEnabled(true);
+ given(this.appAuthService.opened(batchCommonDTO.getIds(),
batchCommonDTO.getEnabled()))
+ .willReturn(AdminConstants.ID_NOT_EXIST);
+
this.mockMvc.perform(MockMvcRequestBuilders.post("/appAuth/batchOpened")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(GsonUtils.getInstance().toJson(batchCommonDTO)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.message",
is(AdminConstants.ID_NOT_EXIST)))
+ .andReturn();
+ }
+
@Test
public void testBatchEnabledWithError() throws Exception {
final BatchCommonDTO batchCommonDTO = new BatchCommonDTO();
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/AppAuthServiceTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/AppAuthServiceTest.java
index cb7b5246c5..a7465afc54 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/AppAuthServiceTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/AppAuthServiceTest.java
@@ -148,6 +148,20 @@ public final class AppAuthServiceTest {
assertThat(count, greaterThanOrEqualTo(0));
}
+ @Test
+ public void testOpened() {
+ BatchCommonDTO batchCommonDTO = new BatchCommonDTO();
+ batchCommonDTO.setEnabled(Boolean.TRUE);
+ batchCommonDTO.setIds(Collections.singletonList(appAuthDO.getId()));
+ assertEquals(AdminConstants.ID_NOT_EXIST,
this.appAuthService.opened(batchCommonDTO.getIds(),
batchCommonDTO.getEnabled()));
+
+
given(this.appAuthMapper.selectById(appAuthDO.getId())).willReturn(appAuthDO);
+
given(this.appAuthMapper.selectByIds(Collections.singletonList(appAuthDO.getId()))).willReturn(Collections.singletonList(appAuthDO));
+ assertEquals(StringUtils.EMPTY,
this.appAuthService.opened(batchCommonDTO.getIds(),
batchCommonDTO.getEnabled()));
+ AppAuthVO appAuthVO = this.appAuthService.findById(appAuthDO.getId());
+ assertEquals(Boolean.TRUE, appAuthVO.getOpen());
+ }
+
@Test
public void testEnabled() {
BatchCommonDTO batchCommonDTO = new BatchCommonDTO();