This is an automated email from the ASF dual-hosted git repository. liuhongyu 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 0a2b9f5eef improve the function of dubbo plugin configuration based on selector, add registry config. (#6096) 0a2b9f5eef is described below commit 0a2b9f5eef2d3c71f5957571d50d4fa765d22eca Author: Wweiei <45253632+wwe...@users.noreply.github.com> AuthorDate: Sun Aug 17 16:50:41 2025 +0800 improve the function of dubbo plugin configuration based on selector, add registry config. (#6096) * feat: registry config basic operation * feat: registry config basic operation * feat: registry config basic operation * feat: registry config basic operation * fix:Copilot code review * fix:Copilot code review * fix:Copilot code review,update method judge exist registry_id --------- Co-authored-by: aias00 <liuhon...@apache.org> --- db/init/mysql/schema.sql | 28 ++ db/init/ob/schema.sql | 27 ++ db/init/og/create-table.sql | 38 +++ db/init/oracle/schema.sql | 43 +++ db/init/pg/create-table.sql | 37 +++ db/upgrade/2.7.0-upgrade-2.7.1-mysql.sql | 28 +- db/upgrade/2.7.0-upgrade-2.7.1-ob.sql | 28 +- db/upgrade/2.7.0-upgrade-2.7.1-og.sql | 40 ++- db/upgrade/2.7.0-upgrade-2.7.1-oracle.sql | 45 ++- db/upgrade/2.7.0-upgrade-2.7.1-pg.sql | 39 ++- .../http-debug-registry-config-controller-api.http | 79 +++++ .../admin/controller/RegistryController.java | 128 ++++++++ .../apache/shenyu/admin/mapper/RegistryMapper.java | 132 ++++++++ .../apache/shenyu/admin/model/dto/RegistryDTO.java | 199 ++++++++++++ .../shenyu/admin/model/entity/RegistryDO.java | 352 +++++++++++++++++++++ .../shenyu/admin/model/query/RegistryQuery.java | 139 ++++++++ .../apache/shenyu/admin/model/vo/RegistryVO.java | 212 +++++++++++++ .../shenyu/admin/service/RegistryService.java | 75 +++++ .../admin/service/impl/RegistryServiceImpl.java | 134 ++++++++ .../shenyu/admin/transfer/RegistryTransfer.java | 51 +++ .../src/main/resources/mappers/registry-sqlmap.xml | 267 ++++++++++++++++ 21 files changed, 2116 insertions(+), 5 deletions(-) diff --git a/db/init/mysql/schema.sql b/db/init/mysql/schema.sql index 266829fd76..3292f11f9b 100644 --- a/db/init/mysql/schema.sql +++ b/db/init/mysql/schema.sql @@ -2703,3 +2703,31 @@ CREATE TABLE IF NOT EXISTS `instance_info` ( `date_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'date_updated', PRIMARY KEY (`id`) ); + +DROP TABLE IF EXISTS `registry_config`; + +CREATE TABLE `registry_config` ( + `id` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'primary key id', + `registry_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'registry_id', + `protocol` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'protocol', + `address` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'address', + `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'username', + `password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'password', + `namespace` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'namespace', + `group` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'group', + `date_created` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'create time', + `date_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT 'update time', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic; + +INSERT INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1953048313980116900', '1357956838021890048', 'SHENYU.MENU.SYSTEM.MANAGMENT.REGISTRY', 'registry', '/config/registry', 'registry', 1, 7, 'ordered-list', 0, 0, '', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1953048313980116901', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.ADD', '', '', '', 2, 0, '', 1, 0, 'system:registry:add', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1953048313980116902', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.LIST', '', '', '', 2, 1, '', 1, 0, 'system:registry:list', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1953048313980116903', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.DELETE', '', '', '', 2, 2, '', 1, 0, 'system:registry:delete', 1,'2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1953048313980116904', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.EDIT', '', '', '', 2, 3, '', 1, 0, 'system:registry:edit', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); + +INSERT INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1953049887387303901', '1346358560427216896', '1953048313980116900', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1953049887387303902', '1346358560427216896', '1953048313980116901', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1953049887387303903', '1346358560427216896', '1953048313980116902', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1953049887387303904', '1346358560427216896', '1953048313980116903', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1953049887387303905', '1346358560427216896', '1953048313980116904', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); diff --git a/db/init/ob/schema.sql b/db/init/ob/schema.sql index 7af05181e1..c0414df2d4 100644 --- a/db/init/ob/schema.sql +++ b/db/init/ob/schema.sql @@ -2620,3 +2620,30 @@ INSERT INTO `plugin_handle` VALUES ('1722804548510507356', '66', 'baseUrl', 'bas INSERT INTO `plugin_handle` VALUES ('1722804548510507357', '66', 'apiKey', 'apiKey', 2, 2, 2, '{"required":"0","rule":""}', '2025-03-12 06:02:18.707', '2025-03-12 06:02:18.707'); INSERT INTO `plugin_handle` VALUES ('1722804548510507358', '66', 'model', 'model', 2, 2, 3, '{"required":"0","rule":""}', '2025-03-12 06:02:32.450', '2025-03-12 06:02:32.450'); INSERT INTO `plugin_handle` VALUES ('1722804548510507359', '66', 'content', 'content', 2, 2, 4, '{"required":"0","rule":""}', '2025-03-12 06:02:32.450', '2025-03-12 06:02:32.450'); + +DROP TABLE IF EXISTS `registry_config`; +CREATE TABLE `registry_config` ( + `id` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'primary key id', + `registry_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'registry_id', + `protocol` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'protocol', + `address` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'address', + `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'username', + `password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'password', + `namespace` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'namespace', + `group` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'group', + `date_created` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'create time', + `date_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT 'update time', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic; + +INSERT INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1953048313980116900', '1357956838021890048', 'SHENYU.MENU.SYSTEM.MANAGMENT.REGISTRY', 'registry', '/config/registry', 'registry', 1, 7, 'ordered-list', 0, 0, '', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1953048313980116901', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.ADD', '', '', '', 2, 0, '', 1, 0, 'system:registry:add', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1953048313980116902', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.LIST', '', '', '', 2, 1, '', 1, 0, 'system:registry:list', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1953048313980116903', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.DELETE', '', '', '', 2, 2, '', 1, 0, 'system:registry:delete', 1,'2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1953048313980116904', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.EDIT', '', '', '', 2, 3, '', 1, 0, 'system:registry:edit', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); + +INSERT INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1953049887387303901', '1346358560427216896', '1953048313980116900', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1953049887387303902', '1346358560427216896', '1953048313980116901', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1953049887387303903', '1346358560427216896', '1953048313980116902', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1953049887387303904', '1346358560427216896', '1953048313980116903', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1953049887387303905', '1346358560427216896', '1953048313980116904', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); diff --git a/db/init/og/create-table.sql b/db/init/og/create-table.sql index 54df4bd21f..e779a5e818 100644 --- a/db/init/og/create-table.sql +++ b/db/init/og/create-table.sql @@ -3014,3 +3014,41 @@ INSERT INTO "public"."permission" VALUES ('1697146861569542757', '13463585604272 INSERT INTO "public"."permission" VALUES ('1697146861569542758', '1346358560427216896', '1844026199075534867', '2023-08-31 07:18:37', '2023-08-31 07:18:37'); INSERT INTO "public"."permission" VALUES ('1697146861569542759', '1346358560427216896', '1844026199075534868', '2023-08-31 07:18:37', '2023-08-31 07:18:37'); INSERT INTO "public"."permission" VALUES ('1697146861569542760', '1346358560427216896', '1844026199075534869', '2023-08-31 07:18:37', '2023-08-31 07:18:37'); + +DROP TABLE IF EXISTS "public"."registry_config"; +CREATE TABLE "public"."registry_config" ( + "id" varchar(128) NOT NULL, + "registry_id" varchar(50) NOT NULL, + "protocol" varchar(128) NOT NULL, + "address" varchar(512) NOT NULL, + "username" varchar(50), + "password" varchar(100), + "namespace" varchar(100), + "group" varchar(20), + "date_created" timestamp(3) NOT NULL DEFAULT timezone('UTC-8'::text, (now())::timestamp(0) without time zone), + "date_updated" timestamp(3) NOT NULL DEFAULT timezone('UTC-8'::text, (now())::timestamp(0) without time zone), + PRIMARY KEY ("id") +); + +COMMENT ON COLUMN "public"."registry_config"."id" IS 'primary key'; +COMMENT ON COLUMN "public"."registry_config"."registry_id" IS 'registry_id'; +COMMENT ON COLUMN "public"."registry_config"."protocol" IS 'protocol'; +COMMENT ON COLUMN "public"."registry_config"."address" IS 'address'; +COMMENT ON COLUMN "public"."registry_config"."username" IS 'username'; +COMMENT ON COLUMN "public"."registry_config"."password" IS 'password'; +COMMENT ON COLUMN "public"."registry_config"."namespace" IS 'namespace'; +COMMENT ON COLUMN "public"."registry_config"."group" IS 'group'; +COMMENT ON COLUMN "public"."registry_config"."date_created" IS 'create time'; +COMMENT ON COLUMN "public"."registry_config"."date_updated" IS 'update time'; + +INSERT INTO "public"."resource" VALUES ('1953048313980116900', '1357956838021890048', 'SHENYU.MENU.SYSTEM.MANAGMENT.REGISTRY', 'registry', '/config/registry', 'registry', 1, 7, 'ordered-list', 0, 0, '', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."resource" VALUES ('1953048313980116901', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.ADD', '', '', '', 2, 0, '', 1, 0, 'system:registry:add', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."resource" VALUES ('1953048313980116902', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.LIST', '', '', '', 2, 1, '', 1, 0, 'system:registry:list', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."resource" VALUES ('1953048313980116903', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.DELETE', '', '', '', 2, 2, '', 1, 0, 'system:registry:delete', 1,'2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."resource" VALUES ('1953048313980116904', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.EDIT', '', '', '', 2, 3, '', 1, 0, 'system:registry:edit', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); + +INSERT INTO "public"."permission" VALUES ('1953049887387303901', '1346358560427216896', '1953048313980116900', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."permission" VALUES ('1953049887387303902', '1346358560427216896', '1953048313980116901', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."permission" VALUES ('1953049887387303903', '1346358560427216896', '1953048313980116902', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."permission" VALUES ('1953049887387303904', '1346358560427216896', '1953048313980116903', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."permission" VALUES ('1953049887387303905', '1346358560427216896', '1953048313980116904', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); diff --git a/db/init/oracle/schema.sql b/db/init/oracle/schema.sql index d273a954b1..81779376ba 100644 --- a/db/init/oracle/schema.sql +++ b/db/init/oracle/schema.sql @@ -3607,3 +3607,46 @@ INSERT INTO permission (id, role_id, resource_id, date_created, date_updated) VA INSERT INTO permission (id, role_id, resource_id, date_created, date_updated) VALUES ('1697146861569542758', '1346358560427216896', '1844026199075534867', sysdate, sysdate); INSERT INTO permission (id, role_id, resource_id, date_created, date_updated) VALUES ('1697146861569542759', '1346358560427216896', '1844026199075534868', sysdate, sysdate); INSERT INTO permission (id, role_id, resource_id, date_created, date_updated) VALUES ('1697146861569542760', '1346358560427216896', '1844026199075534869', sysdate, sysdate); + +CREATE TABLE "public"."registry_config" ( + id varchar2(128) NOT NULL, + registry_id varchar2(50) NOT NULL, + protocol varchar2(128) NOT NULL, + address varchar2(512) NOT NULL, + username varchar2(50), + password varchar2(100), + namespace varchar2(100), + group varchar2(20), + date_created timestamp(3) DEFAULT SYSTIMESTAMP NOT NULL, + date_updated timestamp(3) DEFAULT SYSTIMESTAMP NOT NULL, + CONSTRAINT registry_config_pk PRIMARY KEY (id) +); + +COMMENT ON TABLE registry_config IS 'registry config information table'; +COMMENT ON COLUMN registry_config.id IS 'primary key'; +COMMENT ON COLUMN registry_config.registry_id IS 'registry_id'; +COMMENT ON COLUMN registry_config.protocol IS 'protocol'; +COMMENT ON COLUMN registry_config.address IS 'address'; +COMMENT ON COLUMN registry_config.username IS 'username'; +COMMENT ON COLUMN registry_config.password IS 'password'; +COMMENT ON COLUMN registry_config.namespace IS 'namespace'; +COMMENT ON COLUMN registry_config.group IS 'group'; +COMMENT ON COLUMN registry_config.date_created IS 'create time'; +COMMENT ON COLUMN registry_config.date_updated IS 'update time'; + +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, date_created, date_updated) +VALUES ('1953048313980116900', '1357956838021890048', 'SHENYU.MENU.SYSTEM.MANAGMENT.REGISTRY', 'registry', '/config/registry', 'registry', 1, 7, 'ordered-list', 0, 0, '', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +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, date_created, date_updated) +VALUES ('1953048313980116901', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.ADD', '', '', '', 2, 0, '', 1, 0, 'system:registry:add', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +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, date_created, date_updated) +VALUES ('1953048313980116902', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.LIST', '', '', '', 2, 1, '', 1, 0, 'system:registry:list', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +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, date_created, date_updated) +VALUES ('1953048313980116903', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.DELETE', '', '', '', 2, 2, '', 1, 0, 'system:registry:delete', 1,'2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +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, date_created, date_updated) +VALUES ('1953048313980116904', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.EDIT', '', '', '', 2, 3, '', 1, 0, 'system:registry:edit', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); + +INSERT INTO permission (id, role_id, resource_id, date_created, date_updated) VALUES ('1953049887387303901', '1346358560427216896', '1953048313980116900', sysdate, sysdate); +INSERT INTO permission (id, role_id, resource_id, date_created, date_updated) VALUES ('1953049887387303902', '1346358560427216896', '1953048313980116901', sysdate, sysdate); +INSERT INTO permission (id, role_id, resource_id, date_created, date_updated) VALUES ('1953049887387303903', '1346358560427216896', '1953048313980116902', sysdate, sysdate); +INSERT INTO permission (id, role_id, resource_id, date_created, date_updated) VALUES ('1953049887387303904', '1346358560427216896', '1953048313980116903', sysdate, sysdate); +INSERT INTO permission (id, role_id, resource_id, date_created, date_updated) VALUES ('1953049887387303905', '1346358560427216896', '1953048313980116904', sysdate, sysdate); \ No newline at end of file diff --git a/db/init/pg/create-table.sql b/db/init/pg/create-table.sql index 1cb674daf5..e386ab7c3e 100644 --- a/db/init/pg/create-table.sql +++ b/db/init/pg/create-table.sql @@ -3149,3 +3149,40 @@ INSERT INTO "public"."permission" VALUES ('1697146861569542757', '13463585604272 INSERT INTO "public"."permission" VALUES ('1697146861569542758', '1346358560427216896', '1844026199075534867', '2023-08-31 07:18:37', '2023-08-31 07:18:37'); INSERT INTO "public"."permission" VALUES ('1697146861569542759', '1346358560427216896', '1844026199075534868', '2023-08-31 07:18:37', '2023-08-31 07:18:37'); INSERT INTO "public"."permission" VALUES ('1697146861569542760', '1346358560427216896', '1844026199075534869', '2023-08-31 07:18:37', '2023-08-31 07:18:37'); + +DROP TABLE IF EXISTS "public"."registry_config"; +CREATE TABLE "public"."registry_config" ( + "id" varchar(128) NOT NULL, + "registry_id" varchar(50) NOT NULL, + "protocol" varchar(128) NOT NULL, + "address" varchar(512) NOT NULL, + "username" varchar(50), + "password" varchar(100), + "namespace" varchar(100), + "group" varchar(20), + "date_created" timestamp(3) NOT NULL DEFAULT timezone('UTC-8'::text, (now())::timestamp(0) without time zone), + "date_updated" timestamp(3) NOT NULL DEFAULT timezone('UTC-8'::text, (now())::timestamp(0) without time zone), + PRIMARY KEY ("id") +); +COMMENT ON COLUMN "public"."registry_config"."id" IS 'primary key'; +COMMENT ON COLUMN "public"."registry_config"."registry_id" IS 'registry_id'; +COMMENT ON COLUMN "public"."registry_config"."protocol" IS 'protocol'; +COMMENT ON COLUMN "public"."registry_config"."address" IS 'address'; +COMMENT ON COLUMN "public"."registry_config"."username" IS 'username'; +COMMENT ON COLUMN "public"."registry_config"."password" IS 'password'; +COMMENT ON COLUMN "public"."registry_config"."namespace" IS 'namespace'; +COMMENT ON COLUMN "public"."registry_config"."group" IS 'group'; +COMMENT ON COLUMN "public"."registry_config"."date_created" IS 'create time'; +COMMENT ON COLUMN "public"."registry_config"."date_updated" IS 'update time'; + +INSERT INTO "public"."resource" VALUES ('1953048313980116900', '1357956838021890048', 'SHENYU.MENU.SYSTEM.MANAGMENT.REGISTRY', 'registry', '/config/registry', 'registry', 1, 7, 'ordered-list', 0, 0, '', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."resource" VALUES ('1953048313980116901', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.ADD', '', '', '', 2, 0, '', 1, 0, 'system:registry:add', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."resource" VALUES ('1953048313980116902', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.LIST', '', '', '', 2, 1, '', 1, 0, 'system:registry:list', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."resource" VALUES ('1953048313980116903', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.DELETE', '', '', '', 2, 2, '', 1, 0, 'system:registry:delete', 1,'2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."resource" VALUES ('1953048313980116904', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.EDIT', '', '', '', 2, 3, '', 1, 0, 'system:registry:edit', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); + +INSERT INTO "public"."permission" VALUES ('1953049887387303901', '1346358560427216896', '1953048313980116900', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."permission" VALUES ('1953049887387303902', '1346358560427216896', '1953048313980116901', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."permission" VALUES ('1953049887387303903', '1346358560427216896', '1953048313980116902', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."permission" VALUES ('1953049887387303904', '1346358560427216896', '1953048313980116903', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."permission" VALUES ('1953049887387303905', '1346358560427216896', '1953048313980116904', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); \ No newline at end of file diff --git a/db/upgrade/2.7.0-upgrade-2.7.1-mysql.sql b/db/upgrade/2.7.0-upgrade-2.7.1-mysql.sql index 99d376da10..87e56d6aa2 100755 --- a/db/upgrade/2.7.0-upgrade-2.7.1-mysql.sql +++ b/db/upgrade/2.7.0-upgrade-2.7.1-mysql.sql @@ -238,4 +238,30 @@ DELETE FROM `plugin_handle` WHERE `plugin_id` = '8'; INSERT INTO `plugin_handle` VALUES ('1529402613204173925', '6', 'registry', 'registry', 2, 1, 0, '{\"required\":\"0\",\"rule\":\"\"}', '2025-02-27 17:20:50.233', '2025-02-27 17:20:50.233'); UPDATE `plugin_handle` SET ext_obj = '{\"required\":\"0\",\"rule\":\"\"}' WHERE plugin_id = '6' AND label = 'ip:port' AND data_type = 2; -INSERT INTO `plugin_handle` VALUES ('1942847622591684608', '61', 'messageEndpoint', 'messageEndpoint', 2, 1, 0, '{"required":"0","defaultValue":"/message","rule":""}', '2025-07-09 07:25:44.249', '2025-07-09 07:25:44.249'); \ No newline at end of file +INSERT INTO `plugin_handle` VALUES ('1942847622591684608', '61', 'messageEndpoint', 'messageEndpoint', 2, 1, 0, '{"required":"0","defaultValue":"/message","rule":""}', '2025-07-09 07:25:44.249', '2025-07-09 07:25:44.249'); + +CREATE TABLE `registry_config` ( + `id` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'primary key id', + `registry_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'registry_id', + `protocol` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'protocol', + `address` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'address', + `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'username', + `password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'password', + `namespace` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'namespace', + `group` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'group', + `date_created` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'create time', + `date_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT 'update time', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic; + +INSERT INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1953048313980116900', '1357956838021890048', 'SHENYU.MENU.SYSTEM.MANAGMENT.REGISTRY', 'registry', '/config/registry', 'registry', 1, 7, 'ordered-list', 0, 0, '', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1953048313980116901', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.ADD', '', '', '', 2, 0, '', 1, 0, 'system:registry:add', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1953048313980116902', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.LIST', '', '', '', 2, 1, '', 1, 0, 'system:registry:list', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1953048313980116903', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.DELETE', '', '', '', 2, 2, '', 1, 0, 'system:registry:delete', 1,'2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1953048313980116904', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.EDIT', '', '', '', 2, 3, '', 1, 0, 'system:registry:edit', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); + +INSERT INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1953049887387303901', '1346358560427216896', '1953048313980116900', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1953049887387303902', '1346358560427216896', '1953048313980116901', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1953049887387303903', '1346358560427216896', '1953048313980116902', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1953049887387303904', '1346358560427216896', '1953048313980116903', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1953049887387303905', '1346358560427216896', '1953048313980116904', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); diff --git a/db/upgrade/2.7.0-upgrade-2.7.1-ob.sql b/db/upgrade/2.7.0-upgrade-2.7.1-ob.sql index 271a8cfe3d..4ee7f8dbc1 100755 --- a/db/upgrade/2.7.0-upgrade-2.7.1-ob.sql +++ b/db/upgrade/2.7.0-upgrade-2.7.1-ob.sql @@ -231,4 +231,30 @@ INSERT INTO `permission` VALUES ('1697146861569542756', '1346358560427216896', ' INSERT INTO `permission` VALUES ('1697146861569542757', '1346358560427216896', '1844026199075534866', '2023-08-31 07:18:37', '2023-08-31 07:18:37'); INSERT INTO `permission` VALUES ('1697146861569542758', '1346358560427216896', '1844026199075534867', '2023-08-31 07:18:37', '2023-08-31 07:18:37'); INSERT INTO `permission` VALUES ('1697146861569542759', '1346358560427216896', '1844026199075534868', '2023-08-31 07:18:37', '2023-08-31 07:18:37'); -INSERT INTO `permission` VALUES ('1697146861569542760', '1346358560427216896', '1844026199075534869', '2023-08-31 07:18:37', '2023-08-31 07:18:37'); \ No newline at end of file +INSERT INTO `permission` VALUES ('1697146861569542760', '1346358560427216896', '1844026199075534869', '2023-08-31 07:18:37', '2023-08-31 07:18:37'); + +CREATE TABLE `registry_config` ( + `id` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'primary key id', + `registry_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'registry_id', + `protocol` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'protocol', + `address` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'address', + `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'username', + `password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'password', + `namespace` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'namespace', + `group` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'group', + `date_created` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'create time', + `date_updated` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT 'update time', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic; + +INSERT INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1953048313980116900', '1357956838021890048', 'SHENYU.MENU.SYSTEM.MANAGMENT.REGISTRY', 'registry', '/config/registry', 'registry', 1, 7, 'ordered-list', 0, 0, '', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1953048313980116901', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.ADD', '', '', '', 2, 0, '', 1, 0, 'system:registry:add', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1953048313980116902', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.LIST', '', '', '', 2, 1, '', 1, 0, 'system:registry:list', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1953048313980116903', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.DELETE', '', '', '', 2, 2, '', 1, 0, 'system:registry:delete', 1,'2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1953048313980116904', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.EDIT', '', '', '', 2, 3, '', 1, 0, 'system:registry:edit', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); + +INSERT INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1953049887387303901', '1346358560427216896', '1953048313980116900', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1953049887387303902', '1346358560427216896', '1953048313980116901', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1953049887387303903', '1346358560427216896', '1953048313980116902', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1953049887387303904', '1346358560427216896', '1953048313980116903', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO `permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1953049887387303905', '1346358560427216896', '1953048313980116904', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); diff --git a/db/upgrade/2.7.0-upgrade-2.7.1-og.sql b/db/upgrade/2.7.0-upgrade-2.7.1-og.sql index 4f6cf7a2ff..be9366ac7b 100644 --- a/db/upgrade/2.7.0-upgrade-2.7.1-og.sql +++ b/db/upgrade/2.7.0-upgrade-2.7.1-og.sql @@ -243,4 +243,42 @@ INSERT INTO "public"."permission" VALUES ('1697146861569542756', '13463585604272 INSERT INTO "public"."permission" VALUES ('1697146861569542757', '1346358560427216896', '1844026199075534866', '2023-08-31 07:18:37', '2023-08-31 07:18:37'); INSERT INTO "public"."permission" VALUES ('1697146861569542758', '1346358560427216896', '1844026199075534867', '2023-08-31 07:18:37', '2023-08-31 07:18:37'); INSERT INTO "public"."permission" VALUES ('1697146861569542759', '1346358560427216896', '1844026199075534868', '2023-08-31 07:18:37', '2023-08-31 07:18:37'); -INSERT INTO "public"."permission" VALUES ('1697146861569542760', '1346358560427216896', '1844026199075534869', '2023-08-31 07:18:37', '2023-08-31 07:18:37'); \ No newline at end of file +INSERT INTO "public"."permission" VALUES ('1697146861569542760', '1346358560427216896', '1844026199075534869', '2023-08-31 07:18:37', '2023-08-31 07:18:37'); + +DROP TABLE IF EXISTS "public"."registry_config"; +CREATE TABLE "public"."registry_config" ( + "id" varchar(128) NOT NULL, + "registry_id" varchar(50) NOT NULL, + "protocol" varchar(128) NOT NULL, + "address" varchar(512) NOT NULL, + "username" varchar(50), + "password" varchar(100), + "namespace" varchar(100), + "group" varchar(20), + "date_created" timestamp(3) NOT NULL DEFAULT timezone('UTC-8'::text, (now())::timestamp(0) without time zone), + "date_updated" timestamp(3) NOT NULL DEFAULT timezone('UTC-8'::text, (now())::timestamp(0) without time zone), + PRIMARY KEY ("id") +); + +COMMENT ON COLUMN "public"."registry_config"."id" IS 'primary key'; +COMMENT ON COLUMN "public"."registry_config"."registry_id" IS 'registry_id'; +COMMENT ON COLUMN "public"."registry_config"."protocol" IS 'protocol'; +COMMENT ON COLUMN "public"."registry_config"."address" IS 'address'; +COMMENT ON COLUMN "public"."registry_config"."username" IS 'username'; +COMMENT ON COLUMN "public"."registry_config"."password" IS 'password'; +COMMENT ON COLUMN "public"."registry_config"."namespace" IS 'namespace'; +COMMENT ON COLUMN "public"."registry_config"."group" IS 'group'; +COMMENT ON COLUMN "public"."registry_config"."date_created" IS 'create time'; +COMMENT ON COLUMN "public"."registry_config"."date_updated" IS 'update time'; + +INSERT INTO "public"."resource" VALUES ('1953048313980116900', '1357956838021890048', 'SHENYU.MENU.SYSTEM.MANAGMENT.REGISTRY', 'registry', '/config/registry', 'registry', 1, 7, 'ordered-list', 0, 0, '', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."resource" VALUES ('1953048313980116901', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.ADD', '', '', '', 2, 0, '', 1, 0, 'system:registry:add', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."resource" VALUES ('1953048313980116902', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.LIST', '', '', '', 2, 1, '', 1, 0, 'system:registry:list', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."resource" VALUES ('1953048313980116903', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.DELETE', '', '', '', 2, 2, '', 1, 0, 'system:registry:delete', 1,'2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."resource" VALUES ('1953048313980116904', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.EDIT', '', '', '', 2, 3, '', 1, 0, 'system:registry:edit', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); + +INSERT INTO "public"."permission" VALUES ('1953049887387303901', '1346358560427216896', '1953048313980116900', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."permission" VALUES ('1953049887387303902', '1346358560427216896', '1953048313980116901', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."permission" VALUES ('1953049887387303903', '1346358560427216896', '1953048313980116902', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."permission" VALUES ('1953049887387303904', '1346358560427216896', '1953048313980116903', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."permission" VALUES ('1953049887387303905', '1346358560427216896', '1953048313980116904', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); diff --git a/db/upgrade/2.7.0-upgrade-2.7.1-oracle.sql b/db/upgrade/2.7.0-upgrade-2.7.1-oracle.sql index 704193cae0..fb5df4f0c2 100755 --- a/db/upgrade/2.7.0-upgrade-2.7.1-oracle.sql +++ b/db/upgrade/2.7.0-upgrade-2.7.1-oracle.sql @@ -523,4 +523,47 @@ INSERT INTO permission (id, role_id, resource_id, date_created, date_updated) VA INSERT INTO permission (id, role_id, resource_id, date_created, date_updated) VALUES ('1697146861569542757', '1346358560427216896', '1844026199075534866', sysdate, sysdate); INSERT INTO permission (id, role_id, resource_id, date_created, date_updated) VALUES ('1697146861569542758', '1346358560427216896', '1844026199075534867', sysdate, sysdate); INSERT INTO permission (id, role_id, resource_id, date_created, date_updated) VALUES ('1697146861569542759', '1346358560427216896', '1844026199075534868', sysdate, sysdate); -INSERT INTO permission (id, role_id, resource_id, date_created, date_updated) VALUES ('1697146861569542760', '1346358560427216896', '1844026199075534869', sysdate, sysdate); \ No newline at end of file +INSERT INTO permission (id, role_id, resource_id, date_created, date_updated) VALUES ('1697146861569542760', '1346358560427216896', '1844026199075534869', sysdate, sysdate); + +CREATE TABLE registry_config ( + id varchar2(128) NOT NULL, + registry_id varchar2(50) NOT NULL, + protocol varchar2(128) NOT NULL, + address varchar2(512) NOT NULL, + username varchar2(50), + password varchar2(100), + namespace varchar2(100), + group varchar2(20), + date_created timestamp(3) DEFAULT SYSTIMESTAMP NOT NULL, + date_updated timestamp(3) DEFAULT SYSTIMESTAMP NOT NULL, + CONSTRAINT registry_config_pk PRIMARY KEY (id) +); + +COMMENT ON TABLE registry_config IS 'registry config information table'; +COMMENT ON COLUMN registry_config.id IS 'primary key'; +COMMENT ON COLUMN registry_config.registry_id IS 'registry_id'; +COMMENT ON COLUMN registry_config.protocol IS 'protocol'; +COMMENT ON COLUMN registry_config.address IS 'address'; +COMMENT ON COLUMN registry_config.username IS 'username'; +COMMENT ON COLUMN registry_config.password IS 'password'; +COMMENT ON COLUMN registry_config.namespace IS 'namespace'; +COMMENT ON COLUMN registry_config.group IS 'group'; +COMMENT ON COLUMN registry_config.date_created IS 'create time'; +COMMENT ON COLUMN registry_config.date_updated IS 'update time'; + +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, date_created, date_updated) +VALUES ('1953048313980116900', '1357956838021890048', 'SHENYU.MENU.SYSTEM.MANAGMENT.REGISTRY', 'registry', '/config/registry', 'registry', 1, 7, 'ordered-list', 0, 0, '', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +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, date_created, date_updated) +VALUES ('1953048313980116901', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.ADD', '', '', '', 2, 0, '', 1, 0, 'system:registry:add', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +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, date_created, date_updated) +VALUES ('1953048313980116902', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.LIST', '', '', '', 2, 1, '', 1, 0, 'system:registry:list', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +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, date_created, date_updated) +VALUES ('1953048313980116903', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.DELETE', '', '', '', 2, 2, '', 1, 0, 'system:registry:delete', 1,'2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +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, date_created, date_updated) +VALUES ('1953048313980116904', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.EDIT', '', '', '', 2, 3, '', 1, 0, 'system:registry:edit', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); + +INSERT INTO permission (id, role_id, resource_id, date_created, date_updated) VALUES ('1953049887387303901', '1346358560427216896', '1953048313980116900', sysdate, sysdate); +INSERT INTO permission (id, role_id, resource_id, date_created, date_updated) VALUES ('1953049887387303902', '1346358560427216896', '1953048313980116901', sysdate, sysdate); +INSERT INTO permission (id, role_id, resource_id, date_created, date_updated) VALUES ('1953049887387303903', '1346358560427216896', '1953048313980116902', sysdate, sysdate); +INSERT INTO permission (id, role_id, resource_id, date_created, date_updated) VALUES ('1953049887387303904', '1346358560427216896', '1953048313980116903', sysdate, sysdate); +INSERT INTO permission (id, role_id, resource_id, date_created, date_updated) VALUES ('1953049887387303905', '1346358560427216896', '1953048313980116904', sysdate, sysdate); \ No newline at end of file diff --git a/db/upgrade/2.7.0-upgrade-2.7.1-pg.sql b/db/upgrade/2.7.0-upgrade-2.7.1-pg.sql index c7c06386f0..ca5256a046 100755 --- a/db/upgrade/2.7.0-upgrade-2.7.1-pg.sql +++ b/db/upgrade/2.7.0-upgrade-2.7.1-pg.sql @@ -242,4 +242,41 @@ INSERT INTO "public"."permission" VALUES ('1697146861569542756', '13463585604272 INSERT INTO "public"."permission" VALUES ('1697146861569542757', '1346358560427216896', '1844026199075534866', '2023-08-31 07:18:37', '2023-08-31 07:18:37'); INSERT INTO "public"."permission" VALUES ('1697146861569542758', '1346358560427216896', '1844026199075534867', '2023-08-31 07:18:37', '2023-08-31 07:18:37'); INSERT INTO "public"."permission" VALUES ('1697146861569542759', '1346358560427216896', '1844026199075534868', '2023-08-31 07:18:37', '2023-08-31 07:18:37'); -INSERT INTO "public"."permission" VALUES ('1697146861569542760', '1346358560427216896', '1844026199075534869', '2023-08-31 07:18:37', '2023-08-31 07:18:37'); \ No newline at end of file +INSERT INTO "public"."permission" VALUES ('1697146861569542760', '1346358560427216896', '1844026199075534869', '2023-08-31 07:18:37', '2023-08-31 07:18:37'); + +DROP TABLE IF EXISTS "public"."registry_config"; +CREATE TABLE "public"."registry_config" ( + "id" varchar(128) NOT NULL, + "registry_id" varchar(50) NOT NULL, + "protocol" varchar(128) NOT NULL, + "address" varchar(512) NOT NULL, + "username" varchar(50), + "password" varchar(100), + "namespace" varchar(100), + "group" varchar(20), + "date_created" timestamp(3) NOT NULL DEFAULT timezone('UTC-8'::text, (now())::timestamp(0) without time zone), + "date_updated" timestamp(3) NOT NULL DEFAULT timezone('UTC-8'::text, (now())::timestamp(0) without time zone), + PRIMARY KEY ("id") +); +COMMENT ON COLUMN "public"."registry_config"."id" IS 'primary key'; +COMMENT ON COLUMN "public"."registry_config"."registry_id" IS 'registry_id'; +COMMENT ON COLUMN "public"."registry_config"."protocol" IS 'protocol'; +COMMENT ON COLUMN "public"."registry_config"."address" IS 'address'; +COMMENT ON COLUMN "public"."registry_config"."username" IS 'username'; +COMMENT ON COLUMN "public"."registry_config"."password" IS 'password'; +COMMENT ON COLUMN "public"."registry_config"."namespace" IS 'namespace'; +COMMENT ON COLUMN "public"."registry_config"."group" IS 'group'; +COMMENT ON COLUMN "public"."registry_config"."date_created" IS 'create time'; +COMMENT ON COLUMN "public"."registry_config"."date_updated" IS 'update time'; + +INSERT INTO "public"."resource" VALUES ('1953048313980116900', '1357956838021890048', 'SHENYU.MENU.SYSTEM.MANAGMENT.REGISTRY', 'registry', '/config/registry', 'registry', 1, 7, 'ordered-list', 0, 0, '', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."resource" VALUES ('1953048313980116901', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.ADD', '', '', '', 2, 0, '', 1, 0, 'system:registry:add', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."resource" VALUES ('1953048313980116902', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.LIST', '', '', '', 2, 1, '', 1, 0, 'system:registry:list', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."resource" VALUES ('1953048313980116903', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.DELETE', '', '', '', 2, 2, '', 1, 0, 'system:registry:delete', 1,'2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."resource" VALUES ('1953048313980116904', '1953048313980116900', 'SHENYU.BUTTON.SYSTEM.EDIT', '', '', '', 2, 3, '', 1, 0, 'system:registry:edit', 1, '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); + +INSERT INTO "public"."permission" VALUES ('1953049887387303901', '1346358560427216896', '1953048313980116900', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."permission" VALUES ('1953049887387303902', '1346358560427216896', '1953048313980116901', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."permission" VALUES ('1953049887387303903', '1346358560427216896', '1953048313980116902', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."permission" VALUES ('1953049887387303904', '1346358560427216896', '1953048313980116903', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); +INSERT INTO "public"."permission" VALUES ('1953049887387303905', '1346358560427216896', '1953048313980116904', '2025-08-06 17:00:00.000', '2025-08-06 17:00:00.000'); \ No newline at end of file diff --git a/shenyu-admin/src/http/http-debug-registry-config-controller-api.http b/shenyu-admin/src/http/http-debug-registry-config-controller-api.http new file mode 100644 index 0000000000..389929b1d6 --- /dev/null +++ b/shenyu-admin/src/http/http-debug-registry-config-controller-api.http @@ -0,0 +1,79 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# if you debug api, replace your own token + +### registry create +POST http://localhost:9095/registry/insertOrUpdate +Accept: application/json +Content-Type: application/json +X-Access-Token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjbGllbnRJZCI6IjhmMmE2ZDQ2YzU4ODRhODViNGViY2NiMTM5NTJiODQzIiwidXNlck5hbWUiOiJhZG1pbiIsImV4cCI6MTc1NDkwNTIzMH0.YA5XcsMcsAQnmQZPhjAB1Dz1woIxQB0sFv9mbAc8rcY + +{ + "registryId": "nacos-2", + "protocol": "nacos", + "address": "127.0.0.1:8848", + "username": "nacos", + "password": "nacos", + "namespace": "test-namespace", + "group": null +} + +### registry update +POST http://localhost:9095/registry/insertOrUpdate +Accept: application/json +Content-Type: application/json +X-Access-Token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjbGllbnRJZCI6IjhmMmE2ZDQ2YzU4ODRhODViNGViY2NiMTM5NTJiODQzIiwidXNlck5hbWUiOiJhZG1pbiIsImV4cCI6MTc1NDkwNTIzMH0.YA5XcsMcsAQnmQZPhjAB1Dz1woIxQB0sFv9mbAc8rcY + +{ + "id": "1954478410339516416", + "registryId": "nacos-1", + "protocol": "nacos", + "address": "127.0.0.1:8848", + "username": "nacos", + "password": "nacos", + "namespace": "test_local", + "group": null +} + +### regisrty list by page +GET http://localhost:9095/registry/findPageByQuery?currentPage=1&pageSize=10®istryId=nacos&address=127.0.0.1 +Accept: application/json +Content-Type: application/json +X-Access-Token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjbGllbnRJZCI6IjhmMmE2ZDQ2YzU4ODRhODViNGViY2NiMTM5NTJiODQzIiwidXNlck5hbWUiOiJhZG1pbiIsImV4cCI6MTc1NDkwNTIzMH0.YA5XcsMcsAQnmQZPhjAB1Dz1woIxQB0sFv9mbAc8rcY + +### regisrty list +GET http://localhost:9095/registry/list +Accept: application/json +Content-Type: application/json +X-Access-Token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjbGllbnRJZCI6IjhmMmE2ZDQ2YzU4ODRhODViNGViY2NiMTM5NTJiODQzIiwidXNlck5hbWUiOiJhZG1pbiIsImV4cCI6MTc1NDkwNTIzMH0.YA5XcsMcsAQnmQZPhjAB1Dz1woIxQB0sFv9mbAc8rcY + +### regisrty detail +GET http://localhost:9095/registry/1954478410339516416 +Accept: application/json +Content-Type: application/json +X-Access-Token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjbGllbnRJZCI6IjhmMmE2ZDQ2YzU4ODRhODViNGViY2NiMTM5NTJiODQzIiwidXNlck5hbWUiOiJhZG1pbiIsImV4cCI6MTc1NDkwNTIzMH0.YA5XcsMcsAQnmQZPhjAB1Dz1woIxQB0sFv9mbAc8rcY + +### regisrty delete +DELETE http://localhost:9095/registry/batch +Accept: application/json +Content-Type: application/json +X-Access-Token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjbGllbnRJZCI6ImEzY2NhMzc3YTU4ZTRjOGZiMWE4YTI5MTQ0ZThhNzcyIiwidXNlck5hbWUiOiJhZG1pbiIsImV4cCI6MTc1NDU1NTE4OX0.2VYA-n1VCoOjziijteN8r2IOdyErZ9FtmBkOYScwdWM + +[ + "1953018066451435520" +] diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/RegistryController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/RegistryController.java new file mode 100644 index 0000000000..74e9340c1d --- /dev/null +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/RegistryController.java @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shenyu.admin.controller; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import org.apache.shenyu.admin.aspect.annotation.RestApi; +import org.apache.shenyu.admin.mapper.RegistryMapper; +import org.apache.shenyu.admin.model.dto.RegistryDTO; +import org.apache.shenyu.admin.model.page.CommonPager; +import org.apache.shenyu.admin.model.page.PageParameter; +import org.apache.shenyu.admin.model.query.RegistryQuery; +import org.apache.shenyu.admin.model.result.ShenyuAdminResult; +import org.apache.shenyu.admin.model.vo.RegistryVO; +import org.apache.shenyu.admin.service.impl.RegistryServiceImpl; +import org.apache.shenyu.admin.utils.ShenyuResultMessage; +import org.apache.shenyu.admin.validation.annotation.Existed; +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +@RestApi("/registry") +public class RegistryController { + + private final RegistryServiceImpl registryService; + + public RegistryController(final RegistryServiceImpl registryService) { + this.registryService = registryService; + } + + /** + * Find registry page by query. + * + * @param registryId the registry registryId + * @param address the registry address + * @param namespace the registry namespace + * @param currentPage current page of list + * @param pageSize page size of query + * @return the shenyu result + */ + @GetMapping("/findPageByQuery") + @RequiresPermissions("system:registry:list") + public ShenyuAdminResult findPageByQuery(final String registryId, final String address, final String namespace, + @RequestParam @NotNull(message = "currentPage not null") final Integer currentPage, + @RequestParam @NotNull(message = "pageSize not null") final Integer pageSize) { + RegistryQuery query = new RegistryQuery(); + query.setRegistryId(registryId); + query.setAddress(address); + query.setNamespace(namespace); + query.setPageParameter(new PageParameter(currentPage, pageSize)); + CommonPager<RegistryVO> commonPager = registryService.listByPage(query); + return ShenyuAdminResult.success(ShenyuResultMessage.QUERY_SUCCESS, commonPager); + } + + /** + * Find registry list. + * + * @return the shenyu result + */ + @GetMapping("/list") + @RequiresPermissions("system:registry:list") + public ShenyuAdminResult list() { + return ShenyuAdminResult.success(ShenyuResultMessage.QUERY_SUCCESS, registryService.listAll()); + } + + + /** + * Insert or update registry. + * + * @param registryDTO {@link RegistryDTO} + * @return {@linkplain ShenyuAdminResult} + */ + @PostMapping("/insertOrUpdate") + @RequiresPermissions(value = {"system:registry:add", "system:registry:edit"}, logical = Logical.OR) + public ShenyuAdminResult createOrUpdate(@Valid @RequestBody final RegistryDTO registryDTO) { + return ShenyuAdminResult.success(ShenyuResultMessage.SUCCESS, registryService.createOrUpdate(registryDTO)); + } + + /** + * delete by id. + * + * @param ids ids + * @return {@linkplain ShenyuAdminResult} + */ + @DeleteMapping("/batch") + @RequiresPermissions("system:registry:delete") + public ShenyuAdminResult delete(@RequestBody final List<@NotBlank String> ids) { + return ShenyuAdminResult.success(ShenyuResultMessage.SUCCESS, registryService.delete(ids)); + } + + /** + * detail registry. + * + * @param id registry id. + * @return {@linkplain ShenyuAdminResult} + */ + @GetMapping("/{id}") + @RequiresPermissions("system:registry:edit") + public ShenyuAdminResult detailPlugin(@PathVariable("id") + @Existed(message = "id is not existed", + provider = RegistryMapper.class) final String id) { + RegistryVO registryVO = registryService.findById(id); + return ShenyuAdminResult.success(ShenyuResultMessage.DETAIL_SUCCESS, registryVO); + } +} diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/RegistryMapper.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/RegistryMapper.java new file mode 100644 index 0000000000..13c20bc6fa --- /dev/null +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/RegistryMapper.java @@ -0,0 +1,132 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shenyu.admin.mapper; + +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.shenyu.admin.model.entity.RegistryDO; +import org.apache.shenyu.admin.model.query.RegistryQuery; +import org.apache.shenyu.admin.validation.ExistProvider; + +import java.io.Serializable; +import java.util.List; + +/** + * RegistryMapper. + */ +@Mapper +public interface RegistryMapper extends ExistProvider { + + /** + * existed. + * + * @param id id + * @return existed + */ + @Override + Boolean existed(@Param("id") Serializable id); + + /** + * select registry by id. + * + * @param id primary key. + * @return {@linkplain RegistryDO} + */ + RegistryDO selectById(String id); + + /** + * select registry by registryId. + * + * @param registryId registryId. + * @return {@linkplain RegistryDO} + */ + RegistryDO selectByRegistryId(String registryId); + + /** + * selectAll. + * + * @return registryDOList + */ + List<RegistryDO> selectAll(); + + /** + * insert registry. + * + * @param registryDO registryDO. + * @return rows + */ + int insert(RegistryDO registryDO); + + + /** + * insert registry. + * + * @param registryDO registryDO. + * @return rows + */ + int insertSelective(RegistryDO registryDO); + + + /** + * update registry. + * + * @param registryDO {@linkplain RegistryDO} + * @return rows + */ + int update(RegistryDO registryDO); + + /** + * update registry. + * + * @param registryDO {@linkplain RegistryDO} + * @return rows + */ + int updateSelective(RegistryDO registryDO); + + /** + * count registry by query. + * + * @param registryQuery {@linkplain RegistryQuery} + * @return {@linkplain Integer} + */ + Integer countByQuery(RegistryQuery registryQuery); + + /** + * select registry by query. + * + * @param registryQuery {@linkplain RegistryQuery} + * @return {@linkplain List} + */ + List<RegistryDO> selectByQuery(RegistryQuery registryQuery); + + /** + * select registry by ids. + * + * @param ids ids. + * @return {@linkplain RegistryDO} + */ + List<RegistryDO> selectByIds(List<String> ids); + + /** + * delete registry. + * + * @param ids primary keys. + * @return rows int + */ + int deleteByIds(List<String> ids); +} diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/RegistryDTO.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/RegistryDTO.java new file mode 100644 index 0000000000..20d47b24f8 --- /dev/null +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/RegistryDTO.java @@ -0,0 +1,199 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shenyu.admin.model.dto; + +import java.io.Serializable; + +import jakarta.validation.constraints.NotNull; +import org.hibernate.validator.constraints.Length; + +/** + * RegistryDTO. + */ +public class RegistryDTO implements Serializable { + + private String id; + + @Length(max = 128, message = "The maximum length is 128") + @NotNull(message = "registry code not null") + private String registryId; + + @Length(max = 128, message = "The maximum length is 128") + @NotNull(message = "registry protocol not null") + private String protocol; + + @Length(max = 100, message = "The maximum length is 100") + @NotNull(message = "address null") + private String address; + + @Length(max = 50, message = "The maximum length is 50") + private String username; + + @Length(max = 100, message = "The maximum length is 100") + private String password; + + @Length(max = 100, message = "The maximum length is 100") + private String namespace; + + @Length(max = 20, message = "The maximum length is 20") + private String group; + + /** + * Gets the value of id. + * + * @return the value of id + */ + public String getId() { + return id; + } + + /** + * Sets the id. + * + * @param id id + */ + public void setId(final String id) { + this.id = id; + } + + /** + * Gets the value of registryId. + * + * @return the value of registryId + */ + public String getRegistryId() { + return registryId; + } + + /** + * Sets the registryId. + * + * @param registryId registryId + */ + public void setRegistryId(final String registryId) { + this.registryId = registryId; + } + + /** + * Gets the value of protocol. + * + * @return the value of protocol + */ + public String getProtocol() { + return protocol; + } + + /** + * Sets the protocol. + * + * @param protocol protocol + */ + public void setProtocol(final String protocol) { + this.protocol = protocol; + } + + /** + * Gets the value of address. + * + * @return the value of address + */ + public String getAddress() { + return address; + } + + /** + * Sets the address. + * + * @param address address + */ + public void setAddress(final String address) { + this.address = address; + } + + /** + * Gets the value of username. + * + * @return the value of username + */ + public String getUsername() { + return username; + } + + /** + * Sets the username. + * + * @param username username + */ + public void setUsername(final String username) { + this.username = username; + } + + /** + * Gets the value of password. + * + * @return the value of password + */ + public String getPassword() { + return password; + } + + /** + * Sets the password. + * + * @param password password + */ + public void setPassword(final String password) { + this.password = password; + } + + /** + * Gets the value of namespace. + * + * @return the value of namespace + */ + public String getNamespace() { + return namespace; + } + + /** + * Sets the namespace. + * + * @param namespace namespace + */ + public void setNamespace(final String namespace) { + this.namespace = namespace; + } + + /** + * Gets the value of group. + * + * @return the value of group + */ + public String getGroup() { + return group; + } + + /** + * Sets the group. + * + * @param group group + */ + public void setGroup(final String group) { + this.group = group; + } +} diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/RegistryDO.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/RegistryDO.java new file mode 100644 index 0000000000..d84e775a33 --- /dev/null +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/RegistryDO.java @@ -0,0 +1,352 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shenyu.admin.model.entity; + +import java.sql.Timestamp; + +/** + * Registry do. + */ +public class RegistryDO extends BaseDO { + + /** + * the model registryId. + */ + private String registryId; + + /** + * the model protocol. + */ + private String protocol; + + /** + * the model address. + */ + private String address; + + /** + * the model username. + */ + private String username; + + /** + * the model password. + */ + private String password; + + /** + * the model namespace. + */ + private String namespace; + + /** + * the model group. + */ + private String group; + + /** + * Gets the value of registryId. + * + * @return the value of registryId + */ + public String getRegistryId() { + return registryId; + } + + /** + * Sets the registryId. + * + * @param registryId registryId + */ + public void setRegistryId(final String registryId) { + this.registryId = registryId; + } + + /** + * Gets the value of protocol. + * + * @return the value of protocol + */ + public String getProtocol() { + return protocol; + } + + /** + * Sets the protocol. + * + * @param protocol protocol + */ + public void setProtocol(final String protocol) { + this.protocol = protocol; + } + + /** + * Gets the value of address. + * + * @return the value of address + */ + public String getAddress() { + return address; + } + + /** + * Sets the address. + * + * @param address address + */ + public void setAddress(final String address) { + this.address = address; + } + + /** + * Gets the value of username. + * + * @return the value of username + */ + public String getUsername() { + return username; + } + + /** + * Sets the username. + * + * @param username username + */ + public void setUsername(final String username) { + this.username = username; + } + + /** + * Gets the value of password. + * + * @return the value of password + */ + public String getPassword() { + return password; + } + + /** + * Sets the password. + * + * @param password password + */ + public void setPassword(final String password) { + this.password = password; + } + + /** + * Gets the value of namespace. + * + * @return the value of namespace + */ + public String getNamespace() { + return namespace; + } + + /** + * Sets the namespace. + * + * @param namespace namespace + */ + public void setNamespace(final String namespace) { + this.namespace = namespace; + } + + /** + * Gets the value of group. + * + * @return the value of group + */ + public String getGroup() { + return group; + } + + /** + * Sets the group. + * + * @param group group + */ + public void setGroup(final String group) { + this.group = group; + } + + /** + * builder. + * + * @return RegistryDOBuilder + */ + public static RegistryDOBuilder builder() { + return new RegistryDO.RegistryDOBuilder(); + } + + public static final class RegistryDOBuilder { + + private String id; + + private Timestamp dateCreated; + + private Timestamp dateUpdated; + + private String registryId; + + private String protocol; + + private String address; + + private String username; + + private String password; + + private String namespace; + + private String group; + + private RegistryDOBuilder() { + } + + /** + * id. + * + * @param id the id. + * @return RegistryDOBuilder. + */ + public RegistryDOBuilder id(final String id) { + this.id = id; + return this; + } + + /** + * dateCreated. + * + * @param dateCreated the dateCreated. + * @return RegistryDOBuilder. + */ + public RegistryDOBuilder dateCreated(final Timestamp dateCreated) { + this.dateCreated = dateCreated; + return this; + } + + /** + * dateUpdated. + * + * @param dateUpdated the dateUpdated. + * @return RegistryDOBuilder. + */ + public RegistryDOBuilder dateUpdated(final Timestamp dateUpdated) { + this.dateUpdated = dateUpdated; + return this; + } + + /** + * registryId. + * + * @param registryId the registryId. + * @return RegistryDOBuilder. + */ + public RegistryDOBuilder registryId(final String registryId) { + this.registryId = registryId; + return this; + } + + /** + * protocol. + * + * @param protocol the protocol. + * @return RegistryDOBuilder. + */ + public RegistryDOBuilder protocol(final String protocol) { + this.protocol = protocol; + return this; + } + + /** + * address. + * + * @param address the address. + * @return RegistryDOBuilder. + */ + public RegistryDOBuilder address(final String address) { + this.address = address; + return this; + } + + /** + * username. + * + * @param username the username. + * @return RegistryDOBuilder. + */ + public RegistryDOBuilder username(final String username) { + this.username = username; + return this; + } + + /** + * password. + * + * @param password the password. + * @return RegistryDOBuilder. + */ + public RegistryDOBuilder password(final String password) { + this.password = password; + return this; + } + + /** + * namespace. + * + * @param namespace the namespace. + * @return RegistryDOBuilder. + */ + public RegistryDOBuilder namespace(final String namespace) { + this.namespace = namespace; + return this; + } + + /** + * group. + * + * @param group the group. + * @return RegistryDOBuilder. + */ + public RegistryDOBuilder group(final String group) { + this.group = group; + return this; + } + + /** + * build method. + * + * @return build object. + */ + public RegistryDO build() { + RegistryDO registryDO = new RegistryDO(); + registryDO.setId(id); + registryDO.setDateCreated(dateCreated); + registryDO.setDateUpdated(dateUpdated); + registryDO.setRegistryId(registryId); + registryDO.setProtocol(protocol); + registryDO.setAddress(address); + registryDO.setUsername(username); + registryDO.setPassword(password); + registryDO.setNamespace(namespace); + registryDO.setGroup(group); + return registryDO; + } + } +} diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/query/RegistryQuery.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/query/RegistryQuery.java new file mode 100644 index 0000000000..6316c4d7f4 --- /dev/null +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/query/RegistryQuery.java @@ -0,0 +1,139 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shenyu.admin.model.query; + +import org.apache.shenyu.admin.model.page.PageParameter; + +import java.io.Serializable; +import java.util.Objects; + +/** + * this is registry query. + */ +public class RegistryQuery implements Serializable { + + /** + * registryId. + */ + private String registryId; + + /** + * address. + */ + private String address; + + /** + * namespace. + */ + private String namespace; + + /** + * page parameter. + */ + private PageParameter pageParameter; + + /** + * Gets the value of registryId. + * + * @return the value of registryId + */ + public String getRegistryId() { + return registryId; + } + + /** + * Sets the registryId. + * + * @param registryId registryId + */ + public void setRegistryId(final String registryId) { + this.registryId = registryId; + } + + /** + * Gets the value of address. + * + * @return the value of address + */ + public String getAddress() { + return address; + } + + /** + * Sets the address. + * + * @param address address + */ + public void setAddress(final String address) { + this.address = address; + } + + /** + * Gets the value of namespace. + * + * @return the value of namespace + */ + public String getNamespace() { + return namespace; + } + + /** + * Sets the namespace. + * + * @param namespace namespace + */ + public void setNamespace(final String namespace) { + this.namespace = namespace; + } + + /** + * Gets the value of getPageParameter. + * + * @return the value of getPageParameter + */ + public PageParameter getPageParameter() { + return pageParameter; + } + + /** + * Sets the pageParameter. + * + * @param pageParameter pageParameter + */ + public void setPageParameter(final PageParameter pageParameter) { + this.pageParameter = pageParameter; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (Objects.isNull(o) || getClass() != o.getClass()) { + return false; + } + RegistryQuery that = (RegistryQuery) o; + return Objects.equals(registryId, that.registryId) && Objects.equals(address, that.address) + && Objects.equals(namespace, that.namespace) && Objects.equals(pageParameter, that.pageParameter); + } + + @Override + public int hashCode() { + return Objects.hash(registryId, address, namespace, pageParameter); + } +} diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/RegistryVO.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/RegistryVO.java new file mode 100644 index 0000000000..d030ac79f2 --- /dev/null +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/RegistryVO.java @@ -0,0 +1,212 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shenyu.admin.model.vo; + +import java.io.Serializable; + +/** + * RegistryVO. + */ +public class RegistryVO implements Serializable { + + private static final long serialVersionUID = 8274916350247389561L; + + /** + * id. + */ + private String id; + + /** + * registryId. + */ + private String registryId; + + /** + * protocol. + */ + private String protocol; + + /** + * address. + */ + private String address; + + /** + * username. + */ + private String username; + + /** + * password. + */ + private String password; + + /** + * namespace. + */ + private String namespace; + + /** + * group. + */ + private String group; + + /** + * Gets the value of id. + * + * @return the value of id + */ + public String getId() { + return id; + } + + /** + * Sets the id. + * + * @param id id + */ + public void setId(final String id) { + this.id = id; + } + + /** + * Gets the value of registryId. + * + * @return the value of registryId + */ + public String getRegistryId() { + return registryId; + } + + /** + * Sets the registryId. + * + * @param registryId registryId + */ + public void setRegistryId(final String registryId) { + this.registryId = registryId; + } + + /** + * Gets the value of protocol. + * + * @return the value of protocol + */ + public String getProtocol() { + return protocol; + } + + /** + * Sets the protocol. + * + * @param protocol protocol + */ + public void setProtocol(final String protocol) { + this.protocol = protocol; + } + + /** + * Gets the value of address. + * + * @return the value of address + */ + public String getAddress() { + return address; + } + + /** + * Sets the address. + * + * @param address address + */ + public void setAddress(final String address) { + this.address = address; + } + + /** + * Gets the value of username. + * + * @return the value of username + */ + public String getUsername() { + return username; + } + + /** + * Sets the username. + * + * @param username username + */ + public void setUsername(final String username) { + this.username = username; + } + + /** + * Gets the value of password. + * + * @return the value of password + */ + public String getPassword() { + return password; + } + + /** + * Sets the password. + * + * @param password password + */ + public void setPassword(final String password) { + this.password = password; + } + + /** + * Gets the value of namespace. + * + * @return the value of namespace + */ + public String getNamespace() { + return namespace; + } + + /** + * Sets the namespace. + * + * @param namespace namespace + */ + public void setNamespace(final String namespace) { + this.namespace = namespace; + } + + /** + * Gets the value of group. + * + * @return the value of group + */ + public String getGroup() { + return group; + } + + /** + * Sets the group. + * + * @param group group + */ + public void setGroup(final String group) { + this.group = group; + } +} diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/RegistryService.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/RegistryService.java new file mode 100644 index 0000000000..d9abe45395 --- /dev/null +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/RegistryService.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shenyu.admin.service; + +import org.apache.shenyu.admin.model.dto.RegistryDTO; +import org.apache.shenyu.admin.model.page.CommonPager; +import org.apache.shenyu.admin.model.query.RegistryQuery; +import org.apache.shenyu.admin.model.vo.RegistryVO; + +import java.util.List; + +public interface RegistryService { + + /** + * Create or update registry. + * + * @param registryDTO the registry dto + * @return the string + */ + RegistryVO createOrUpdate(RegistryDTO registryDTO); + + /** + * find page of registry by query. + * + * @param registryQuery {@linkplain RegistryQuery} + * @return {@linkplain CommonPager} + */ + CommonPager<RegistryVO> listByPage(RegistryQuery registryQuery); + + /** + * delete by id. + * + * @param ids ids + * @return msg + */ + String delete(List<String> ids); + + /** + * find registry by id. + * + * @param id id. + * @return {@linkplain RegistryVO} + */ + RegistryVO findById(String id); + + /** + * find registry by registryId. + * + * @param registryId registryId. + * @return {@linkplain RegistryVO} + */ + RegistryVO findByRegistryId(String registryId); + + /** + * find list of registry. + * + * @return {@linkplain List} + */ + List<RegistryVO> listAll(); +} diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/RegistryServiceImpl.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/RegistryServiceImpl.java new file mode 100644 index 0000000000..ae5e3ce6a1 --- /dev/null +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/RegistryServiceImpl.java @@ -0,0 +1,134 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shenyu.admin.service.impl; + +import org.apache.commons.lang3.StringUtils; +import org.apache.shenyu.admin.exception.ShenyuAdminException; +import org.apache.shenyu.admin.mapper.RegistryMapper; +import org.apache.shenyu.admin.model.dto.RegistryDTO; +import org.apache.shenyu.admin.model.entity.RegistryDO; +import org.apache.shenyu.admin.model.page.CommonPager; +import org.apache.shenyu.admin.model.page.PageResultUtils; +import org.apache.shenyu.admin.model.query.RegistryQuery; +import org.apache.shenyu.admin.model.vo.RegistryVO; +import org.apache.shenyu.admin.service.RegistryService; +import org.apache.shenyu.admin.transfer.RegistryTransfer; +import org.apache.shenyu.admin.utils.ShenyuResultMessage; +import org.apache.shenyu.common.utils.UUIDUtils; +import org.springframework.stereotype.Service; + +import java.sql.Timestamp; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +@Service +public class RegistryServiceImpl implements RegistryService { + + private final RegistryMapper registryMapper; + + public RegistryServiceImpl(final RegistryMapper registryMapper) { + this.registryMapper = registryMapper; + } + + @Override + public RegistryVO createOrUpdate(final RegistryDTO registryDTO) { + return StringUtils.isBlank(registryDTO.getId()) + ? this.create(registryDTO) : this.update(registryDTO); + } + + @Override + public CommonPager<RegistryVO> listByPage(final RegistryQuery registryQuery) { + return PageResultUtils.result(registryQuery.getPageParameter(), () -> registryMapper.countByQuery(registryQuery), () -> registryMapper.selectByQuery(registryQuery) + .stream() + .map(RegistryTransfer.INSTANCE::mapToVo) + .collect(Collectors.toList())); + } + + @Override + public String delete(final List<String> ids) { + registryMapper.deleteByIds(ids); + return ShenyuResultMessage.DELETE_SUCCESS; + } + + @Override + public RegistryVO findById(final String id) { + return RegistryTransfer.INSTANCE.mapToVo(registryMapper.selectById(id)); + } + + @Override + public RegistryVO findByRegistryId(final String registryId) { + return RegistryTransfer.INSTANCE.mapToVo(registryMapper.selectByRegistryId(registryId)); + } + + @Override + public List<RegistryVO> listAll() { + List<RegistryDO> registryDOS = registryMapper.selectAll(); + return registryDOS.stream().map(RegistryTransfer.INSTANCE::mapToVo).collect(Collectors.toList()); + } + + + private RegistryVO create(final RegistryDTO registryDTO) { + RegistryDO existRegistryDO = registryMapper.selectByRegistryId(registryDTO.getRegistryId()); + if (Objects.nonNull(existRegistryDO)) { + throw new ShenyuAdminException("registry_id is already exist"); + } + + Timestamp currentTime = new Timestamp(System.currentTimeMillis()); + String id = UUIDUtils.getInstance().generateShortUuid(); + RegistryDO registryDO = RegistryDO.builder() + .id(id) + .registryId(registryDTO.getRegistryId()) + .protocol(registryDTO.getProtocol()) + .address(registryDTO.getAddress()) + .namespace(registryDTO.getNamespace()) + .username(registryDTO.getUsername()) + .password(registryDTO.getPassword()) + .group(registryDTO.getGroup()) + .dateCreated(currentTime) + .dateUpdated(currentTime) + .build(); + registryMapper.insert(registryDO); + + return RegistryTransfer.INSTANCE.mapToVo(registryDO); + } + + private RegistryVO update(final RegistryDTO registryDTO) { + if (Objects.isNull(registryDTO) || Objects.isNull(registryDTO.getId())) { + throw new ShenyuAdminException("registry is not exist"); + } + RegistryDO existRegistryDO = registryMapper.selectByRegistryId(registryDTO.getRegistryId()); + if (Objects.nonNull(existRegistryDO) && !existRegistryDO.getId().equals(registryDTO.getId())) { + throw new ShenyuAdminException("registry_id is already exist"); + } + Timestamp currentTime = new Timestamp(System.currentTimeMillis()); + RegistryDO registryDO = RegistryDO.builder() + .id(registryDTO.getId()) + .registryId(registryDTO.getRegistryId()) + .protocol(registryDTO.getProtocol()) + .address(registryDTO.getAddress()) + .namespace(registryDTO.getNamespace()) + .username(registryDTO.getUsername()) + .password(registryDTO.getPassword()) + .group(registryDTO.getGroup()) + .dateUpdated(currentTime) + .build(); + return registryMapper.updateSelective(registryDO) > 0 + ? RegistryTransfer.INSTANCE.mapToVo(registryDO) : null; + } +} diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/transfer/RegistryTransfer.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/transfer/RegistryTransfer.java new file mode 100644 index 0000000000..514c6ffc1a --- /dev/null +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/transfer/RegistryTransfer.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shenyu.admin.transfer; + +import org.apache.shenyu.admin.model.entity.RegistryDO; +import org.apache.shenyu.admin.model.vo.RegistryVO; + +import java.util.Optional; + +public enum RegistryTransfer { + /** + * The constant INSTANCE. + */ + INSTANCE; + + /** + * mapToVo. + * + * @param registryDO registryDO + * @return RegistryVO + */ + public RegistryVO mapToVo(RegistryDO registryDO) { + return Optional.ofNullable(registryDO).map(data -> { + RegistryVO vo = new RegistryVO(); + vo.setId(data.getId()); + vo.setRegistryId(data.getRegistryId()); + vo.setProtocol(data.getProtocol()); + vo.setAddress(data.getAddress()); + vo.setUsername(data.getUsername()); + vo.setPassword(data.getPassword()); + vo.setGroup(data.getGroup()); + vo.setNamespace(data.getNamespace()); + return vo; + }).orElse(null); + } +} diff --git a/shenyu-admin/src/main/resources/mappers/registry-sqlmap.xml b/shenyu-admin/src/main/resources/mappers/registry-sqlmap.xml new file mode 100644 index 0000000000..7728cd9920 --- /dev/null +++ b/shenyu-admin/src/main/resources/mappers/registry-sqlmap.xml @@ -0,0 +1,267 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one or more + ~ contributor license agreements. See the NOTICE file distributed with + ~ this work for additional information regarding copyright ownership. + ~ The ASF licenses this file to You under the Apache License, Version 2.0 + ~ (the "License"); you may not use this file except in compliance with + ~ the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "https://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="org.apache.shenyu.admin.mapper.RegistryMapper"> + <resultMap id="BaseResultMap" type="org.apache.shenyu.admin.model.entity.RegistryDO"> + <id column="id" jdbcType="VARCHAR" property="id"/> + <result column="registry_id" jdbcType="VARCHAR" property="registryId"/> + <result column="protocol" jdbcType="VARCHAR" property="protocol"/> + <result column="address" jdbcType="VARCHAR" property="address"/> + <result column="username" jdbcType="VARCHAR" property="username"/> + <result column="password" jdbcType="VARCHAR" property="password"/> + <result column="namespace" jdbcType="VARCHAR" property="namespace"/> + <result column="group" jdbcType="VARCHAR" property="group"/> + <result column="date_created" jdbcType="TIMESTAMP" property="dateCreated"/> + <result column="date_updated" jdbcType="TIMESTAMP" property="dateUpdated"/> + </resultMap> + + <sql id="Base_Column_List"> + id, + registry_id, + protocol, + address, + username, + password, + namespace, + `group`, + date_created, + date_updated + </sql> + + <select id="existed" resultType="java.lang.Boolean"> + SELECT true + FROM registry_config + WHERE id = #{id} limit 1 + </select> + + <select id="selectById" parameterType="java.lang.String" resultMap="BaseResultMap"> + SELECT + <include refid="Base_Column_List"/> + FROM registry_config + WHERE id = #{id, jdbcType=VARCHAR} + </select> + + <select id="selectByRegistryId" parameterType="java.lang.String" resultMap="BaseResultMap"> + SELECT + <include refid="Base_Column_List"/> + FROM registry_config + WHERE registry_id = #{registryId, jdbcType=VARCHAR} + </select> + + <select id="selectAll" resultType="org.apache.shenyu.admin.model.entity.RegistryDO"> + SELECT + <include refid="Base_Column_List"/> + FROM registry_config + </select> + + <insert id="insert" keyColumn="id" keyProperty="id" useGeneratedKeys="true" + parameterType="org.apache.shenyu.admin.model.entity.RegistryDO"> + INSERT INTO registry_config + (id, + registry_id, + protocol, + address, + username, + password, + namespace, + `group`, + date_created, + date_updated + ) + VALUES + (#{id, jdbcType=VARCHAR}, + #{registryId, jdbcType=VARCHAR}, + #{protocol, jdbcType=VARCHAR}, + #{address, jdbcType=VARCHAR}, + #{username, jdbcType=VARCHAR}, + #{password, jdbcType=VARCHAR}, + #{namespace, jdbcType=VARCHAR}, + #{group, jdbcType=VARCHAR}, + #{dateCreated, jdbcType=TIMESTAMP}, + #{dateUpdated, jdbcType=TIMESTAMP} + ) + </insert> + + <insert id="insertSelective" parameterType="org.apache.shenyu.admin.model.entity.RegistryDO"> + INSERT INTO registry_config + <trim prefix="(" suffix=")" suffixOverrides=","> + id, + <if test="registryId != null"> + registry_id, + </if> + <if test="protocol != null"> + protocol, + </if> + <if test="address != null"> + address, + </if> + <if test="username != null"> + username, + </if> + <if test="password != null"> + password, + </if> + <if test="namespace != null"> + namespace, + </if> + <if test="group != null"> + `group`, + </if> + <if test="dateCreated != null"> + date_created, + </if> + <if test="dateUpdated != null"> + date_updated, + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + #{id, jdbcType=VARCHAR}, + <if test="registryId != null"> + #{registryId, jdbcType=VARCHAR}, + </if> + <if test="protocol != null"> + #{protocol, jdbcType=VARCHAR}, + </if> + <if test="address != null"> + #{address, jdbcType=VARCHAR}, + </if> + <if test="username != null"> + #{username, jdbcType=VARCHAR}, + </if> + <if test="password != null"> + #{password, jdbcType=VARCHAR}, + </if> + <if test="namespace != null"> + #{namespace, jdbcType=VARCHAR}, + </if> + <if test="group != null"> + #{group, jdbcType=VARCHAR}, + </if> + <if test="dateCreated != null"> + #{dateCreated, jdbcType=TIMESTAMP}, + </if> + <if test="dateUpdated != null"> + #{dateUpdated, jdbcType=TIMESTAMP}, + </if> + </trim> + </insert> + + <update id="update" parameterType="org.apache.shenyu.admin.model.entity.RegistryDO"> + UPDATE registry_config + SET registry_id = #{registryId, jdbcType=VARCHAR}, + protocol = #{protocol, jdbcType=VARCHAR}, + address = #{address, jdbcType=VARCHAR}, + username = #{username, jdbcType=VARCHAR}, + password = #{password, jdbcType=VARCHAR}, + namespace = #{namespace, jdbcType=VARCHAR}, + `group` = #{group, jdbcType=VARCHAR}, + date_created = #{dateCreated, jdbcType=TIMESTAMP}, + date_updated = #{dateUpdated, jdbcType=TIMESTAMP} + WHERE id = #{id, jdbcType=VARCHAR} + </update> + + <update id="updateSelective" parameterType="org.apache.shenyu.admin.model.entity.RegistryDO"> + UPDATE registry_config + <set> + <if test="registryId != null"> + registry_id = #{registryId, jdbcType=VARCHAR}, + </if> + <if test="protocol != null"> + protocol = #{protocol, jdbcType=VARCHAR}, + </if> + <if test="address != null"> + address = #{address, jdbcType=VARCHAR}, + </if> + <if test="username != null"> + username = #{username, jdbcType=VARCHAR}, + </if> + <if test="password != null"> + password = #{password, jdbcType=VARCHAR}, + </if> + <if test="namespace != null"> + namespace = #{namespace, jdbcType=VARCHAR}, + </if> + <if test="group != null"> + `group` = #{group, jdbcType=VARCHAR}, + </if> + <if test="dateCreated != null"> + date_created = #{dateCreated, jdbcType=TIMESTAMP}, + </if> + <if test="dateUpdated != null"> + date_updated = #{dateUpdated, jdbcType=TIMESTAMP}, + </if> + </set> + WHERE id = #{id, jdbcType=VARCHAR} + </update> + + <select id="countByQuery" parameterType="org.apache.shenyu.admin.model.query.RegistryQuery" resultType="java.lang.Integer"> + SELECT count(1) + FROM registry_config + <where> + <if test="registryId != null and registryId != ''"> + <bind name="registryIdLike" value="('%' + registryId + '%')"/> + AND registry_id LIKE #{registryIdLike, jdbcType=VARCHAR} + </if> + <if test="address != null and address != ''"> + <bind name="addressLike" value="('%' + address + '%')"/> + AND address LIKE #{addressLike, jdbcType=VARCHAR} + </if> + <if test="namespace != null and namespace != ''"> + AND namespace = #{namespace, jdbcType=VARCHAR} + </if> + </where> + </select> + + <select id="selectByQuery" parameterType="org.apache.shenyu.admin.model.query.RegistryQuery" resultMap="BaseResultMap"> + SELECT + <include refid="Base_Column_List"/> + FROM registry_config + <where> + <if test="registryId != null and registryId != ''"> + <bind name="registryIdLike" value="('%' + registryId + '%')"/> + AND registry_id LIKE #{registryIdLike, jdbcType=VARCHAR} + </if> + <if test="address != null and address != ''"> + <bind name="addressLike" value="('%' + address + '%')"/> + AND address LIKE #{addressLike, jdbcType=VARCHAR} + </if> + <if test="namespace != null and namespace != ''"> + AND namespace = #{namespace, jdbcType=VARCHAR} + </if> + </where> + </select> + + <select id="selectByIds" parameterType="java.util.List" resultMap="BaseResultMap"> + SELECT + <include refid="Base_Column_List"/> + FROM registry_config + WHERE id IN + <foreach item="id" collection="ids" open="(" separator="," close=")"> + #{id, jdbcType=VARCHAR} + </foreach> + </select> + + <delete id="deleteByIds" parameterType="java.util.List"> + DELETE FROM registry_config + WHERE id IN + <foreach item="id" collection="ids" open="(" separator="," close=")"> + #{id, jdbcType=VARCHAR} + </foreach> + </delete> +</mapper>