diff --git a/bootstrap/src/main/resources/application.properties b/bootstrap/src/main/resources/application.properties index afc4bbc4ec..7007b0f842 100644 --- a/bootstrap/src/main/resources/application.properties +++ b/bootstrap/src/main/resources/application.properties @@ -190,6 +190,9 @@ nacos.console.port=8080 ### Nacos Server Web context path: nacos.console.contextPath= +### Nacos Server context path, which link to nacos server `nacos.server.contextPath`, works when deployment type is `console` +nacos.console.remote.server.context-path=/nacos + #************** Console UI Configuration ***************# ### Turn on/off the nacos console ui. diff --git a/config/src/main/java/com/alibaba/nacos/config/server/service/NamespaceConfigInfoService.java b/config/src/main/java/com/alibaba/nacos/config/server/service/NamespaceConfigInfoService.java index 2a1a9d050e..8d95944d80 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/service/NamespaceConfigInfoService.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/service/NamespaceConfigInfoService.java @@ -16,10 +16,10 @@ package com.alibaba.nacos.config.server.service; +import com.alibaba.nacos.api.model.response.Namespace; import com.alibaba.nacos.config.server.constant.PropertiesConstant; import com.alibaba.nacos.config.server.service.repository.ConfigInfoPersistService; import com.alibaba.nacos.core.namespace.injector.AbstractNamespaceDetailInjector; -import com.alibaba.nacos.core.namespace.model.Namespace; import com.alibaba.nacos.sys.env.EnvUtil; import org.springframework.stereotype.Service; diff --git a/config/src/test/java/com/alibaba/nacos/config/server/service/NamespaceConfigInfoServiceTest.java b/config/src/test/java/com/alibaba/nacos/config/server/service/NamespaceConfigInfoServiceTest.java index 737649e39f..5df84e5d08 100644 --- a/config/src/test/java/com/alibaba/nacos/config/server/service/NamespaceConfigInfoServiceTest.java +++ b/config/src/test/java/com/alibaba/nacos/config/server/service/NamespaceConfigInfoServiceTest.java @@ -19,7 +19,7 @@ package com.alibaba.nacos.config.server.service; import com.alibaba.nacos.config.server.constant.PropertiesConstant; import com.alibaba.nacos.config.server.model.capacity.TenantCapacity; import com.alibaba.nacos.config.server.service.repository.ConfigInfoPersistService; -import com.alibaba.nacos.core.namespace.model.Namespace; +import com.alibaba.nacos.api.model.response.Namespace; import com.alibaba.nacos.sys.env.EnvUtil; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; diff --git a/console-ui/src/components/EditorNameSpace/EditorNameSpace.js b/console-ui/src/components/EditorNameSpace/EditorNameSpace.js index 249fb788d1..e9a13db5c8 100644 --- a/console-ui/src/components/EditorNameSpace/EditorNameSpace.js +++ b/console-ui/src/components/EditorNameSpace/EditorNameSpace.js @@ -94,6 +94,7 @@ class EditorNameSpace extends React.Component { handleSubmit() { const { locale = {} } = this.props; this.field.validate((errors, values) => { + console.log(values); if (errors) { return; } diff --git a/console-ui/src/lib.js b/console-ui/src/lib.js index 2eaabb56db..5c671ca3f0 100644 --- a/console-ui/src/lib.js +++ b/console-ui/src/lib.js @@ -28,7 +28,10 @@ request.middleWare((_config = {}) => { let config = _config; let { url = '' } = config; - const namespace = localStorage.getItem('namespace') ? localStorage.getItem('namespace') : ''; + let namespace = config?.data?.namespaceId; + if (!namespace) { + namespace = localStorage.getItem('namespace') ? localStorage.getItem('namespace') : ''; + } // 如果url中已经有 namespaceId, 不在data中添加namespaceId config.data = url.indexOf('namespaceId=') === -1 diff --git a/console/src/main/java/com/alibaba/nacos/console/NacosConsole.java b/console/src/main/java/com/alibaba/nacos/console/NacosConsole.java index ccae48010b..4c95e8f83e 100644 --- a/console/src/main/java/com/alibaba/nacos/console/NacosConsole.java +++ b/console/src/main/java/com/alibaba/nacos/console/NacosConsole.java @@ -20,6 +20,7 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.ldap.LdapAutoConfiguration; import org.springframework.context.annotation.PropertySource; +import org.springframework.scheduling.annotation.EnableScheduling; /** * Nacos console starter. @@ -28,6 +29,7 @@ import org.springframework.context.annotation.PropertySource; */ @SpringBootApplication(exclude = LdapAutoConfiguration.class) @PropertySource("classpath:nacos-console.properties") +@EnableScheduling public class NacosConsole { public static void main(String[] args) { diff --git a/console/src/main/java/com/alibaba/nacos/console/config/ConsoleDeploymentConfig.java b/console/src/main/java/com/alibaba/nacos/console/config/ConsoleDeploymentConfig.java index 805b5fefe5..bf7b67400a 100644 --- a/console/src/main/java/com/alibaba/nacos/console/config/ConsoleDeploymentConfig.java +++ b/console/src/main/java/com/alibaba/nacos/console/config/ConsoleDeploymentConfig.java @@ -19,11 +19,6 @@ package com.alibaba.nacos.console.config; import com.alibaba.nacos.console.handler.impl.remote.EnabledRemoteHandler; import com.alibaba.nacos.core.code.ControllerMethodsCache; import com.alibaba.nacos.naming.selector.SelectorManager; -import com.alibaba.nacos.plugin.auth.api.Permission; -import com.alibaba.nacos.plugin.auth.exception.AccessException; -import com.alibaba.nacos.plugin.auth.impl.authenticate.IAuthenticationManager; -import com.alibaba.nacos.plugin.auth.impl.users.NacosUser; -import jakarta.servlet.http.HttpServletRequest; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -45,44 +40,4 @@ public class ConsoleDeploymentConfig { public SelectorManager selectorManager() { return new SelectorManager(); } - - @Bean - public IAuthenticationManager authenticationManager() { - // TODO implement remote authentication manager. - return new IAuthenticationManager() { - @Override - public NacosUser authenticate(String username, String rawPassword) throws AccessException { - return new NacosUser("nacos"); - } - - @Override - public NacosUser authenticate(String jwtToken) throws AccessException { - return new NacosUser("nacos"); - } - - @Override - public NacosUser authenticate(HttpServletRequest httpServletRequest) throws AccessException { - return new NacosUser("nacos"); - } - - @Override - public void authorize(Permission permission, NacosUser nacosUser) throws AccessException { - } - - @Override - public boolean hasGlobalAdminRole(String username) { - return true; - } - - @Override - public boolean hasGlobalAdminRole() { - return true; - } - - @Override - public boolean hasGlobalAdminRole(NacosUser nacosUser) { - return true; - } - }; - } } diff --git a/console/src/main/java/com/alibaba/nacos/console/config/NacosConsoleAuthConfig.java b/console/src/main/java/com/alibaba/nacos/console/config/NacosConsoleAuthConfig.java index b65f6cda99..ec7552b662 100644 --- a/console/src/main/java/com/alibaba/nacos/console/config/NacosConsoleAuthConfig.java +++ b/console/src/main/java/com/alibaba/nacos/console/config/NacosConsoleAuthConfig.java @@ -17,6 +17,7 @@ package com.alibaba.nacos.console.config; import com.alibaba.nacos.auth.config.NacosAuthConfig; +import com.alibaba.nacos.common.utils.StringUtils; import com.alibaba.nacos.core.config.AbstractDynamicConfig; import com.alibaba.nacos.plugin.auth.constant.ApiType; import com.alibaba.nacos.plugin.auth.constant.Constants; @@ -41,6 +42,10 @@ public class NacosConsoleAuthConfig extends AbstractDynamicConfig implements Nac */ private String nacosAuthSystemType; + private String serverIdentityKey; + + private String serverIdentityValue; + public NacosConsoleAuthConfig() { super("NacosConsoleAuth"); resetConfig(); @@ -63,23 +68,25 @@ public class NacosConsoleAuthConfig extends AbstractDynamicConfig implements Nac @Override public boolean isSupportServerIdentity() { - return false; + return StringUtils.isNotBlank(serverIdentityKey) && StringUtils.isNotBlank(serverIdentityValue); } @Override public String getServerIdentityKey() { - return ""; + return serverIdentityKey; } @Override public String getServerIdentityValue() { - return ""; + return serverIdentityValue; } @Override protected void getConfigFromEnv() { authEnabled = EnvUtil.getProperty(Constants.Auth.NACOS_CORE_AUTH_CONSOLE_ENABLED, Boolean.class, true); nacosAuthSystemType = EnvUtil.getProperty(Constants.Auth.NACOS_CORE_AUTH_SYSTEM_TYPE, ""); + serverIdentityKey = EnvUtil.getProperty(Constants.Auth.NACOS_CORE_AUTH_SERVER_IDENTITY_KEY, ""); + serverIdentityValue = EnvUtil.getProperty(Constants.Auth.NACOS_CORE_AUTH_SERVER_IDENTITY_VALUE, ""); } @Override diff --git a/console/src/main/java/com/alibaba/nacos/console/config/NacosConsoleAuthControllerConfig.java b/console/src/main/java/com/alibaba/nacos/console/config/NacosConsoleAuthControllerConfig.java index c22aec60d6..85175b3b8d 100644 --- a/console/src/main/java/com/alibaba/nacos/console/config/NacosConsoleAuthControllerConfig.java +++ b/console/src/main/java/com/alibaba/nacos/console/config/NacosConsoleAuthControllerConfig.java @@ -17,41 +17,41 @@ package com.alibaba.nacos.console.config; import com.alibaba.nacos.auth.config.AuthConfigs; -import com.alibaba.nacos.console.handler.impl.inner.EnabledInnerHandler; import com.alibaba.nacos.plugin.auth.impl.authenticate.IAuthenticationManager; import com.alibaba.nacos.plugin.auth.impl.controller.v3.PermissionControllerV3; import com.alibaba.nacos.plugin.auth.impl.controller.v3.RoleControllerV3; import com.alibaba.nacos.plugin.auth.impl.controller.v3.UserControllerV3; -import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleService; import com.alibaba.nacos.plugin.auth.impl.token.TokenManagerDelegate; -import com.alibaba.nacos.plugin.auth.impl.users.NacosUserDetailsServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.users.NacosUserService; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; /** * Configuration of console auth controller. + * TODO use {@link Import} to dynamic load auth plugin controller like Mybatis. * * @author xiweng.yy */ @Configuration -@EnabledInnerHandler public class NacosConsoleAuthControllerConfig { @Bean - public UserControllerV3 consoleUserControllerV3(NacosUserDetailsServiceImpl userDetailsService, - NacosRoleServiceImpl roleService, AuthConfigs authConfigs, IAuthenticationManager iAuthenticationManager, + public UserControllerV3 consoleUserControllerV3(NacosUserService userDetailsService, NacosRoleService roleService, + AuthConfigs authConfigs, IAuthenticationManager iAuthenticationManager, TokenManagerDelegate jwtTokenManager) { return new UserControllerV3(userDetailsService, roleService, authConfigs, iAuthenticationManager, jwtTokenManager); } @Bean - public RoleControllerV3 consoleRoleControllerV3(NacosRoleServiceImpl roleService) { + public RoleControllerV3 consoleRoleControllerV3(NacosRoleService roleService) { return new RoleControllerV3(roleService); } @Bean - public PermissionControllerV3 permissionControllerV3(NacosRoleServiceImpl roleService) { + public PermissionControllerV3 permissionControllerV3(NacosRoleService roleService) { return new PermissionControllerV3(roleService); } } diff --git a/console/src/main/java/com/alibaba/nacos/console/config/NacosConsoleAuthServiceConfig.java b/console/src/main/java/com/alibaba/nacos/console/config/NacosConsoleAuthServiceConfig.java new file mode 100644 index 0000000000..4b697a0dfa --- /dev/null +++ b/console/src/main/java/com/alibaba/nacos/console/config/NacosConsoleAuthServiceConfig.java @@ -0,0 +1,95 @@ +/* + * Copyright 1999-2025 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.nacos.console.config; + +import com.alibaba.nacos.auth.config.AuthConfigs; +import com.alibaba.nacos.console.handler.impl.remote.EnabledRemoteHandler; +import com.alibaba.nacos.core.code.ControllerMethodsCache; +import com.alibaba.nacos.plugin.auth.impl.authenticate.DefaultAuthenticationManager; +import com.alibaba.nacos.plugin.auth.impl.authenticate.IAuthenticationManager; +import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleService; +import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleServiceRemoteImpl; +import com.alibaba.nacos.plugin.auth.impl.token.TokenManager; +import com.alibaba.nacos.plugin.auth.impl.token.TokenManagerDelegate; +import com.alibaba.nacos.plugin.auth.impl.token.impl.CachedJwtTokenManager; +import com.alibaba.nacos.plugin.auth.impl.token.impl.JwtTokenManager; +import com.alibaba.nacos.plugin.auth.impl.users.NacosUserService; +import com.alibaba.nacos.plugin.auth.impl.users.NacosUserServiceRemoteImpl; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; + +import javax.annotation.PostConstruct; + +/** + * Configuration of console auth service. + * TODO use {@link Import} to dynamic load auth plugin controller like Mybatis. + * + * @author xiweng.yy + */ +@EnabledRemoteHandler +@Import(AuthConfigs.class) +@Configuration +public class NacosConsoleAuthServiceConfig { + + private final ControllerMethodsCache methodsCache; + + public NacosConsoleAuthServiceConfig(ControllerMethodsCache methodsCache) { + this.methodsCache = methodsCache; + } + + @PostConstruct + public void registerAuthPathToCache() { + methodsCache.initClassMethod("com.alibaba.nacos.plugin.auth.impl.controller"); + } + + @Bean + public NacosRoleService nacosRoleService(AuthConfigs authConfigs) { + return new NacosRoleServiceRemoteImpl(authConfigs); + } + + @Bean + public NacosUserService nacosUserService(AuthConfigs authConfigs) { + return new NacosUserServiceRemoteImpl(authConfigs); + } + + @Bean + @ConditionalOnMissingBean + public IAuthenticationManager defaultAuthenticationManager(NacosUserService userDetailsService, + TokenManagerDelegate jwtTokenManager, NacosRoleService roleService) { + return new DefaultAuthenticationManager(userDetailsService, jwtTokenManager, roleService); + } + + @Bean + @ConditionalOnProperty(value = TokenManagerDelegate.NACOS_AUTH_TOKEN_CACHING_ENABLED, havingValue = "false", matchIfMissing = true) + public TokenManager tokenManager(AuthConfigs authConfigs) { + return new JwtTokenManager(authConfigs); + } + + @Bean + @ConditionalOnProperty(value = TokenManagerDelegate.NACOS_AUTH_TOKEN_CACHING_ENABLED, havingValue = "true") + public TokenManager cachedTokenManager(AuthConfigs authConfigs) { + return new CachedJwtTokenManager(new JwtTokenManager(authConfigs)); + } + + @Bean + public TokenManagerDelegate tokenManagerDelegate(TokenManager tokenManager) { + return new TokenManagerDelegate(tokenManager); + } +} diff --git a/console/src/main/java/com/alibaba/nacos/console/controller/NamespaceController.java b/console/src/main/java/com/alibaba/nacos/console/controller/NamespaceController.java index 84be1b67c0..d3ddff1f00 100644 --- a/console/src/main/java/com/alibaba/nacos/console/controller/NamespaceController.java +++ b/console/src/main/java/com/alibaba/nacos/console/controller/NamespaceController.java @@ -24,7 +24,7 @@ import com.alibaba.nacos.common.utils.StringUtils; import com.alibaba.nacos.console.handler.impl.inner.EnabledInnerHandler; import com.alibaba.nacos.console.paramcheck.ConsoleDefaultHttpParamExtractor; import com.alibaba.nacos.core.controller.compatibility.Compatibility; -import com.alibaba.nacos.core.namespace.model.Namespace; +import com.alibaba.nacos.api.model.response.Namespace; import com.alibaba.nacos.core.namespace.repository.NamespacePersistService; import com.alibaba.nacos.core.paramcheck.ExtractorManager; import com.alibaba.nacos.core.service.NamespaceOperationService; diff --git a/console/src/main/java/com/alibaba/nacos/console/controller/ServerStateController.java b/console/src/main/java/com/alibaba/nacos/console/controller/ServerStateController.java index b32d7aceb2..1cfd355ee4 100644 --- a/console/src/main/java/com/alibaba/nacos/console/controller/ServerStateController.java +++ b/console/src/main/java/com/alibaba/nacos/console/controller/ServerStateController.java @@ -18,13 +18,13 @@ package com.alibaba.nacos.console.controller; import com.alibaba.nacos.common.model.RestResult; import com.alibaba.nacos.common.model.RestResultUtils; +import com.alibaba.nacos.console.handler.impl.inner.EnabledInnerHandler; import com.alibaba.nacos.console.paramcheck.ConsoleDefaultHttpParamExtractor; import com.alibaba.nacos.core.controller.compatibility.Compatibility; import com.alibaba.nacos.core.paramcheck.ExtractorManager; +import com.alibaba.nacos.core.service.NacosServerStateService; import com.alibaba.nacos.plugin.auth.constant.ApiType; import com.alibaba.nacos.sys.env.EnvUtil; -import com.alibaba.nacos.sys.module.ModuleState; -import com.alibaba.nacos.sys.module.ModuleStateHolder; import com.alibaba.nacos.sys.utils.DiskUtils; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; @@ -33,7 +33,6 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.io.File; -import java.util.HashMap; import java.util.Map; import static com.alibaba.nacos.common.utils.StringUtils.FOLDER_SEPARATOR; @@ -48,12 +47,19 @@ import static com.alibaba.nacos.common.utils.StringUtils.WINDOWS_FOLDER_SEPARATO @RestController @RequestMapping("/v1/console/server") @ExtractorManager.Extractor(httpExtractor = ConsoleDefaultHttpParamExtractor.class) +@EnabledInnerHandler public class ServerStateController { private static final String ANNOUNCEMENT_FILE = "announcement.conf"; private static final String GUIDE_FILE = "console-guide.conf"; + private final NacosServerStateService stateService; + + public ServerStateController(NacosServerStateService stateService) { + this.stateService = stateService; + } + /** * Get server state of current server. * @@ -62,11 +68,7 @@ public class ServerStateController { @GetMapping("/state") @Compatibility(apiType = ApiType.CONSOLE_API, alternatives = "GET ${contextPath:nacos}/v3/console/server/state") public ResponseEntity> serverState() { - Map serverState = new HashMap<>(4); - for (ModuleState each : ModuleStateHolder.getInstance().getAllModuleStates()) { - each.getStates().forEach((s, o) -> serverState.put(s, null == o ? null : o.toString())); - } - return ResponseEntity.ok().body(serverState); + return ResponseEntity.ok(stateService.getServerState()); } @GetMapping("/announcement") diff --git a/console/src/main/java/com/alibaba/nacos/console/controller/v2/NamespaceControllerV2.java b/console/src/main/java/com/alibaba/nacos/console/controller/v2/NamespaceControllerV2.java index c74e538637..9a7543ef35 100644 --- a/console/src/main/java/com/alibaba/nacos/console/controller/v2/NamespaceControllerV2.java +++ b/console/src/main/java/com/alibaba/nacos/console/controller/v2/NamespaceControllerV2.java @@ -19,6 +19,7 @@ package com.alibaba.nacos.console.controller.v2; import com.alibaba.nacos.api.annotation.NacosApi; import com.alibaba.nacos.api.exception.NacosException; import com.alibaba.nacos.api.exception.api.NacosApiException; +import com.alibaba.nacos.api.model.response.Namespace; import com.alibaba.nacos.api.model.v2.ErrorCode; import com.alibaba.nacos.api.model.v2.Result; import com.alibaba.nacos.auth.annotation.Secured; @@ -26,7 +27,6 @@ import com.alibaba.nacos.common.utils.StringUtils; import com.alibaba.nacos.console.handler.impl.inner.EnabledInnerHandler; import com.alibaba.nacos.console.paramcheck.ConsoleDefaultHttpParamExtractor; import com.alibaba.nacos.core.controller.compatibility.Compatibility; -import com.alibaba.nacos.core.namespace.model.Namespace; import com.alibaba.nacos.core.namespace.model.form.NamespaceForm; import com.alibaba.nacos.core.namespace.repository.NamespacePersistService; import com.alibaba.nacos.core.paramcheck.ExtractorManager; diff --git a/console/src/main/java/com/alibaba/nacos/console/controller/v3/ConsoleServerStateController.java b/console/src/main/java/com/alibaba/nacos/console/controller/v3/ConsoleServerStateController.java index 9e918d7095..9e42fe85e5 100644 --- a/console/src/main/java/com/alibaba/nacos/console/controller/v3/ConsoleServerStateController.java +++ b/console/src/main/java/com/alibaba/nacos/console/controller/v3/ConsoleServerStateController.java @@ -18,6 +18,7 @@ package com.alibaba.nacos.console.controller.v3; import com.alibaba.nacos.api.annotation.NacosApi; +import com.alibaba.nacos.api.exception.NacosException; import com.alibaba.nacos.api.model.v2.Result; import com.alibaba.nacos.api.model.v2.SupportedLanguage; import com.alibaba.nacos.console.paramcheck.ConsoleDefaultHttpParamExtractor; @@ -54,7 +55,7 @@ public class ConsoleServerStateController { * @return state json. */ @GetMapping("/state") - public ResponseEntity> serverState() { + public ResponseEntity> serverState() throws NacosException { Map serverState = serverStateProxy.getServerState(); return ResponseEntity.ok().body(serverState); } diff --git a/console/src/main/java/com/alibaba/nacos/console/controller/v3/core/ConsoleNamespaceController.java b/console/src/main/java/com/alibaba/nacos/console/controller/v3/core/ConsoleNamespaceController.java index 377122213e..8249ee1351 100644 --- a/console/src/main/java/com/alibaba/nacos/console/controller/v3/core/ConsoleNamespaceController.java +++ b/console/src/main/java/com/alibaba/nacos/console/controller/v3/core/ConsoleNamespaceController.java @@ -24,7 +24,7 @@ import com.alibaba.nacos.auth.annotation.Secured; import com.alibaba.nacos.common.utils.StringUtils; import com.alibaba.nacos.console.paramcheck.ConsoleDefaultHttpParamExtractor; import com.alibaba.nacos.console.proxy.core.NamespaceProxy; -import com.alibaba.nacos.core.namespace.model.Namespace; +import com.alibaba.nacos.api.model.response.Namespace; import com.alibaba.nacos.core.namespace.model.form.CreateNamespaceForm; import com.alibaba.nacos.core.namespace.model.form.NamespaceForm; import com.alibaba.nacos.core.paramcheck.ExtractorManager; diff --git a/console/src/main/java/com/alibaba/nacos/console/controller/v3/naming/ConsoleInstanceController.java b/console/src/main/java/com/alibaba/nacos/console/controller/v3/naming/ConsoleInstanceController.java index 850c9ab1e6..629852b3d7 100644 --- a/console/src/main/java/com/alibaba/nacos/console/controller/v3/naming/ConsoleInstanceController.java +++ b/console/src/main/java/com/alibaba/nacos/console/controller/v3/naming/ConsoleInstanceController.java @@ -20,12 +20,14 @@ package com.alibaba.nacos.console.controller.v3.naming; import com.alibaba.nacos.api.annotation.NacosApi; import com.alibaba.nacos.api.exception.NacosException; import com.alibaba.nacos.api.exception.api.NacosApiException; +import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.api.model.v2.ErrorCode; import com.alibaba.nacos.api.model.v2.Result; import com.alibaba.nacos.api.naming.pojo.Instance; import com.alibaba.nacos.api.naming.pojo.builder.InstanceBuilder; import com.alibaba.nacos.api.naming.utils.NamingUtils; import com.alibaba.nacos.auth.annotation.Secured; +import com.alibaba.nacos.common.utils.JacksonUtils; import com.alibaba.nacos.console.proxy.naming.InstanceProxy; import com.alibaba.nacos.core.control.TpsControl; import com.alibaba.nacos.core.model.form.PageForm; @@ -76,10 +78,13 @@ public class ConsoleInstanceController { @RequestMapping("/list") public Result getInstanceList(InstanceListForm instanceForm, PageForm pageForm) throws NacosException { instanceForm.validate(); - // TODO use Page + List replace with console ui - ObjectNode result = instanceProxy.listInstances(instanceForm.getNamespaceId(), instanceForm.getServiceName(), - instanceForm.getGroupName(), instanceForm.getClusterName(), pageForm.getPageNo(), - pageForm.getPageSize()); + Page instancePage = instanceProxy.listInstances(instanceForm.getNamespaceId(), + instanceForm.getServiceName(), instanceForm.getGroupName(), instanceForm.getClusterName(), + pageForm.getPageNo(), pageForm.getPageSize()); + // TODO use Page directly after console-ui modified + ObjectNode result = JacksonUtils.createEmptyJsonNode(); + result.replace("instances", JacksonUtils.transferToJsonNode(instancePage.getPageItems())); + result.put("count", instancePage.getTotalCount()); return Result.success(result); } diff --git a/console/src/main/java/com/alibaba/nacos/console/handler/HealthHandler.java b/console/src/main/java/com/alibaba/nacos/console/handler/HealthHandler.java index 9866cf330e..0b224adc86 100644 --- a/console/src/main/java/com/alibaba/nacos/console/handler/HealthHandler.java +++ b/console/src/main/java/com/alibaba/nacos/console/handler/HealthHandler.java @@ -17,6 +17,7 @@ package com.alibaba.nacos.console.handler; +import com.alibaba.nacos.api.exception.NacosException; import com.alibaba.nacos.api.model.v2.Result; /** @@ -30,7 +31,8 @@ public interface HealthHandler { * Perform readiness check to determine if Nacos is ready to handle requests. * * @return readiness result + * @throws NacosException if an error occurs during readiness check */ - Result checkReadiness(); + Result checkReadiness() throws NacosException; } diff --git a/console/src/main/java/com/alibaba/nacos/console/handler/ServerStateHandler.java b/console/src/main/java/com/alibaba/nacos/console/handler/ServerStateHandler.java index 4382db996e..656f79c3ae 100644 --- a/console/src/main/java/com/alibaba/nacos/console/handler/ServerStateHandler.java +++ b/console/src/main/java/com/alibaba/nacos/console/handler/ServerStateHandler.java @@ -17,6 +17,8 @@ package com.alibaba.nacos.console.handler; +import com.alibaba.nacos.api.exception.NacosException; + import java.util.Map; /** @@ -30,8 +32,9 @@ public interface ServerStateHandler { * Get the current state of the server. * * @return a map containing the server state + * @throws NacosException if an error occurs while retrieving the server state */ - Map getServerState(); + Map getServerState() throws NacosException; /** * Get the announcement content based on the language. diff --git a/console/src/main/java/com/alibaba/nacos/console/handler/core/NamespaceHandler.java b/console/src/main/java/com/alibaba/nacos/console/handler/core/NamespaceHandler.java index 8c6a951413..88fc171f81 100644 --- a/console/src/main/java/com/alibaba/nacos/console/handler/core/NamespaceHandler.java +++ b/console/src/main/java/com/alibaba/nacos/console/handler/core/NamespaceHandler.java @@ -18,7 +18,7 @@ package com.alibaba.nacos.console.handler.core; import com.alibaba.nacos.api.exception.NacosException; -import com.alibaba.nacos.core.namespace.model.Namespace; +import com.alibaba.nacos.api.model.response.Namespace; import com.alibaba.nacos.core.namespace.model.form.NamespaceForm; import java.util.List; diff --git a/console/src/main/java/com/alibaba/nacos/console/handler/impl/inner/ServerStateInnerHandler.java b/console/src/main/java/com/alibaba/nacos/console/handler/impl/inner/ServerStateInnerHandler.java index 56711678cd..1f1567f629 100644 --- a/console/src/main/java/com/alibaba/nacos/console/handler/impl/inner/ServerStateInnerHandler.java +++ b/console/src/main/java/com/alibaba/nacos/console/handler/impl/inner/ServerStateInnerHandler.java @@ -17,11 +17,9 @@ package com.alibaba.nacos.console.handler.impl.inner; import com.alibaba.nacos.console.handler.impl.AbstractServerStateHandler; -import com.alibaba.nacos.sys.module.ModuleState; -import com.alibaba.nacos.sys.module.ModuleStateHolder; +import com.alibaba.nacos.core.service.NacosServerStateService; import org.springframework.stereotype.Service; -import java.util.HashMap; import java.util.Map; /** @@ -33,12 +31,14 @@ import java.util.Map; @EnabledInnerHandler public class ServerStateInnerHandler extends AbstractServerStateHandler { + private final NacosServerStateService stateService; + + public ServerStateInnerHandler(NacosServerStateService stateService) { + this.stateService = stateService; + } + public Map getServerState() { - Map serverState = new HashMap<>(4); - for (ModuleState each : ModuleStateHolder.getInstance().getAllModuleStates()) { - each.getStates().forEach((s, o) -> serverState.put(s, null == o ? null : o.toString())); - } - return serverState; + return stateService.getServerState(); } } diff --git a/console/src/main/java/com/alibaba/nacos/console/handler/impl/inner/core/NamespaceInnerHandler.java b/console/src/main/java/com/alibaba/nacos/console/handler/impl/inner/core/NamespaceInnerHandler.java index 3f9927f649..230ff6b0c3 100644 --- a/console/src/main/java/com/alibaba/nacos/console/handler/impl/inner/core/NamespaceInnerHandler.java +++ b/console/src/main/java/com/alibaba/nacos/console/handler/impl/inner/core/NamespaceInnerHandler.java @@ -21,7 +21,7 @@ import com.alibaba.nacos.api.exception.api.NacosApiException; import com.alibaba.nacos.api.model.v2.ErrorCode; import com.alibaba.nacos.console.handler.core.NamespaceHandler; import com.alibaba.nacos.console.handler.impl.inner.EnabledInnerHandler; -import com.alibaba.nacos.core.namespace.model.Namespace; +import com.alibaba.nacos.api.model.response.Namespace; import com.alibaba.nacos.core.namespace.model.form.NamespaceForm; import com.alibaba.nacos.core.namespace.repository.NamespacePersistService; import com.alibaba.nacos.core.service.NamespaceOperationService; diff --git a/console/src/main/java/com/alibaba/nacos/console/handler/impl/inner/naming/InstanceInnerHandler.java b/console/src/main/java/com/alibaba/nacos/console/handler/impl/inner/naming/InstanceInnerHandler.java index 0157f18197..b20f9c69e8 100644 --- a/console/src/main/java/com/alibaba/nacos/console/handler/impl/inner/naming/InstanceInnerHandler.java +++ b/console/src/main/java/com/alibaba/nacos/console/handler/impl/inner/naming/InstanceInnerHandler.java @@ -17,18 +17,18 @@ package com.alibaba.nacos.console.handler.impl.inner.naming; import com.alibaba.nacos.api.exception.NacosException; +import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.api.naming.pojo.Instance; import com.alibaba.nacos.api.naming.utils.NamingUtils; import com.alibaba.nacos.common.notify.NotifyCenter; import com.alibaba.nacos.common.trace.event.naming.UpdateInstanceTraceEvent; -import com.alibaba.nacos.common.utils.JacksonUtils; import com.alibaba.nacos.console.handler.impl.inner.EnabledInnerHandler; import com.alibaba.nacos.console.handler.naming.InstanceHandler; import com.alibaba.nacos.core.utils.PageUtil; +import com.alibaba.nacos.naming.core.CatalogService; import com.alibaba.nacos.naming.core.CatalogServiceV2Impl; import com.alibaba.nacos.naming.core.InstanceOperatorClientImpl; import com.alibaba.nacos.naming.model.form.InstanceForm; -import com.fasterxml.jackson.databind.node.ObjectNode; import org.springframework.stereotype.Service; import java.util.List; @@ -42,7 +42,7 @@ import java.util.List; @EnabledInnerHandler public class InstanceInnerHandler implements InstanceHandler { - private final CatalogServiceV2Impl catalogServiceV2; + private final CatalogService catalogService; private final InstanceOperatorClientImpl instanceServiceV2; @@ -52,20 +52,16 @@ public class InstanceInnerHandler implements InstanceHandler { * @param catalogServiceV2 the service for catalog-related operations */ public InstanceInnerHandler(CatalogServiceV2Impl catalogServiceV2, InstanceOperatorClientImpl instanceServiceV2) { - this.catalogServiceV2 = catalogServiceV2; + this.catalogService = catalogServiceV2; this.instanceServiceV2 = instanceServiceV2; } @Override - public ObjectNode listInstances(String namespaceId, String serviceNameWithoutGroup, String groupName, String clusterName, int page, - int pageSize) throws NacosException { - List instances = catalogServiceV2.listInstances(namespaceId, groupName, + public Page listInstances(String namespaceId, String serviceNameWithoutGroup, String groupName, + String clusterName, int page, int pageSize) throws NacosException { + List instances = catalogService.listInstances(namespaceId, groupName, serviceNameWithoutGroup, clusterName); - List resultInstances = PageUtil.subPageList(instances, page, pageSize); - ObjectNode result = JacksonUtils.createEmptyJsonNode(); - result.replace("instances", JacksonUtils.transferToJsonNode(resultInstances)); - result.put("count", instances.size()); - return result; + return PageUtil.subPage(instances, page, pageSize); } @Override diff --git a/console/src/main/java/com/alibaba/nacos/console/handler/impl/remote/ConsoleMaintainerClientAuthPlugin.java b/console/src/main/java/com/alibaba/nacos/console/handler/impl/remote/ConsoleMaintainerClientAuthPlugin.java new file mode 100644 index 0000000000..aa9eaade99 --- /dev/null +++ b/console/src/main/java/com/alibaba/nacos/console/handler/impl/remote/ConsoleMaintainerClientAuthPlugin.java @@ -0,0 +1,66 @@ +/* + * Copyright 1999-2025 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.nacos.console.handler.impl.remote; + +import com.alibaba.nacos.api.exception.NacosException; +import com.alibaba.nacos.auth.config.NacosAuthConfigHolder; +import com.alibaba.nacos.common.http.client.NacosRestTemplate; +import com.alibaba.nacos.console.config.NacosConsoleAuthConfig; +import com.alibaba.nacos.plugin.auth.api.LoginIdentityContext; +import com.alibaba.nacos.plugin.auth.api.RequestResource; +import com.alibaba.nacos.plugin.auth.spi.client.AbstractClientAuthService; + +import java.util.List; +import java.util.Properties; + +/** + * Client Auth Plugin implementation for console remote maintainer client. + * + * @author xiweng.yy + */ +public class ConsoleMaintainerClientAuthPlugin extends AbstractClientAuthService { + + private LoginIdentityContext identityContext = new LoginIdentityContext(); + + @Override + public Boolean login(Properties properties) { + NacosConsoleAuthConfig authConfig = (NacosConsoleAuthConfig) NacosAuthConfigHolder.getInstance() + .getNacosAuthConfigByScope(NacosConsoleAuthConfig.NACOS_CONSOLE_AUTH_SCOPE); + if (authConfig.isSupportServerIdentity()) { + identityContext.setParameter(authConfig.getServerIdentityKey(), authConfig.getServerIdentityValue()); + } + return true; + } + + @Override + public void setServerList(List serverList) { + } + + @Override + public void setNacosRestTemplate(NacosRestTemplate nacosRestTemplate) { + } + + @Override + public LoginIdentityContext getLoginIdentityContext(RequestResource resource) { + return identityContext; + } + + @Override + public void shutdown() throws NacosException { + + } +} diff --git a/console/src/main/java/com/alibaba/nacos/console/handler/impl/remote/HealthRemoteHandler.java b/console/src/main/java/com/alibaba/nacos/console/handler/impl/remote/HealthRemoteHandler.java index fac1676021..9b1ec69141 100644 --- a/console/src/main/java/com/alibaba/nacos/console/handler/impl/remote/HealthRemoteHandler.java +++ b/console/src/main/java/com/alibaba/nacos/console/handler/impl/remote/HealthRemoteHandler.java @@ -16,6 +16,7 @@ package com.alibaba.nacos.console.handler.impl.remote; +import com.alibaba.nacos.api.exception.NacosException; import com.alibaba.nacos.api.model.v2.Result; import com.alibaba.nacos.console.handler.HealthHandler; import org.springframework.stereotype.Service; @@ -29,10 +30,16 @@ import org.springframework.stereotype.Service; @EnabledRemoteHandler public class HealthRemoteHandler implements HealthHandler { + private final NacosMaintainerClientHolder clientHolder; + + public HealthRemoteHandler(NacosMaintainerClientHolder clientHolder) { + this.clientHolder = clientHolder; + } + @Override - public Result checkReadiness() { - // TODO call nacos servers - return Result.success("ok"); + public Result checkReadiness() throws NacosException { + Boolean result = clientHolder.getNamingMaintainerService().readiness(); + return result ? Result.success("ok") : Result.failure("Nacos server readiness failed."); } } diff --git a/console/src/main/java/com/alibaba/nacos/console/handler/impl/remote/NacosMaintainerClientHolder.java b/console/src/main/java/com/alibaba/nacos/console/handler/impl/remote/NacosMaintainerClientHolder.java index ebd804906a..bb093e0343 100644 --- a/console/src/main/java/com/alibaba/nacos/console/handler/impl/remote/NacosMaintainerClientHolder.java +++ b/console/src/main/java/com/alibaba/nacos/console/handler/impl/remote/NacosMaintainerClientHolder.java @@ -51,7 +51,6 @@ public class NacosMaintainerClientHolder { String memberAddressString = StringUtils.join(memberAddress, ","); Properties properties = new Properties(); properties.setProperty(PropertyKeyConst.SERVER_ADDR, memberAddressString); - // TODO Add admin user and pass namingMaintainerService = NamingMaintainerFactory.createNamingMaintainerService(properties); configMaintainerService = ConfigMaintainerFactory.createConfigMaintainerService(properties); // TODO sub member change event to upgrade maintainer client server members. diff --git a/console/src/main/java/com/alibaba/nacos/console/handler/impl/remote/ServerStateRemoteHandler.java b/console/src/main/java/com/alibaba/nacos/console/handler/impl/remote/ServerStateRemoteHandler.java index 5decb40472..ce8a27f35f 100644 --- a/console/src/main/java/com/alibaba/nacos/console/handler/impl/remote/ServerStateRemoteHandler.java +++ b/console/src/main/java/com/alibaba/nacos/console/handler/impl/remote/ServerStateRemoteHandler.java @@ -16,7 +16,7 @@ package com.alibaba.nacos.console.handler.impl.remote; -import com.alibaba.nacos.common.utils.VersionUtils; +import com.alibaba.nacos.api.exception.NacosException; import com.alibaba.nacos.console.handler.impl.AbstractServerStateHandler; import com.alibaba.nacos.sys.env.Constants; import com.alibaba.nacos.sys.env.EnvUtil; @@ -24,7 +24,6 @@ import com.alibaba.nacos.sys.module.ModuleState; import com.alibaba.nacos.sys.module.ModuleStateHolder; import org.springframework.stereotype.Service; -import java.util.HashMap; import java.util.Map; /** @@ -36,13 +35,14 @@ import java.util.Map; @EnabledRemoteHandler public class ServerStateRemoteHandler extends AbstractServerStateHandler { - public Map getServerState() { - Map serverState = new HashMap<>(4); - // TODO get state from nacos servers - // Mock first - serverState.put(Constants.STARTUP_MODE_STATE, EnvUtil.STANDALONE_MODE_ALONE); - serverState.put(Constants.FUNCTION_MODE_STATE, EnvUtil.getFunctionMode()); - serverState.put(Constants.NACOS_VERSION, VersionUtils.version); + private final NacosMaintainerClientHolder clientHolder; + + public ServerStateRemoteHandler(NacosMaintainerClientHolder clientHolder) { + this.clientHolder = clientHolder; + } + + public Map getServerState() throws NacosException { + Map serverState = this.clientHolder.getNamingMaintainerService().getServerState(); serverState.put(Constants.SERVER_PORT_STATE, EnvUtil.getProperty("nacos.console.port", "8080")); // Add current console states for (ModuleState each : ModuleStateHolder.getInstance().getAllModuleStates()) { diff --git a/console/src/main/java/com/alibaba/nacos/console/handler/impl/remote/core/NamespaceRemoteHandler.java b/console/src/main/java/com/alibaba/nacos/console/handler/impl/remote/core/NamespaceRemoteHandler.java index 23e91df033..346a213278 100644 --- a/console/src/main/java/com/alibaba/nacos/console/handler/impl/remote/core/NamespaceRemoteHandler.java +++ b/console/src/main/java/com/alibaba/nacos/console/handler/impl/remote/core/NamespaceRemoteHandler.java @@ -17,15 +17,13 @@ package com.alibaba.nacos.console.handler.impl.remote.core; import com.alibaba.nacos.api.exception.NacosException; +import com.alibaba.nacos.api.model.response.Namespace; import com.alibaba.nacos.console.handler.core.NamespaceHandler; import com.alibaba.nacos.console.handler.impl.remote.EnabledRemoteHandler; import com.alibaba.nacos.console.handler.impl.remote.NacosMaintainerClientHolder; -import com.alibaba.nacos.core.namespace.model.Namespace; import com.alibaba.nacos.core.namespace.model.form.NamespaceForm; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.Collections; import java.util.List; /** @@ -45,32 +43,12 @@ public class NamespaceRemoteHandler implements NamespaceHandler { @Override public List getNamespaceList() throws NacosException { - return transferToNamespaceList(clientHolder.getNamingMaintainerService().getNamespaceList()); - } - - private List transferToNamespaceList(List namespaceList) { - if (null == namespaceList) { - return Collections.emptyList(); - } - List result = new ArrayList<>(); - namespaceList.forEach(namespace -> result.add(transferToNamespace(namespace))); - return result; + return clientHolder.getNamingMaintainerService().getNamespaceList(); } @Override public Namespace getNamespaceDetail(String namespaceId) throws NacosException { - return transferToNamespace(clientHolder.getNamingMaintainerService().getNamespace(namespaceId)); - } - - private Namespace transferToNamespace(com.alibaba.nacos.api.model.response.Namespace namespace) { - Namespace targetNamespace = new Namespace(); - targetNamespace.setNamespaceShowName(namespace.getNamespaceShowName()); - targetNamespace.setNamespaceDesc(namespace.getNamespaceDesc()); - targetNamespace.setNamespace(namespace.getNamespace()); - targetNamespace.setQuota(namespace.getQuota()); - targetNamespace.setConfigCount(namespace.getConfigCount()); - targetNamespace.setType(namespace.getType()); - return targetNamespace; + return clientHolder.getNamingMaintainerService().getNamespace(namespaceId); } @Override @@ -81,8 +59,9 @@ public class NamespaceRemoteHandler implements NamespaceHandler { @Override public Boolean updateNamespace(NamespaceForm namespaceForm) throws NacosException { - return clientHolder.getNamingMaintainerService().updateNamespace(namespaceForm.getNamespaceId(), - namespaceForm.getNamespaceName(), namespaceForm.getNamespaceDesc()); + return clientHolder.getNamingMaintainerService() + .updateNamespace(namespaceForm.getNamespaceId(), namespaceForm.getNamespaceName(), + namespaceForm.getNamespaceDesc()); } @Override diff --git a/console/src/main/java/com/alibaba/nacos/console/handler/impl/remote/naming/InstanceRemoteHandler.java b/console/src/main/java/com/alibaba/nacos/console/handler/impl/remote/naming/InstanceRemoteHandler.java index b8532ed387..529ab8b77a 100644 --- a/console/src/main/java/com/alibaba/nacos/console/handler/impl/remote/naming/InstanceRemoteHandler.java +++ b/console/src/main/java/com/alibaba/nacos/console/handler/impl/remote/naming/InstanceRemoteHandler.java @@ -17,14 +17,13 @@ package com.alibaba.nacos.console.handler.impl.remote.naming; import com.alibaba.nacos.api.exception.NacosException; +import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.api.naming.pojo.Instance; -import com.alibaba.nacos.common.utils.JacksonUtils; import com.alibaba.nacos.console.handler.impl.remote.EnabledRemoteHandler; import com.alibaba.nacos.console.handler.impl.remote.NacosMaintainerClientHolder; import com.alibaba.nacos.console.handler.naming.InstanceHandler; import com.alibaba.nacos.core.utils.PageUtil; import com.alibaba.nacos.naming.model.form.InstanceForm; -import com.fasterxml.jackson.databind.node.ObjectNode; import org.springframework.stereotype.Service; import java.util.List; @@ -45,15 +44,11 @@ public class InstanceRemoteHandler implements InstanceHandler { } @Override - public ObjectNode listInstances(String namespaceId, String serviceNameWithoutGroup, String groupName, + public Page listInstances(String namespaceId, String serviceNameWithoutGroup, String groupName, String clusterName, int page, int pageSize) throws NacosException { List instances = clientHolder.getNamingMaintainerService() .listInstances(namespaceId, groupName, serviceNameWithoutGroup, clusterName, false); - List resultInstances = PageUtil.subPageList(instances, page, pageSize); - ObjectNode result = JacksonUtils.createEmptyJsonNode(); - result.replace("instances", JacksonUtils.transferToJsonNode(resultInstances)); - result.put("count", instances.size()); - return result; + return PageUtil.subPage(instances, page, pageSize); } @Override diff --git a/console/src/main/java/com/alibaba/nacos/console/handler/naming/InstanceHandler.java b/console/src/main/java/com/alibaba/nacos/console/handler/naming/InstanceHandler.java index 00b05ff642..4979414d9c 100644 --- a/console/src/main/java/com/alibaba/nacos/console/handler/naming/InstanceHandler.java +++ b/console/src/main/java/com/alibaba/nacos/console/handler/naming/InstanceHandler.java @@ -18,9 +18,9 @@ package com.alibaba.nacos.console.handler.naming; import com.alibaba.nacos.api.exception.NacosException; +import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.api.naming.pojo.Instance; import com.alibaba.nacos.naming.model.form.InstanceForm; -import com.fasterxml.jackson.databind.node.ObjectNode; /** * Interface for handling instance-related operations. @@ -38,10 +38,10 @@ public interface InstanceHandler { * @param clusterName the cluster name * @param page the page number * @param pageSize the size of the page - * @return a JSON node containing the instances information + * @return the page object of {@link Instance} * @throws NacosException if the list operation fails */ - ObjectNode listInstances(String namespaceId, String serviceNameWithoutGroup, String groupName, String clusterName, + Page listInstances(String namespaceId, String serviceNameWithoutGroup, String groupName, String clusterName, int page, int pageSize) throws NacosException; /** diff --git a/console/src/main/java/com/alibaba/nacos/console/handler/naming/ServiceHandler.java b/console/src/main/java/com/alibaba/nacos/console/handler/naming/ServiceHandler.java index 3a674d1955..e6c305f833 100644 --- a/console/src/main/java/com/alibaba/nacos/console/handler/naming/ServiceHandler.java +++ b/console/src/main/java/com/alibaba/nacos/console/handler/naming/ServiceHandler.java @@ -96,7 +96,7 @@ public interface ServiceHandler { * @param serviceName the service name * @param groupName the group name * @param ignoreEmptyService whether to filter services with empty instances - * @return if withInstances is {@code true}, return List of {@link ServiceDetailInfo}, otherwise return List of {@link ServiceView} + * @return if withInstances is {@code true}, return Page of {@link ServiceDetailInfo}, otherwise return Page of {@link ServiceView} * @throws NacosException if an error occurs during fetching service details */ Object getServiceList(boolean withInstances, String namespaceId, int pageNo, int pageSize, String serviceName, diff --git a/console/src/main/java/com/alibaba/nacos/console/proxy/HealthProxy.java b/console/src/main/java/com/alibaba/nacos/console/proxy/HealthProxy.java index eb7e364f3a..b5c7ae6570 100644 --- a/console/src/main/java/com/alibaba/nacos/console/proxy/HealthProxy.java +++ b/console/src/main/java/com/alibaba/nacos/console/proxy/HealthProxy.java @@ -17,6 +17,7 @@ package com.alibaba.nacos.console.proxy; +import com.alibaba.nacos.api.exception.NacosException; import com.alibaba.nacos.api.model.v2.Result; import com.alibaba.nacos.console.handler.HealthHandler; import org.springframework.stereotype.Service; @@ -40,7 +41,7 @@ public class HealthProxy { * * @return readiness result */ - public Result checkReadiness() { + public Result checkReadiness() throws NacosException { return healthHandler.checkReadiness(); } } diff --git a/console/src/main/java/com/alibaba/nacos/console/proxy/ServerStateProxy.java b/console/src/main/java/com/alibaba/nacos/console/proxy/ServerStateProxy.java index a38ba92948..e070647226 100644 --- a/console/src/main/java/com/alibaba/nacos/console/proxy/ServerStateProxy.java +++ b/console/src/main/java/com/alibaba/nacos/console/proxy/ServerStateProxy.java @@ -17,6 +17,7 @@ package com.alibaba.nacos.console.proxy; +import com.alibaba.nacos.api.exception.NacosException; import com.alibaba.nacos.console.handler.ServerStateHandler; import org.springframework.stereotype.Service; @@ -41,7 +42,7 @@ public class ServerStateProxy { * * @return the server state as a Map */ - public Map getServerState() { + public Map getServerState() throws NacosException { return serverStateHandler.getServerState(); } diff --git a/console/src/main/java/com/alibaba/nacos/console/proxy/core/NamespaceProxy.java b/console/src/main/java/com/alibaba/nacos/console/proxy/core/NamespaceProxy.java index 29d5f7e1c1..3324669bdf 100644 --- a/console/src/main/java/com/alibaba/nacos/console/proxy/core/NamespaceProxy.java +++ b/console/src/main/java/com/alibaba/nacos/console/proxy/core/NamespaceProxy.java @@ -19,7 +19,7 @@ package com.alibaba.nacos.console.proxy.core; import com.alibaba.nacos.api.exception.NacosException; import com.alibaba.nacos.console.handler.core.NamespaceHandler; -import com.alibaba.nacos.core.namespace.model.Namespace; +import com.alibaba.nacos.api.model.response.Namespace; import com.alibaba.nacos.core.namespace.model.form.NamespaceForm; import org.springframework.stereotype.Service; diff --git a/console/src/main/java/com/alibaba/nacos/console/proxy/naming/InstanceProxy.java b/console/src/main/java/com/alibaba/nacos/console/proxy/naming/InstanceProxy.java index f27da30cba..e55f918c6a 100644 --- a/console/src/main/java/com/alibaba/nacos/console/proxy/naming/InstanceProxy.java +++ b/console/src/main/java/com/alibaba/nacos/console/proxy/naming/InstanceProxy.java @@ -18,10 +18,10 @@ package com.alibaba.nacos.console.proxy.naming; import com.alibaba.nacos.api.exception.NacosException; +import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.api.naming.pojo.Instance; import com.alibaba.nacos.console.handler.naming.InstanceHandler; import com.alibaba.nacos.naming.model.form.InstanceForm; -import com.fasterxml.jackson.databind.node.ObjectNode; import org.springframework.stereotype.Service; /** @@ -52,11 +52,11 @@ public class InstanceProxy { * @param clusterName the cluster name * @param page the page number * @param pageSize the size of the page - * @return a JSON node containing the instances information + * @return the page object of {@link Instance} * @throws IllegalArgumentException if the deployment type is invalid * @throws NacosException if the list operation fails */ - public ObjectNode listInstances(String namespaceId, String serviceNameWithoutGroup, String groupName, + public Page listInstances(String namespaceId, String serviceNameWithoutGroup, String groupName, String clusterName, int page, int pageSize) throws NacosException { return instanceHandler.listInstances(namespaceId, serviceNameWithoutGroup, groupName, clusterName, page, pageSize); diff --git a/console/src/main/java/com/alibaba/nacos/console/proxy/naming/ServiceProxy.java b/console/src/main/java/com/alibaba/nacos/console/proxy/naming/ServiceProxy.java index 2f53c1791d..94c2393aec 100644 --- a/console/src/main/java/com/alibaba/nacos/console/proxy/naming/ServiceProxy.java +++ b/console/src/main/java/com/alibaba/nacos/console/proxy/naming/ServiceProxy.java @@ -128,15 +128,17 @@ public class ServiceProxy { public Object getServiceList(boolean withInstances, String namespaceId, int pageNo, int pageSize, String serviceName, String groupName, boolean hasIpCount) throws NacosException { if (withInstances) { - return serviceHandler.getServiceList(withInstances, namespaceId, pageNo, pageSize, serviceName, groupName, - hasIpCount); + // TODO use result directly after console ui changed and return page object + Page serviceDetailInfoPage = (Page) serviceHandler.getServiceList( + withInstances, namespaceId, pageNo, pageSize, serviceName, groupName, hasIpCount); + return serviceDetailInfoPage.getPageItems(); } // TODO use result directly after console ui changed and return page object - List views = (List) serviceHandler.getServiceList(withInstances, namespaceId, pageNo, + Page views = (Page) serviceHandler.getServiceList(withInstances, namespaceId, pageNo, pageSize, serviceName, groupName, hasIpCount); ObjectNode result = JacksonUtils.createEmptyJsonNode(); - result.put(FieldsConstants.COUNT, views.size()); - result.set(FieldsConstants.SERVICE_LIST, JacksonUtils.transferToJsonNode(views)); + result.put(FieldsConstants.COUNT, views.getTotalCount()); + result.set(FieldsConstants.SERVICE_LIST, JacksonUtils.transferToJsonNode(views.getPageItems())); return result; } diff --git a/cmdb/src/main/resources/application.properties b/console/src/main/resources/META-INF/services/com.alibaba.nacos.plugin.auth.spi.client.AbstractClientAuthService similarity index 73% rename from cmdb/src/main/resources/application.properties rename to console/src/main/resources/META-INF/services/com.alibaba.nacos.plugin.auth.spi.client.AbstractClientAuthService index 642d1573f9..a47e5093ab 100644 --- a/cmdb/src/main/resources/application.properties +++ b/console/src/main/resources/META-INF/services/com.alibaba.nacos.plugin.auth.spi.client.AbstractClientAuthService @@ -1,5 +1,5 @@ # -# Copyright 1999-2018 Alibaba Group Holding Ltd. +# Copyright 1999-2025 Alibaba Group Holding Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,8 +13,5 @@ # See the License for the specific language governing permissions and # limitations under the License. # -server.port=8848 -server.servlet.context-path=/nacos -nacos.cmdb.dumpTaskInterval=3600 -nacos.cmdb.eventTaskInterval=10 -nacos.cmdb.loadDataAtStart=true + +com.alibaba.nacos.console.handler.impl.remote.ConsoleMaintainerClientAuthPlugin \ No newline at end of file diff --git a/console/src/main/resources/application.properties b/console/src/main/resources/application.properties deleted file mode 100644 index 262a0f7c47..0000000000 --- a/console/src/main/resources/application.properties +++ /dev/null @@ -1,253 +0,0 @@ -# -# Copyright 1999-2024 Alibaba Group Holding Ltd. -# -# Licensed 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. -# - -#*************** Spring Boot Related Configurations ***************# -### Default web context path: -server.servlet.contextPath=/nacos -### Include message field -server.error.include-message=ALWAYS -### Default web server port: -server.port=8848 - -#*************** Network Related Configurations ***************# -### If prefer hostname over ip for Nacos server addresses in cluster.conf: -# nacos.inetutils.prefer-hostname-over-ip=false - -### Specify local server's IP: -# nacos.inetutils.ip-address= - -#*************** Config Module Related Configurations ***************# -### Deprecated configuration property, it is recommended to use `spring.sql.init.platform` replaced. -# spring.datasource.platform=mysql -# nacos.plugin.datasource.log.enabled=true -#spring.sql.init.platform=mysql -### Count of DB: -# db.num=1 - -### Connect URL of DB: -#db.url.0=jdbc:mysql://127.0.0.1:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC -#db.user=nacos -#db.password=nacos - -### the maximum retry times for push -nacos.config.push.maxRetryTime=50 - -#*************** Naming Module Related Configurations ***************# -### Data dispatch task execution period in milliseconds: - -### If enable data warmup. If set to false, the server would accept request without local data preparation: -# nacos.naming.data.warmup=true - -### If enable the instance auto expiration, kind like of health check of instance: -# nacos.naming.expireInstance=true - -nacos.naming.empty-service.auto-clean=true -nacos.naming.empty-service.clean.initial-delay-ms=50000 -nacos.naming.empty-service.clean.period-time-ms=30000 - - -#*************** CMDB Module Related Configurations ***************# -### The interval to dump external CMDB in seconds: -# nacos.cmdb.dumpTaskInterval=3600 - -### The interval of polling data change event in seconds: -# nacos.cmdb.eventTaskInterval=10 - -### The interval of loading labels in seconds: -# nacos.cmdb.labelTaskInterval=300 - -### If turn on data loading task: -# nacos.cmdb.loadDataAtStart=false - - -#*************** Metrics Related Configurations ***************# -### Metrics for prometheus -#management.endpoints.web.exposure.include=* - -### Metrics for elastic search -management.elastic.metrics.export.enabled=false -#management.elastic.metrics.export.host=http://localhost:9200 - -### Metrics for influx -management.influx.metrics.export.enabled=false -#management.influx.metrics.export.db=springboot -#management.influx.metrics.export.influx.uri=http://localhost:8086 -#management.influx.metrics.export.influx.auto-create-db=true -#management.influx.metrics.export.influx.consistency=one -#management.influx.metrics.export.influx.compressed=true - -#*************** Access Log Related Configurations ***************# -### If turn on the access log: -server.tomcat.accesslog.enabled=true - -### accesslog automatic cleaning time -server.tomcat.accesslog.max-days=30 - -### The access log pattern: -server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i - -### The directory of access log: -server.tomcat.basedir=file:. - - -#*************** Access Control Related Configurations ***************# -### If enable spring security, this option is deprecated in 1.2.0: -#spring.security.enabled=false -### The ignore urls of auth, is deprecated in 1.2.0: -nacos.security.ignore.urls=/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-ui/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/** - -### The auth system to use, currently only 'nacos' and 'ldap' is supported: -nacos.core.auth.system.type=nacos - -### If turn on auth system v3: -nacos.core.auth.enabled=false -nacos.core.auth.console.enabled=true - -### Turn on/off caching of auth information. By turning on this switch, the update of auth information would have a 15 seconds delay. -nacos.core.auth.caching.enabled=true - -### Since 1.4.1, Turn on/off white auth for user-agent: nacos-server, only for upgrade from old version. -nacos.core.auth.enable.userAgentAuthWhite=false - -### Since 1.4.1, worked when nacos.core.auth.enabled=true and nacos.core.auth.enable.userAgentAuthWhite=false. -### The two properties is the white list for auth and used by identity the request from other server. -nacos.core.auth.server.identity.key= -nacos.core.auth.server.identity.value= - -### worked when nacos.core.auth.system.type=nacos -### The token expiration in seconds: -nacos.core.auth.plugin.nacos.token.cache.enable=false -nacos.core.auth.plugin.nacos.token.expire.seconds=18000 -### The default token (Base64 string): -#nacos.core.auth.plugin.nacos.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789 -nacos.core.auth.plugin.nacos.token.secret.key= - -### worked when nacos.core.auth.system.type=ldap,{0} is Placeholder,replace login username -#nacos.core.auth.ldap.url=ldap://localhost:389 -#nacos.core.auth.ldap.basedc=dc=example,dc=org -#nacos.core.auth.ldap.userDn=cn=admin,${nacos.core.auth.ldap.basedc} -#nacos.core.auth.ldap.password=admin -#nacos.core.auth.ldap.userdn=cn={0},dc=example,dc=org -#nacos.core.auth.ldap.filter.prefix=uid -#nacos.core.auth.ldap.case.sensitive=true -#nacos.core.auth.ldap.ignore.partial.result.exception=false - -#*************** Control Plugin Related Configurations ***************# -# plugin type -#nacos.plugin.control.manager.type=nacos - -# local control rule storage dir, default ${nacos.home}/data/connection and ${nacos.home}/data/tps -#nacos.plugin.control.rule.local.basedir=${nacos.home} - -# external control rule storage type, if exist -#nacos.plugin.control.rule.external.storage= - -#*************** Config Change Plugin Related Configurations ***************# -# webhook -#nacos.core.config.plugin.webhook.enabled=false -# It is recommended to use EB https://help.aliyun.com/document_detail/413974.html -#nacos.core.config.plugin.webhook.url=http://localhost:8080/webhook/send?token=*** -# The content push max capacity ,byte -#nacos.core.config.plugin.webhook.contentMaxCapacity=102400 - -# whitelist -#nacos.core.config.plugin.whitelist.enabled=false -# The import file suffixs -#nacos.core.config.plugin.whitelist.suffixs=xml,text,properties,yaml,html -# fileformatcheck,which validate the import file of type and content -#nacos.core.config.plugin.fileformatcheck.enabled=false - -#*************** Istio Related Configurations ***************# -### If turn on the MCP server: -nacos.istio.mcp.server.enabled=false - -###*************** Add from 1.3.0 ***************### - -#*************** Core Related Configurations ***************# - -### set the WorkerID manually -# nacos.core.snowflake.worker-id= - -### Member-MetaData -# nacos.core.member.meta.site= -# nacos.core.member.meta.adweight= -# nacos.core.member.meta.weight= - -### MemberLookup -### Addressing pattern category, If set, the priority is highest -# nacos.core.member.lookup.type=[file,address-server] -## Set the cluster list with a configuration file or command-line argument -# nacos.member.list=192.168.16.101:8847?raft_port=8807,192.168.16.101?raft_port=8808,192.168.16.101:8849?raft_port=8809 -## for AddressServerMemberLookup -# Maximum number of retries to query the address server upon initialization -# nacos.core.address-server.retry=5 -## Server domain name address of [address-server] mode -# address.server.domain=jmenv.tbsite.net -## Server port of [address-server] mode -# address.server.port=8080 -## Request address of [address-server] mode -# address.server.url=/nacos/serverlist - -#*************** JRaft Related Configurations ***************# - -### Sets the Raft cluster election timeout, default value is 5 second -# nacos.core.protocol.raft.data.election_timeout_ms=5000 -### Sets the amount of time the Raft snapshot will execute periodically, default is 30 minute -# nacos.core.protocol.raft.data.snapshot_interval_secs=30 -### raft internal worker threads -# nacos.core.protocol.raft.data.core_thread_num=8 -### Number of threads required for raft business request processing -# nacos.core.protocol.raft.data.cli_service_thread_num=4 -### raft linear read strategy. Safe linear reads are used by default, that is, the Leader tenure is confirmed by heartbeat -# nacos.core.protocol.raft.data.read_index_type=ReadOnlySafe -### rpc request timeout, default 5 seconds -# nacos.core.protocol.raft.data.rpc_request_timeout_ms=5000 -### enable to support prometheus service discovery -#nacos.prometheus.metrics.enabled=true - -#************** Console UI Configuration ***************# - -### Turn on/off the nacos console ui. -#nacos.console.ui.enabled=true - -###*************** Add from 3.0.0 ***************### - -#*************** Deployment Type Configuration ***************# - -### Sets the deployment type: 'merged' for joint deployment, 'server' for separate deployment server only, 'console' for separate deployment console only. -nacos.deployment.type=merged - -#************** Nacos Admin Compatibility Related Configurations ***************# - -### Enabled for open API compatibility -# nacos.core.api.compatibility.client.enabled=true -### Enabled for admin API compatibility -# nacos.core.api.compatibility.admin.enabled=true -### Enabled for console API compatibility -# nacos.core.api.compatibility.console.enabled=false - -#*************** K8s Related Configurations ***************# -### If turn on the K8s sync: -nacos.k8s.sync.enabled=false - -### If use the Java API from an application outside a kubernetes cluster -#nacos.k8s.sync.outsideCluster=false -#nacos.k8s.sync.kubeConfig=/.kube/config - -#*************** DistributedLock Configurations ***************# - -# nacos.lock.default_expire_time = 30000000 -# nacos.lock.max_expire_time = 1800000000 \ No newline at end of file diff --git a/console/src/main/resources/static/index.html b/console/src/main/resources/static/index.html index ade19baa20..00dfc4930f 100644 --- a/console/src/main/resources/static/index.html +++ b/console/src/main/resources/static/index.html @@ -35,7 +35,7 @@ - +
@@ -56,6 +56,6 @@ - + diff --git a/console/src/main/resources/static/js/main.js b/console/src/main/resources/static/js/main.js index 819a7c18e5..89e05d76f8 100644 --- a/console/src/main/resources/static/js/main.js +++ b/console/src/main/resources/static/js/main.js @@ -295,7 +295,7 @@ var t;e.defineLocale("zh-tw",{months:"一月_二月_三月_四月_五月_六月_ * @author Feross Aboukhadijeh * @license MIT */ -var k=P(706),o=P(707),s=P(708);function n(){return d.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function l(e,t){if(n()=n())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n().toString(16)+" bytes");return 0|e}function f(e,t){if(d.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;var n=(e="string"!=typeof e?""+e:e).length;if(0===n)return 0;for(var a=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return L(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return O(e).length;default:if(a)return L(e).length;t=(""+t).toLowerCase(),a=!0}}function t(e,t,n){var a,r=!1;if((t=void 0===t||t<0?0:t)>this.length)return"";if((n=void 0===n||n>this.length?this.length:n)<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e=e||"utf8";;)switch(e){case"hex":var o=this,i=t,s=n,l=o.length;(!s||s<0||l=e.length){if(r)return-1;n=e.length-1}else if(n<0){if(!r)return-1;n=0}if("string"==typeof t&&(t=d.from(t,a)),d.isBuffer(t))return 0===t.length?-1:m(e,t,n,a,r);if("number"==typeof t)return t&=255,d.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?(r?Uint8Array.prototype.indexOf:Uint8Array.prototype.lastIndexOf).call(e,t,n):m(e,[t],n,a,r);throw new TypeError("val must be string, number or Buffer")}function m(e,t,n,a,r){var o=1,i=e.length,s=t.length;if(void 0!==a&&("ucs2"===(a=String(a).toLowerCase())||"ucs-2"===a||"utf16le"===a||"utf-16le"===a)){if(e.length<2||t.length<2)return-1;i/=o=2,s/=2,n/=2}function l(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(r)for(var u=-1,c=n;c>8,r.push(n%256),r.push(a);return r}(t,e.length-n),e,n,a)}function E(e,t,n){n=Math.min(e.length,n);for(var a=[],r=t;r>>10&1023|55296),c=56320|1023&c),a.push(c),r+=d}var f=a,p=f.length;if(p<=v)return String.fromCharCode.apply(String,f);for(var h="",m=0;mt)&&(e+=" ... "),""},d.prototype.compare=function(e,t,n,a,r){if(!d.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===n&&(n=e?e.length:0),void 0===a&&(a=0),void 0===r&&(r=this.length),(t=void 0===t?0:t)<0||n>e.length||a<0||r>this.length)throw new RangeError("out of range index");if(r<=a&&n<=t)return 0;if(r<=a)return-1;if(n<=t)return 1;if(this===e)return 0;for(var o=(r>>>=0)-(a>>>=0),i=(n>>>=0)-(t>>>=0),s=Math.min(o,i),l=this.slice(a,r),u=e.slice(t,n),c=0;cthis.length)throw new RangeError("Attempt to write outside buffer bounds");a=a||"utf8";for(var o,i,s,l=!1;;)switch(a){case"hex":var u=this,c=e,d=t,f=n,p=(d=Number(d)||0,u.length-d);if((!f||p<(f=Number(f)))&&(f=p),(p=c.length)%2!=0)throw new TypeError("Invalid hex string");p/2e.length)throw new RangeError("Index out of range")}function w(e,t,n,a){t<0&&(t=65535+t+1);for(var r=0,o=Math.min(e.length-n,2);r>>8*(a?r:1-r)}function M(e,t,n,a){t<0&&(t=4294967295+t+1);for(var r=0,o=Math.min(e.length-n,4);r>>8*(a?r:3-r)&255}function S(e,t,n,a){if(n+a>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function x(e,t,n,a,r){return r||S(e,0,n,4),o.write(e,t,n,a,23,4),n+4}function C(e,t,n,a,r){return r||S(e,0,n,8),o.write(e,t,n,a,52,8),n+8}d.prototype.slice=function(e,t){var n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):n>>8):w(this,e,t,!0),t+2},d.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||b(this,e,t,2,65535,0),d.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):w(this,e,t,!1),t+2},d.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||b(this,e,t,4,4294967295,0),d.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):M(this,e,t,!0),t+4},d.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||b(this,e,t,4,4294967295,0),d.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},d.prototype.writeIntLE=function(e,t,n,a){e=+e,t|=0,a||b(this,e,t,n,(a=Math.pow(2,8*n-1))-1,-a);var r=0,o=1,i=0;for(this[t]=255&e;++r>0)-i&255;return t+n},d.prototype.writeIntBE=function(e,t,n,a){e=+e,t|=0,a||b(this,e,t,n,(a=Math.pow(2,8*n-1))-1,-a);var r=n-1,o=1,i=0;for(this[t+r]=255&e;0<=--r&&(o*=256);)e<0&&0===i&&0!==this[t+r+1]&&(i=1),this[t+r]=(e/o>>0)-i&255;return t+n},d.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||b(this,e,t,1,127,-128),d.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&(e=e<0?255+e+1:e),t+1},d.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||b(this,e,t,2,32767,-32768),d.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):w(this,e,t,!0),t+2},d.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||b(this,e,t,2,32767,-32768),d.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):w(this,e,t,!1),t+2},d.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||b(this,e,t,4,2147483647,-2147483648),d.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):M(this,e,t,!0),t+4},d.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||b(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),d.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},d.prototype.writeFloatLE=function(e,t,n){return x(this,e,t,!0,n)},d.prototype.writeFloatBE=function(e,t,n){return x(this,e,t,!1,n)},d.prototype.writeDoubleLE=function(e,t,n){return C(this,e,t,!0,n)},d.prototype.writeDoubleBE=function(e,t,n){return C(this,e,t,!1,n)},d.prototype.copy=function(e,t,n,a){if(n=n||0,a||0===a||(a=this.length),t>=e.length&&(t=e.length),(a=0=this.length)throw new RangeError("sourceStart out of bounds");if(a<0)throw new RangeError("sourceEnd out of bounds");a>this.length&&(a=this.length);var r,o=(a=e.length-t>>=0,n=void 0===n?this.length:n>>>0,"number"==typeof(e=e||0))for(s=t;s>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function O(e){return k.toByteArray(function(e){var t;if((e=((t=e).trim?t.trim():t.replace(/^\s+|\s+$/g,"")).replace(T,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function D(e,t,n,a){for(var r=0;r=t.length||r>=e.length);++r)t[r+n]=e[r];return r}}.call(this,P(65))},function(e,t,n){"use strict";var o=n(138);function i(e,t){e.emit("error",t)}e.exports={destroy:function(e,t){var n=this,a=this._readableState&&this._readableState.destroyed,r=this._writableState&&this._writableState.destroyed;return a||r?t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,o.nextTick(i,this,e)):o.nextTick(i,this,e)):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?n._writableState?n._writableState.errorEmitted||(n._writableState.errorEmitted=!0,o.nextTick(i,n,e)):o.nextTick(i,n,e):t&&t(e)})),this},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},function(e,t,n){"use strict";var a=n(139).Buffer,r=a.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"==typeof t||a.isEncoding!==r&&r(e))return t||e;throw new Error("Unknown encoding: "+e)}function i(e){var t;switch(this.encoding=o(e),this.encoding){case"utf16le":this.text=u,this.end=c,t=4;break;case"utf8":this.fillLast=l,t=4;break;case"base64":this.text=d,this.end=f,t=3;break;default:return this.write=p,void(this.end=h)}this.lastNeed=0,this.lastTotal=0,this.lastChar=a.allocUnsafe(t)}function s(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function l(e){var t,n=this.lastTotal-this.lastNeed,a=(t=this,128!=(192&(a=e)[0])?(t.lastNeed=0,"�"):1e.slidesToShow&&(n=e.slideWidth*e.slidesToShow*-1,o=e.slideHeight*e.slidesToShow*-1),e.slideCount%e.slidesToScroll!=0&&(t=e.slideIndex+e.slidesToScroll>e.slideCount&&e.slideCount>e.slidesToShow,t=e.rtl?(e.slideIndex>=e.slideCount?e.slideCount-e.slideIndex:e.slideIndex)+e.slidesToScroll>e.slideCount&&e.slideCount>e.slidesToShow:t)&&(o=e.slideIndex>e.slideCount?(n=(e.slidesToShow-(e.slideIndex-e.slideCount))*e.slideWidth*-1,(e.slidesToShow-(e.slideIndex-e.slideCount))*e.slideHeight*-1):(n=e.slideCount%e.slidesToScroll*e.slideWidth*-1,e.slideCount%e.slidesToScroll*e.slideHeight*-1))):e.slideCount%e.slidesToScroll!=0&&e.slideIndex+e.slidesToScroll>e.slideCount&&e.slideCount>e.slidesToShow&&(n=(e.slidesToShow-e.slideCount%e.slidesToScroll)*e.slideWidth),e.centerMode&&(e.infinite?n+=e.slideWidth*Math.floor(e.slidesToShow/2):n=e.slideWidth*Math.floor(e.slidesToShow/2)),a=e.vertical?e.slideIndex*e.slideHeight*-1+o:e.slideIndex*e.slideWidth*-1+n,!0===e.variableWidth&&(t=void 0,a=(r=e.slideCount<=e.slidesToShow||!1===e.infinite?i.default.findDOMNode(e.trackRef).childNodes[e.slideIndex]:(t=e.slideIndex+e.slidesToShow,i.default.findDOMNode(e.trackRef).childNodes[t]))?-1*r.offsetLeft:0,!0===e.centerMode)&&(r=!1===e.infinite?i.default.findDOMNode(e.trackRef).children[e.slideIndex]:i.default.findDOMNode(e.trackRef).children[e.slideIndex+e.slidesToShow+1])?-1*r.offsetLeft+(e.listWidth-r.offsetWidth)/2:a)}},function(e,t,n){"use strict";t.__esModule=!0;var p=u(n(3)),h=u(n(17)),o=u(n(4)),i=u(n(7)),a=u(n(8)),m=u(n(0)),r=u(n(5)),g=u(n(19)),s=u(n(6)),y=u(n(26)),l=n(11);function u(e){return e&&e.__esModule?e:{default:e}}c=m.default.Component,(0,a.default)(d,c),d.prototype.render=function(){var e=this.props,t=e.title,n=e.children,a=e.className,r=e.isExpanded,o=e.disabled,i=e.style,s=e.prefix,l=e.onClick,u=e.id,e=(0,h.default)(e,["title","children","className","isExpanded","disabled","style","prefix","onClick","id"]),a=(0,g.default)(((c={})[s+"collapse-panel"]=!0,c[s+"collapse-panel-hidden"]=!r,c[s+"collapse-panel-expanded"]=r,c[s+"collapse-panel-disabled"]=o,c[a]=a,c)),c=(0,g.default)(((c={})[s+"collapse-panel-icon"]=!0,c[s+"collapse-panel-icon-expanded"]=r,c)),d=u?u+"-heading":void 0,f=u?u+"-region":void 0;return m.default.createElement("div",(0,p.default)({className:a,style:i,id:u},e),m.default.createElement("div",{id:d,className:s+"collapse-panel-title",onClick:l,onKeyDown:this.onKeyDown,tabIndex:"0","aria-disabled":o,"aria-expanded":r,"aria-controls":f,role:"button"},m.default.createElement(y.default,{type:"arrow-right",className:c,"aria-hidden":"true"}),t),m.default.createElement("div",{className:s+"collapse-panel-content",role:"region",id:f},n))},a=n=d,n.propTypes={prefix:r.default.string,style:r.default.object,children:r.default.any,isExpanded:r.default.bool,disabled:r.default.bool,title:r.default.node,className:r.default.string,onClick:r.default.func,id:r.default.string},n.defaultProps={prefix:"next-",isExpanded:!1,onClick:l.func.noop},n.isNextPanel=!0;var c,r=a;function d(){var e,n;(0,o.default)(this,d);for(var t=arguments.length,a=Array(t),r=0;r\n com.alibaba.nacos\n nacos-client\n ${version}\n \n*/\npackage com.alibaba.nacos.example;\n\nimport java.util.Properties;\nimport java.util.concurrent.Executor;\nimport com.alibaba.nacos.api.NacosFactory;\nimport com.alibaba.nacos.api.config.ConfigService;\nimport com.alibaba.nacos.api.config.listener.Listener;\nimport com.alibaba.nacos.api.exception.NacosException;\n\n/**\n * Config service example\n *\n * @author Nacos\n *\n */\npublic class ConfigExample {\n\n\tpublic static void main(String[] args) throws NacosException, InterruptedException {\n\t\tString serverAddr = "localhost";\n\t\tString dataId = "'.concat(e.dataId,'";\n\t\tString group = "').concat(e.group,'";\n\t\tProperties properties = new Properties();\n\t\tproperties.put(PropertyKeyConst.SERVER_ADDR, serverAddr);\n\t\tConfigService configService = NacosFactory.createConfigService(properties);\n\t\tString content = configService.getConfig(dataId, group, 5000);\n\t\tSystem.out.println(content);\n\t\tconfigService.addListener(dataId, group, new Listener() {\n\t\t\t@Override\n\t\t\tpublic void receiveConfigInfo(String configInfo) {\n\t\t\t\tSystem.out.println("receive:" + configInfo);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic Executor getExecutor() {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t});\n\n\t\tboolean isPublishOk = configService.publishConfig(dataId, group, "content");\n\t\tSystem.out.println(isPublishOk);\n\n\t\tThread.sleep(3000);\n\t\tcontent = configService.getConfig(dataId, group, 5000);\n\t\tSystem.out.println(content);\n\n\t\tboolean isRemoveOk = configService.removeConfig(dataId, group);\n\t\tSystem.out.println(isRemoveOk);\n\t\tThread.sleep(3000);\n\n\t\tcontent = configService.getConfig(dataId, group, 5000);\n\t\tSystem.out.println(content);\n\t\tThread.sleep(300000);\n\n\t}\n}\n')}},{key:"getNodejsCode",value:function(e){return"TODO"}},{key:"getCppCode",value:function(e){return"TODO"}},{key:"getShellCode",value:function(e){return"TODO"}},{key:"getPythonCode",value:function(e){return'/*\n* Demo for Nacos\n*/\nimport json\nimport socket\n\nimport nacos\n\n\ndef get_host_ip():\n res = socket.gethostbyname(socket.gethostname())\n return res\n\n\ndef load_config(content):\n _config = json.loads(content)\n return _config\n\n\ndef nacos_config_callback(args):\n content = args[\'raw_content\']\n load_config(content)\n\n\nclass NacosClient:\n service_name = None\n service_port = None\n service_group = None\n\n def __init__(self, server_endpoint, namespace_id, username=None, password=None):\n self.client = nacos.NacosClient(server_endpoint,\n namespace=namespace_id,\n username=username,\n password=password)\n self.endpoint = server_endpoint\n self.service_ip = get_host_ip()\n\n def register(self):\n self.client.add_naming_instance(self.service_name,\n self.service_ip,\n self.service_port,\n group_name=self.service_group)\n\n def modify(self, service_name, service_ip=None, service_port=None):\n self.client.modify_naming_instance(service_name,\n service_ip if service_ip else self.service_ip,\n service_port if service_port else self.service_port)\n\n def unregister(self):\n self.client.remove_naming_instance(self.service_name,\n self.service_ip,\n self.service_port)\n\n def set_service(self, service_name, service_ip, service_port, service_group):\n self.service_name = service_name\n self.service_ip = service_ip\n self.service_port = service_port\n self.service_group = service_group\n\n async def beat_callback(self):\n self.client.send_heartbeat(self.service_name,\n self.service_ip,\n self.service_port)\n\n def load_conf(self, data_id, group):\n return self.client.get_config(data_id=data_id, group=group, no_snapshot=True)\n\n def add_conf_watcher(self, data_id, group, callback):\n self.client.add_config_watcher(data_id=data_id, group=group, cb=callback)\n\n\nif __name__ == \'__main__\':\n nacos_config = {\n "nacos_data_id":"test",\n "nacos_server_ip":"127.0.0.1",\n "nacos_namespace":"public",\n "nacos_groupName":"DEFAULT_GROUP",\n "nacos_user":"nacos",\n "nacos_password":"1234567"\n }\n nacos_data_id = nacos_config["nacos_data_id"]\n SERVER_ADDRESSES = nacos_config["nacos_server_ip"]\n NAMESPACE = nacos_config["nacos_namespace"]\n groupName = nacos_config["nacos_groupName"]\n user = nacos_config["nacos_user"]\n password = nacos_config["nacos_password"]\n # todo 将另一个路由对象(通常定义在其他模块或文件中)合并到主应用(app)中。\n # app.include_router(custom_api.router, tags=[\'test\'])\n service_ip = get_host_ip()\n client = NacosClient(SERVER_ADDRESSES, NAMESPACE, user, password)\n client.add_conf_watcher(nacos_data_id, groupName, nacos_config_callback)\n\n # 启动时,强制同步一次配置\n data_stream = client.load_conf(nacos_data_id, groupName)\n json_config = load_config(data_stream)\n'}},{key:"getCSharpCode",value:function(e){return'/*\nDemo for Basic Nacos Opreation\nApp.csproj\n\n\n \n\n*/\n\nusing Microsoft.Extensions.DependencyInjection;\nusing Nacos.V2;\nusing Nacos.V2.DependencyInjection;\nusing System;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n string serverAddr = "http://localhost:8848";\n string dataId = "'.concat(e.dataId,'";\n string group = "').concat(e.group,'";\n\n IServiceCollection services = new ServiceCollection();\n\n services.AddNacosV2Config(x =>\n {\n x.ServerAddresses = new List { serverAddr };\n x.Namespace = "cs-test";\n\n // swich to use http or rpc\n x.ConfigUseRpc = true;\n });\n\n IServiceProvider serviceProvider = services.BuildServiceProvider();\n var configSvc = serviceProvider.GetService();\n\n var content = await configSvc.GetConfig(dataId, group, 3000);\n Console.WriteLine(content);\n\n var listener = new ConfigListener();\n\n await configSvc.AddListener(dataId, group, listener);\n\n var isPublishOk = await configSvc.PublishConfig(dataId, group, "content");\n Console.WriteLine(isPublishOk);\n\n await Task.Delay(3000);\n content = await configSvc.GetConfig(dataId, group, 5000);\n Console.WriteLine(content);\n\n var isRemoveOk = await configSvc.RemoveConfig(dataId, group);\n Console.WriteLine(isRemoveOk);\n await Task.Delay(3000);\n\n content = await configSvc.GetConfig(dataId, group, 5000);\n Console.WriteLine(content);\n await Task.Delay(300000);\n }\n\n internal class ConfigListener : IListener\n {\n public void ReceiveConfigInfo(string configInfo)\n {\n Console.WriteLine("receive:" + configInfo);\n }\n }\n}\n\n/*\nRefer to document: https://github.com/nacos-group/nacos-sdk-csharp/tree/dev/samples/MsConfigApp\nDemo for ASP.NET Core Integration\nMsConfigApp.csproj\n\n\n \n\n*/\n\nusing Microsoft.AspNetCore.Hosting;\nusing Microsoft.Extensions.Configuration;\nusing Microsoft.Extensions.Hosting;\nusing Serilog;\nusing Serilog.Events;\n\npublic class Program\n{\n public static void Main(string[] args)\n {\n Log.Logger = new LoggerConfiguration()\n .Enrich.FromLogContext()\n .MinimumLevel.Override("Microsoft", LogEventLevel.Warning)\n .MinimumLevel.Override("System", LogEventLevel.Warning)\n .MinimumLevel.Debug()\n .WriteTo.Console()\n .CreateLogger();\n\n try\n {\n Log.ForContext().Information("Application starting...");\n CreateHostBuilder(args, Log.Logger).Build().Run();\n }\n catch (System.Exception ex)\n {\n Log.ForContext().Fatal(ex, "Application start-up failed!!");\n }\n finally\n {\n Log.CloseAndFlush();\n }\n }\n\n public static IHostBuilder CreateHostBuilder(string[] args, Serilog.ILogger logger) =>\n Host.CreateDefaultBuilder(args)\n .ConfigureAppConfiguration((context, builder) =>\n {\n var c = builder.Build();\n builder.AddNacosV2Configuration(c.GetSection("NacosConfig"), logAction: x => x.AddSerilog(logger));\n })\n .ConfigureWebHostDefaults(webBuilder =>\n {\n webBuilder.UseStartup().UseUrls("http://*:8787");\n })\n .UseSerilog();\n}\n ')}},{key:"openDialog",value:function(e){var t=this;this.setState({dialogvisible:!0}),this.record=e,setTimeout(function(){t.getData()})}},{key:"closeDialog",value:function(){this.setState({dialogvisible:!1})}},{key:"createCodeMirror",value:function(e,t){var n=this.refs.codepreview;n&&(n.innerHTML="",this.cm=window.CodeMirror(n,{value:t,mode:e,height:400,width:500,lineNumbers:!0,theme:"xq-light",lint:!0,tabMode:"indent",autoMatchParens:!0,textWrapping:!0,gutters:["CodeMirror-lint-markers"],extraKeys:{F1:function(e){e.setOption("fullScreen",!e.getOption("fullScreen"))},Esc:function(e){e.getOption("fullScreen")&&e.setOption("fullScreen",!1)}}}))}},{key:"changeTab",value:function(e,t){var n=this;setTimeout(function(){n[e]=!0,n.createCodeMirror("text/javascript",t)})}},{key:"render",value:function(){var e=this.props.locale,e=void 0===e?{}:e;return x.a.createElement("div",null,x.a.createElement(y.a,{title:e.sampleCode,style:{width:"80%"},visible:this.state.dialogvisible,footer:x.a.createElement("div",null),onClose:this.closeDialog.bind(this)},x.a.createElement("div",{style:{height:500}},x.a.createElement(H.a,{tip:e.loading,style:{width:"100%"},visible:this.state.loading},x.a.createElement(L.a,{shape:"text",style:{height:40,paddingBottom:10}},x.a.createElement(O,{title:"Java",key:1,onClick:this.changeTab.bind(this,"commoneditor1",this.defaultCode)}),x.a.createElement(O,{title:"Spring Boot",key:2,onClick:this.changeTab.bind(this,"commoneditor2",this.sprigboot_code)}),x.a.createElement(O,{title:"Spring Cloud",key:21,onClick:this.changeTab.bind(this,"commoneditor21",this.sprigcloud_code)}),x.a.createElement(O,{title:"Node.js",key:3,onClick:this.changeTab.bind(this,"commoneditor3",this.nodejsCode)}),x.a.createElement(O,{title:"C++",key:4,onClick:this.changeTab.bind(this,"commoneditor4",this.cppCode)}),x.a.createElement(O,{title:"Shell",key:5,onClick:this.changeTab.bind(this,"commoneditor5",this.shellCode)}),x.a.createElement(O,{title:"Python",key:6,onClick:this.changeTab.bind(this,"commoneditor6",this.pythonCode)}),x.a.createElement(O,{title:"C#",key:7,onClick:this.changeTab.bind(this,"commoneditor7",this.csharpCode)})),x.a.createElement("div",{ref:"codepreview"})))))}}]),n}(x.a.Component)).displayName="ShowCodeing",k=k))||k,k=(t(69),t(40)),k=t.n(k),z=(t(756),k.a.Row),D=k.a.Col,W=(0,n.a.config)(((k=function(e){Object(M.a)(n,e);var t=Object(S.a)(n);function n(e){return Object(_.a)(this,n),(e=t.call(this,e)).state={visible:!1,title:"",content:"",isok:!0,dataId:"",group:""},e}return Object(b.a)(n,[{key:"componentDidMount",value:function(){this.initData()}},{key:"initData",value:function(){var e=this.props.locale;this.setState({title:(void 0===e?{}:e).confManagement})}},{key:"openDialog",value:function(e){this.setState({visible:!0,title:e.title,content:e.content,isok:e.isok,dataId:e.dataId,group:e.group,message:e.message})}},{key:"closeDialog",value:function(){this.setState({visible:!1})}},{key:"render",value:function(){var e=this.props.locale,e=void 0===e?{}:e,t=x.a.createElement("div",{style:{textAlign:"right"}},x.a.createElement(c.a,{type:"primary",onClick:this.closeDialog.bind(this)},e.determine));return x.a.createElement("div",null,x.a.createElement(y.a,{visible:this.state.visible,footer:t,style:{width:555},onCancel:this.closeDialog.bind(this),onClose:this.closeDialog.bind(this),title:e.deletetitle},x.a.createElement("div",null,x.a.createElement(z,null,x.a.createElement(D,{span:"4",style:{paddingTop:16}},x.a.createElement(m.a,{type:"".concat(this.state.isok?"success":"delete","-filling"),style:{color:this.state.isok?"green":"red"},size:"xl"})),x.a.createElement(D,{span:"20"},x.a.createElement("div",null,x.a.createElement("h3",null,this.state.isok?e.deletedSuccessfully:e.deleteFailed),x.a.createElement("p",null,x.a.createElement("span",{style:{color:"#999",marginRight:5}},"Data ID"),x.a.createElement("span",{style:{color:"#c7254e"}},this.state.dataId)),x.a.createElement("p",null,x.a.createElement("span",{style:{color:"#999",marginRight:5}},"Group"),x.a.createElement("span",{style:{color:"#c7254e"}},this.state.group)),this.state.isok?"":x.a.createElement("p",{style:{color:"red"}},this.state.message)))))))}}]),n}(x.a.Component)).displayName="DeleteDialog",k=k))||k,k=(t(757),t(436)),B=t.n(k),U=(0,n.a.config)(((k=function(e){Object(M.a)(n,e);var t=Object(S.a)(n);function n(){return Object(_.a)(this,n),t.apply(this,arguments)}return Object(b.a)(n,[{key:"render",value:function(){var e=this.props,t=e.data,t=void 0===t?{}:t,n=e.height,e=e.locale,a=void 0===e?{}:e;return x.a.createElement("div",null,"notice"===t.modeType?x.a.createElement("div",{"data-spm-click":"gostr=/aliyun;locaid=notice"},x.a.createElement(B.a,{style:{marginBottom:1\n com.alibaba.nacos\n nacos-client\n ${latest.version}\n \n*/\npackage com.alibaba.nacos.example;\n\nimport java.util.Properties;\n\nimport com.alibaba.nacos.api.exception.NacosException;\nimport com.alibaba.nacos.api.naming.NamingFactory;\nimport com.alibaba.nacos.api.naming.NamingService;\nimport com.alibaba.nacos.api.naming.listener.Event;\nimport com.alibaba.nacos.api.naming.listener.EventListener;\nimport com.alibaba.nacos.api.naming.listener.NamingEvent;\n\n/**\n * @author nkorange\n */\npublic class NamingExample {\n\n public static void main(String[] args) throws NacosException {\n\n Properties properties = new Properties();\n properties.setProperty("serverAddr", System.getProperty("serverAddr"));\n properties.setProperty("namespace", System.getProperty("namespace"));\n\n NamingService naming = NamingFactory.createNamingService(properties);\n\n naming.registerInstance("'.concat(this.record.name,'", "11.11.11.11", 8888, "TEST1");\n\n naming.registerInstance("').concat(this.record.name,'", "2.2.2.2", 9999, "DEFAULT");\n\n System.out.println(naming.getAllInstances("').concat(this.record.name,'"));\n\n naming.deregisterInstance("').concat(this.record.name,'", "2.2.2.2", 9999, "DEFAULT");\n\n System.out.println(naming.getAllInstances("').concat(this.record.name,'"));\n\n naming.subscribe("').concat(this.record.name,'", new EventListener() {\n @Override\n public void onEvent(Event event) {\n System.out.println(((NamingEvent)event).getServiceName());\n System.out.println(((NamingEvent)event).getInstances());\n }\n });\n }\n}')}},{key:"getSpringCode",value:function(e){return'/* Refer to document: https://github.com/nacos-group/nacos-examples/tree/master/nacos-spring-example/nacos-spring-discovery-example\n* pom.xml\n \n com.alibaba.nacos\n nacos-spring-context\n ${latest.version}\n \n*/\n\n// Refer to document: https://github.com/nacos-group/nacos-examples/blob/master/nacos-spring-example/nacos-spring-discovery-example/src/main/java/com/alibaba/nacos/example/spring\npackage com.alibaba.nacos.example.spring;\n\nimport com.alibaba.nacos.api.annotation.NacosProperties;\nimport com.alibaba.nacos.spring.context.annotation.discovery.EnableNacosDiscovery;\nimport org.springframework.context.annotation.Configuration;\n\n@Configuration\n@EnableNacosDiscovery(globalProperties = @NacosProperties(serverAddr = "127.0.0.1:8848"))\npublic class NacosConfiguration {\n\n}\n\n// Refer to document: https://github.com/nacos-group/nacos-examples/tree/master/nacos-spring-example/nacos-spring-discovery-example/src/main/java/com/alibaba/nacos/example/spring/controller\npackage com.alibaba.nacos.example.spring.controller;\n\nimport com.alibaba.nacos.api.annotation.NacosInjected;\nimport com.alibaba.nacos.api.exception.NacosException;\nimport com.alibaba.nacos.api.naming.NamingService;\nimport com.alibaba.nacos.api.naming.pojo.Instance;\nimport org.springframework.stereotype.Controller;\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RequestParam;\nimport org.springframework.web.bind.annotation.ResponseBody;\n\nimport java.util.List;\n\nimport static org.springframework.web.bind.annotation.RequestMethod.GET;\n\n@Controller\n@RequestMapping("discovery")\npublic class DiscoveryController {\n\n @NacosInjected\n private NamingService namingService;\n\n @RequestMapping(value = "/get", method = GET)\n @ResponseBody\n public List get(@RequestParam String serviceName) throws NacosException {\n return namingService.getAllInstances(serviceName);\n }\n}'}},{key:"getSpringBootCode",value:function(e){return'/* Refer to document: https://github.com/nacos-group/nacos-examples/blob/master/nacos-spring-boot-example/nacos-spring-boot-discovery-example\n* pom.xml\n \n com.alibaba.boot\n nacos-discovery-spring-boot-starter\n ${latest.version}\n \n*/\n/* Refer to document: https://github.com/nacos-group/nacos-examples/blob/master/nacos-spring-boot-example/nacos-spring-boot-discovery-example/src/main/resources\n* application.properties\n nacos.discovery.server-addr=127.0.0.1:8848\n*/\n// Refer to document: https://github.com/nacos-group/nacos-examples/blob/master/nacos-spring-boot-example/nacos-spring-boot-discovery-example/src/main/java/com/alibaba/nacos/example/spring/boot/controller\n\npackage com.alibaba.nacos.example.spring.boot.controller;\n\nimport com.alibaba.nacos.api.annotation.NacosInjected;\nimport com.alibaba.nacos.api.exception.NacosException;\nimport com.alibaba.nacos.api.naming.NamingService;\nimport com.alibaba.nacos.api.naming.pojo.Instance;\nimport org.springframework.stereotype.Controller;\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RequestParam;\nimport org.springframework.web.bind.annotation.ResponseBody;\n\nimport java.util.List;\n\nimport static org.springframework.web.bind.annotation.RequestMethod.GET;\n\n@Controller\n@RequestMapping("discovery")\npublic class DiscoveryController {\n\n @NacosInjected\n private NamingService namingService;\n\n @RequestMapping(value = "/get", method = GET)\n @ResponseBody\n public List get(@RequestParam String serviceName) throws NacosException {\n return namingService.getAllInstances(serviceName);\n }\n}'}},{key:"getSpringCloudCode",value:function(e){return"/* Refer to document: https://github.com/nacos-group/nacos-examples/blob/master/nacos-spring-cloud-example/nacos-spring-cloud-discovery-example/\n* pom.xml\n \n org.springframework.cloud\n spring-cloud-starter-alibaba-nacos-discovery\n ${latest.version}\n \n*/\n\n// nacos-spring-cloud-provider-example\n\n/* Refer to document: https://github.com/nacos-group/nacos-examples/tree/master/nacos-spring-cloud-example/nacos-spring-cloud-discovery-example/nacos-spring-cloud-provider-example/src/main/resources\n* application.properties\nserver.port=18080\nspring.application.name=".concat(this.record.name,'\nspring.cloud.nacos.discovery.server-addr=127.0.0.1:8848\n*/\n\n// Refer to document: https://github.com/nacos-group/nacos-examples/tree/master/nacos-spring-cloud-example/nacos-spring-cloud-discovery-example/nacos-spring-cloud-provider-example/src/main/java/com/alibaba/nacos/example/spring/cloud\npackage com.alibaba.nacos.example.spring.cloud;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\nimport org.springframework.cloud.client.discovery.EnableDiscoveryClient;\nimport org.springframework.web.bind.annotation.PathVariable;\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RequestMethod;\nimport org.springframework.web.bind.annotation.RestController;\n\n/**\n * @author xiaojing\n */\n@SpringBootApplication\n@EnableDiscoveryClient\npublic class NacosProviderApplication {\n\n public static void main(String[] args) {\n SpringApplication.run(NacosProviderApplication.class, args);\n}\n\n @RestController\n class EchoController {\n @RequestMapping(value = "/echo/{string}", method = RequestMethod.GET)\n public String echo(@PathVariable String string) {\n return "Hello Nacos Discovery " + string;\n }\n }\n}\n\n// nacos-spring-cloud-consumer-example\n\n/* Refer to document: https://github.com/nacos-group/nacos-examples/tree/master/nacos-spring-cloud-example/nacos-spring-cloud-discovery-example/nacos-spring-cloud-consumer-example/src/main/resources\n* application.properties\nspring.application.name=micro-service-oauth2\nspring.cloud.nacos.discovery.server-addr=127.0.0.1:8848\n*/\n\n// Refer to document: https://github.com/nacos-group/nacos-examples/tree/master/nacos-spring-cloud-example/nacos-spring-cloud-discovery-example/nacos-spring-cloud-consumer-example/src/main/java/com/alibaba/nacos/example/spring/cloud\npackage com.alibaba.nacos.example.spring.cloud;\n\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\nimport org.springframework.cloud.client.discovery.EnableDiscoveryClient;\nimport org.springframework.cloud.client.loadbalancer.LoadBalanced;\nimport org.springframework.context.annotation.Bean;\nimport org.springframework.web.bind.annotation.PathVariable;\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RequestMethod;\nimport org.springframework.web.bind.annotation.RestController;\nimport org.springframework.web.client.RestTemplate;\n\n/**\n * @author xiaojing\n */\n@SpringBootApplication\n@EnableDiscoveryClient\npublic class NacosConsumerApplication {\n\n @LoadBalanced\n @Bean\n public RestTemplate restTemplate() {\n return new RestTemplate();\n }\n\n public static void main(String[] args) {\n SpringApplication.run(NacosConsumerApplication.class, args);\n }\n\n @RestController\n public class TestController {\n\n private final RestTemplate restTemplate;\n\n @Autowired\n public TestController(RestTemplate restTemplate) {this.restTemplate = restTemplate;}\n\n @RequestMapping(value = "/echo/{str}", method = RequestMethod.GET)\n public String echo(@PathVariable String str) {\n return restTemplate.getForObject("http://service-provider/echo/" + str, String.class);\n }\n }\n}')}},{key:"getNodejsCode",value:function(e){return"TODO"}},{key:"getCppCode",value:function(e){return"TODO"}},{key:"getShellCode",value:function(e){return"TODO"}},{key:"getPythonCode",value:function(e){return'/*\n* Demo for Nacos\n*/\nimport json\nimport socket\n\nimport nacos\n\n\ndef get_host_ip():\n res = socket.gethostbyname(socket.gethostname())\n return res\n\n\ndef load_config(content):\n _config = json.loads(content)\n return _config\n\n\ndef nacos_config_callback(args):\n content = args[\'raw_content\']\n load_config(content)\n\n\nclass NacosClient:\n service_name = None\n service_port = None\n service_group = None\n\n def __init__(self, server_endpoint, namespace_id, username=None, password=None):\n self.client = nacos.NacosClient(server_endpoint,\n namespace=namespace_id,\n username=username,\n password=password)\n self.endpoint = server_endpoint\n self.service_ip = get_host_ip()\n\n def register(self):\n self.client.add_naming_instance(self.service_name,\n self.service_ip,\n self.service_port,\n group_name=self.service_group)\n\n def modify(self, service_name, service_ip=None, service_port=None):\n self.client.modify_naming_instance(service_name,\n service_ip if service_ip else self.service_ip,\n service_port if service_port else self.service_port)\n\n def unregister(self):\n self.client.remove_naming_instance(self.service_name,\n self.service_ip,\n self.service_port)\n\n def set_service(self, service_name, service_ip, service_port, service_group):\n self.service_name = service_name\n self.service_ip = service_ip\n self.service_port = service_port\n self.service_group = service_group\n\n async def beat_callback(self):\n self.client.send_heartbeat(self.service_name,\n self.service_ip,\n self.service_port)\n\n def load_conf(self, data_id, group):\n return self.client.get_config(data_id=data_id, group=group, no_snapshot=True)\n\n def add_conf_watcher(self, data_id, group, callback):\n self.client.add_config_watcher(data_id=data_id, group=group, cb=callback)\n\n\nif __name__ == \'__main__\':\n nacos_config = {\n "nacos_data_id":"test",\n "nacos_server_ip":"127.0.0.1",\n "nacos_namespace":"public",\n "nacos_groupName":"DEFAULT_GROUP",\n "nacos_user":"nacos",\n "nacos_password":"1234567"\n }\n nacos_data_id = nacos_config["nacos_data_id"]\n SERVER_ADDRESSES = nacos_config["nacos_server_ip"]\n NAMESPACE = nacos_config["nacos_namespace"]\n groupName = nacos_config["nacos_groupName"]\n user = nacos_config["nacos_user"]\n password = nacos_config["nacos_password"]\n # todo 将另一个路由对象(通常定义在其他模块或文件中)合并到主应用(app)中。\n # app.include_router(custom_api.router, tags=[\'test\'])\n service_ip = get_host_ip()\n client = NacosClient(SERVER_ADDRESSES, NAMESPACE, user, password)\n client.add_conf_watcher(nacos_data_id, groupName, nacos_config_callback)\n\n # 启动时,强制同步一次配置\n data_stream = client.load_conf(nacos_data_id, groupName)\n json_config = load_config(data_stream)\n #设定服务\n client.set_service(json_config["service_name"], json_config.get("service_ip", service_ip), service_port, groupName)\n #注册服务\n client.register()\n #下线服务\n client.unregister()\n'}},{key:"getCSharpCode",value:function(e){return'/* Refer to document: https://github.com/nacos-group/nacos-sdk-csharp/\nDemo for Basic Nacos Opreation\nApp.csproj\n\n\n \n\n*/\n\nusing Microsoft.Extensions.DependencyInjection;\nusing Nacos.V2;\nusing Nacos.V2.DependencyInjection;\nusing System;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n IServiceCollection services = new ServiceCollection();\n\n services.AddNacosV2Naming(x =>\n {\n x.ServerAddresses = new List { "http://localhost:8848/" };\n x.Namespace = "cs-test";\n\n // swich to use http or rpc\n x.NamingUseRpc = true;\n });\n\n IServiceProvider serviceProvider = services.BuildServiceProvider();\n var namingSvc = serviceProvider.GetService();\n\n await namingSvc.RegisterInstance("'.concat(this.record.name,'", "11.11.11.11", 8888, "TEST1");\n\n await namingSvc.RegisterInstance("').concat(this.record.name,'", "2.2.2.2", 9999, "DEFAULT");\n\n Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(await namingSvc.GetAllInstances("').concat(this.record.name,'")));\n\n await namingSvc.DeregisterInstance("').concat(this.record.name,'", "2.2.2.2", 9999, "DEFAULT");\n\n var listener = new EventListener();\n\n await namingSvc.Subscribe("').concat(this.record.name,'", listener);\n }\n\n internal class EventListener : IEventListener\n {\n public Task OnEvent(IEvent @event)\n {\n Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(@event));\n return Task.CompletedTask;\n }\n }\n}\n\n/* Refer to document: https://github.com/nacos-group/nacos-sdk-csharp/\nDemo for ASP.NET Core Integration\nApp.csproj\n\n\n \n\n*/\n\n/* Refer to document: https://github.com/nacos-group/nacos-sdk-csharp/blob/dev/samples/App1/appsettings.json\n* appsettings.json\n{\n "nacos": {\n "ServerAddresses": [ "http://localhost:8848" ],\n "DefaultTimeOut": 15000,\n "Namespace": "cs",\n "ServiceName": "App1",\n "GroupName": "DEFAULT_GROUP",\n "ClusterName": "DEFAULT",\n "Port": 0,\n "Weight": 100,\n "RegisterEnabled": true,\n "InstanceEnabled": true,\n "Ephemeral": true,\n "NamingUseRpc": true,\n "NamingLoadCacheAtStart": ""\n }\n}\n*/\n\n// Refer to document: https://github.com/nacos-group/nacos-sdk-csharp/blob/dev/samples/App1/Startup.cs\nusing Nacos.AspNetCore.V2;\n\npublic class Startup\n{\n public Startup(IConfiguration configuration)\n {\n Configuration = configuration;\n }\n\n public IConfiguration Configuration { get; }\n\n public void ConfigureServices(IServiceCollection services)\n {\n // ....\n services.AddNacosAspNet(Configuration);\n }\n\n public void Configure(IApplicationBuilder app, IWebHostEnvironment env)\n {\n // ....\n }\n}\n ')}},{key:"openDialog",value:function(e){var t=this;this.setState({dialogvisible:!0}),this.record=e,setTimeout(function(){t.getData()})}},{key:"closeDialog",value:function(){this.setState({dialogvisible:!1})}},{key:"createCodeMirror",value:function(e,t){var n=this.refs.codepreview;n&&(n.innerHTML="",this.cm=window.CodeMirror(n,{value:t,mode:e,height:400,width:500,lineNumbers:!0,theme:"xq-light",lint:!0,tabMode:"indent",autoMatchParens:!0,textWrapping:!0,gutters:["CodeMirror-lint-markers"],extraKeys:{F1:function(e){e.setOption("fullScreen",!e.getOption("fullScreen"))},Esc:function(e){e.getOption("fullScreen")&&e.setOption("fullScreen",!1)}}}),this.cm.setSize("auto","490px"))}},{key:"changeTab",value:function(e,t){var n=this;setTimeout(function(){n[e]=!0,n.createCodeMirror("text/javascript",t)})}},{key:"render",value:function(){var e=this.props.locale,e=void 0===e?{}:e;return O.a.createElement("div",null,O.a.createElement(o.a,{title:e.sampleCode,style:{width:"80%"},visible:this.state.dialogvisible,footer:O.a.createElement("div",null),onClose:this.closeDialog.bind(this)},O.a.createElement("div",{style:{height:500}},O.a.createElement(h.a,{tip:e.loading,style:{width:"100%"},visible:this.state.loading},O.a.createElement(m.a,{shape:"text",style:{height:40,paddingBottom:10}},O.a.createElement(g,{title:"Java",key:0,onClick:this.changeTab.bind(this,"commoneditor1",this.defaultCode)}),O.a.createElement(g,{title:"Spring",key:1,onClick:this.changeTab.bind(this,"commoneditor1",this.springCode)}),O.a.createElement(g,{title:"Spring Boot",key:2,onClick:this.changeTab.bind(this,"commoneditor2",this.sprigbootCode)}),O.a.createElement(g,{title:"Spring Cloud",key:21,onClick:this.changeTab.bind(this,"commoneditor21",this.sprigcloudCode)}),O.a.createElement(g,{title:"Node.js",key:3,onClick:this.changeTab.bind(this,"commoneditor3",this.nodejsCode)}),O.a.createElement(g,{title:"C++",key:4,onClick:this.changeTab.bind(this,"commoneditor4",this.cppCode)}),O.a.createElement(g,{title:"Shell",key:5,onClick:this.changeTab.bind(this,"commoneditor5",this.shellCode)}),O.a.createElement(g,{title:"Python",key:6,onClick:this.changeTab.bind(this,"commoneditor6",this.pythonCode)}),O.a.createElement(g,{title:"C#",key:7,onClick:this.changeTab.bind(this,"commoneditor7",this.csharpCode)})),O.a.createElement("div",{ref:"codepreview"})))))}}]),n}(O.a.Component)).displayName="ShowServiceCodeing",f=f))||f,Y=t(51),I=t(146),A=(t(778),t(22)),R=L.a.Item,H=d.a.Row,F=d.a.Col,z=T.a.Column,d=(0,n.a.config)(((f=function(e){Object(u.a)(n,e);var t=Object(c.a)(n);function n(e){var a;return Object(s.a)(this,n),(a=t.call(this,e)).getQueryLater=function(){setTimeout(function(){return a.queryServiceList()})},a.showcode=function(){setTimeout(function(){return a.queryServiceList()})},a.setNowNameSpace=function(e,t,n){return a.setState({nowNamespaceName:e,nowNamespaceId:t,nowNamespaceDesc:n})},a.rowColor=function(e){return{className:e.healthyInstanceCount?"":"row-bg-red"}},a.editServiceDialog=O.a.createRef(),a.showcode=O.a.createRef(),a.state={loading:!1,total:0,pageSize:10,currentPage:1,dataSource:[],search:{serviceName:Object(p.b)("serviceNameParam")||"",groupName:Object(p.b)("groupNameParam")||""},ignoreEmptyService:!("false"===localStorage.getItem("ignoreEmptyService"))},a.field=new i.a(Object(l.a)(a)),a}return Object(a.a)(n,[{key:"openLoading",value:function(){this.setState({loading:!0})}},{key:"closeLoading",value:function(){this.setState({loading:!1})}},{key:"openEditServiceDialog",value:function(){try{this.editServiceDialog.current.getInstance().show(this.state.service)}catch(e){}}},{key:"queryServiceList",value:function(){var n=this,e=this.state,t=e.currentPage,a=e.pageSize,r=e.search,o=e.withInstances,o=void 0!==o&&o,e=e.ignoreEmptyService,e=["ignoreEmptyService=".concat(e),"withInstances=".concat(o),"pageNo=".concat(t),"pageSize=".concat(a),"serviceNameParam=".concat(r.serviceName),"groupNameParam=".concat(r.groupName)];Object(p.f)({serviceNameParam:r.serviceName,groupNameParam:r.groupName}),this.openLoading(),Object(p.e)({url:"v3/console/ns/service/list?".concat(e.join("&")),success:function(e){var e=e.data,e=void 0===e?{}:e,t=e.count,e=e.serviceList;n.setState({dataSource:void 0===e?[]:e,total:void 0===t?0:t,loading:!1})},error:function(){return n.setState({dataSource:[],total:0,currentPage:0,loading:!1})}})}},{key:"showSampleCode",value:function(e){this.showcode.current.getInstance().openDialog(e)}},{key:"querySubscriber",value:function(e){var t=e.name,e=e.groupName,n=this.state.nowNamespaceId;this.props.history.push(Object(D.a)("/subscriberList",{namespace:n,name:t,groupName:e}))}},{key:"handlePageSizeChange",value:function(e){var t=this;this.setState({pageSize:e},function(){return t.queryServiceList()})}},{key:"deleteService",value:function(e){var t=this,n=this.props.locale,n=void 0===n?{}:n,a=n.prompt,n=n.promptDelete;o.a.confirm({title:a,content:n,onOk:function(){Object(p.e)({method:"DELETE",url:"v3/console/ns/service?serviceName=".concat(e.name,"&groupName=").concat(e.groupName),dataType:"json",beforeSend:function(){return t.openLoading()},success:function(e){0!==e.code?r.a.error(e.message||"删除服务失败"):(r.a.success("服务删除成功"),t.queryServiceList())},error:function(e){var t;r.a.error((null==(t=e.data)?void 0:t.responseText)||e.statusText||"请求失败")},complete:function(){return t.closeLoading()}})}})}},{key:"render",value:function(){var a=this,e=this.props.locale,t=void 0===e?{}:e,e=t.pubNoData,n=t.serviceList,r=t.serviceName,o=t.serviceNamePlaceholder,i=t.groupName,s=t.groupNamePlaceholder,l=t.hiddenEmptyService,u=t.query,c=t.create,d=t.operation,f=t.detail,p=t.sampleCode,h=t.deleteAction,m=t.subscriber,g=this.state,y=g.search,v=g.nowNamespaceName,_=g.nowNamespaceId,b=g.nowNamespaceDesc,g=g.ignoreEmptyService,w=this.field,M=w.init,w=w.getValue;return this.init=M,this.getValue=w,O.a.createElement("div",{className:"main-container service-management"},O.a.createElement(Y.a,{title:n,desc:b,namespaceId:_,namespaceName:v,nameSpace:!0}),O.a.createElement(N.a,{setNowNameSpace:this.setNowNameSpace,namespaceCallBack:this.getQueryLater}),O.a.createElement(H,{className:"demo-row",style:{marginBottom:10,padding:0}},O.a.createElement(F,{span:"24"},O.a.createElement(L.a,{inline:!0,field:this.field},O.a.createElement(R,{label:""},O.a.createElement(C.a,{type:"primary",onClick:function(){return a.openEditServiceDialog()}},c)),O.a.createElement(R,{label:r},O.a.createElement(E.a,{placeholder:o,style:{width:200},value:y.serviceName,onChange:function(e){return a.setState({search:Object(x.a)(Object(x.a)({},y),{},{serviceName:e})})},onPressEnter:function(){return a.setState({currentPage:1},function(){return a.queryServiceList()})}})),O.a.createElement(R,{label:i},O.a.createElement(E.a,{placeholder:s,style:{width:200},value:y.groupName,onChange:function(e){return a.setState({search:Object(x.a)(Object(x.a)({},y),{},{groupName:e})})},onPressEnter:function(){return a.setState({currentPage:1},function(){return a.queryServiceList()})}})),O.a.createElement(L.a.Item,{label:"".concat(l)},O.a.createElement(k.a,{checked:g,onChange:function(e){return a.setState({ignoreEmptyService:e,currentPage:1},function(){localStorage.setItem("ignoreEmptyService",e),a.queryServiceList()})}})),O.a.createElement(R,{label:""},O.a.createElement(C.a,{type:"primary",onClick:function(){return a.setState({currentPage:1},function(){return a.queryServiceList()})},style:{marginRight:10}},u))))),O.a.createElement(H,{style:{padding:0}},O.a.createElement(F,{span:"24",style:{padding:0}},O.a.createElement(T.a,{dataSource:this.state.dataSource,locale:{empty:e},rowProps:function(e){return a.rowColor(e)},loading:this.state.loading},O.a.createElement(z,{title:t.columnServiceName,dataIndex:"name"}),O.a.createElement(z,{title:t.groupName,dataIndex:"groupName"}),O.a.createElement(z,{title:t.columnClusterCount,dataIndex:"clusterCount"}),O.a.createElement(z,{title:t.columnIpCount,dataIndex:"ipCount"}),O.a.createElement(z,{title:t.columnHealthyInstanceCount,dataIndex:"healthyInstanceCount"}),O.a.createElement(z,{title:t.columnTriggerFlag,dataIndex:"triggerFlag"}),O.a.createElement(z,{title:d,align:"center",cell:function(e,t,n){return O.a.createElement("div",null,O.a.createElement("a",{onClick:function(){var e=n.name,t=n.groupName;a.props.history.push(Object(D.a)("/serviceDetail",{name:e,groupName:t}))},style:{marginRight:5}},f),O.a.createElement("span",{style:{marginRight:5}},"|"),O.a.createElement("a",{style:{marginRight:5},onClick:function(){return a.showSampleCode(n)}},p),O.a.createElement("span",{style:{marginRight:5}},"|"),O.a.createElement("a",{style:{marginRight:5},onClick:function(){return a.querySubscriber(n)}},m),O.a.createElement("span",{style:{marginRight:5}},"|"),O.a.createElement("a",{onClick:function(){return a.deleteService(n)},style:{marginRight:5}},h))}})))),O.a.createElement("div",{style:{marginTop:10,textAlign:"right"}},O.a.createElement(S.a,{current:this.state.currentPage,pageSizeList:A.f,pageSizePosition:"start",pageSizeSelector:"dropdown",popupProps:{align:"bl tl"},total:this.state.total,pageSize:this.state.pageSize,totalRender:function(e){return O.a.createElement(I.a,{locale:t,total:e})},onPageSizeChange:function(e){return a.handlePageSizeChange(e)},onChange:function(e){return a.setState({currentPage:e},function(){return a.queryServiceList()})}})),O.a.createElement(j,{ref:this.showcode}),O.a.createElement(P.a,{ref:this.editServiceDialog,openLoading:function(){return a.openLoading()},closeLoading:function(){return a.closeLoading()},queryServiceList:function(){return a.setState({currentPage:1},function(){return a.queryServiceList()})}}))}}]),n}(O.a.Component)).displayName="ServiceList",t=f))||t;e.a=d},function(e,t,n){"use strict";n(67);var a=n(47),u=n.n(a),a=(n(35),n(18)),c=n.n(a),a=(n(66),n(21)),d=n.n(a),a=(n(34),n(20)),f=n.n(a),a=(n(93),n(55)),p=n.n(a),a=(n(38),n(2)),h=n.n(a),a=(n(37),n(10)),m=n.n(a),i=n(13),s=n(14),l=n(23),g=n(16),y=n(15),a=(n(27),n(6)),a=n.n(a),r=n(0),v=n.n(r),r=n(30),_=n(45),b=n(53),w=n(32),o=(n(49),n(28)),M=n.n(o),S=(n(168),h.a.Item),k={labelCol:{fixedSpan:4},wrapperCol:{span:19}},E=(0,a.a.config)(((o=function(e){Object(g.a)(o,e);var r=Object(y.a)(o);function o(){var e;Object(i.a)(this,o);for(var t=arguments.length,n=new Array(t),a=0;ao&&v.a.createElement(u.a,{className:"users-pagination",current:i,total:n.totalCount,pageSize:o,onChange:function(e){return t.setState({pageNo:e},function(){return t.getUsers()})}}),v.a.createElement(E,{visible:s,onOk:function(e){return Object(_.d)(e).then(function(e){return t.setState({pageNo:1},function(){return t.getUsers()}),e})},onCancel:function(){return t.colseCreateUser()}}),v.a.createElement(x.a,{visible:l,username:e,onOk:function(e){return Object(_.l)(e).then(function(e){return t.getUsers(),e})},onCancel:function(){return t.setState({passwordResetUser:void 0,passwordResetUserVisible:!1})}}))}}]),n}(v.a.Component)).displayName="UserManagement",n=o))||n)||n;t.a=r},function(e,t,n){"use strict";n(46);var a=n(24),l=n.n(a),a=(n(67),n(47)),u=n.n(a),a=(n(35),n(18)),c=n.n(a),d=n(32),a=(n(66),n(21)),f=n.n(a),a=(n(34),n(20)),p=n.n(a),a=(n(93),n(55)),h=n.n(a),a=(n(38),n(2)),m=n.n(a),a=(n(37),n(10)),g=n.n(a),i=n(13),s=n(14),y=n(23),v=n(16),_=n(15),a=(n(27),n(6)),a=n.n(a),r=n(0),b=n.n(r),r=n(30),w=n(45),o=n(86),M=n(53),S=(n(49),n(28)),k=n.n(S),S=(n(59),n(29)),E=n.n(S),x=m.a.Item,C=E.a.Option,T={labelCol:{fixedSpan:4},wrapperCol:{span:19}},L=Object(r.b)(function(e){return{namespaces:e.namespace.namespaces}},{getNamespaces:o.b,searchRoles:w.m})(S=(0,a.a.config)(((S=function(e){Object(v.a)(o,e);var r=Object(_.a)(o);function o(){var t;Object(i.a)(this,o);for(var e=arguments.length,n=new Array(e),a=0;ai&&b.a.createElement(u.a,{className:"users-pagination",current:s,total:t.totalCount,pageSize:i,onChange:function(e){return a.setState({pageNo:e},function(){return a.getPermissions()})}}),b.a.createElement(L,{visible:n,onOk:function(t){return Object(w.a)(t).then(function(e){e?l.a.error({content:o.checkPermission}):Object(w.b)(t).then(function(e){return a.setState({pageNo:1},function(){return a.getPermissions()}),e})})},onCancel:function(){return a.colseCreatePermission()}}))}}]),n}(b.a.Component)).displayName="PermissionsManagement",n=S))||n)||n);t.a=r},function(e,t,n){"use strict";n(67);var a=n(47),l=n.n(a),a=(n(35),n(18)),u=n.n(a),a=(n(66),n(21)),c=n.n(a),a=(n(34),n(20)),d=n.n(a),a=(n(93),n(55)),f=n.n(a),a=(n(38),n(2)),p=n.n(a),a=(n(37),n(10)),h=n.n(a),i=n(13),s=n(14),m=n(23),g=n(16),y=n(15),a=(n(27),n(6)),a=n.n(a),r=n(0),v=n.n(r),r=n(30),_=n(45),b=n(53),o=(n(59),n(29)),w=n.n(o),o=(n(49),n(28)),M=n.n(o),S=p.a.Item,k={labelCol:{fixedSpan:4},wrapperCol:{span:19}},E=Object(r.b)(function(e){return{users:e.authority.users}},{searchUsers:_.n})(o=(0,a.a.config)(((o=function(e){Object(g.a)(o,e);var r=Object(y.a)(o);function o(){var t;Object(i.a)(this,o);for(var e=arguments.length,n=new Array(e),a=0;ao&&v.a.createElement(l.a,{className:"users-pagination",current:i,total:t.totalCount,pageSize:o,onChange:function(e){return a.setState({pageNo:e},function(){return a.getRoles()})}}),v.a.createElement(E,{visible:s,onOk:function(e){return Object(_.c)(e).then(function(e){return a.getRoles(),e})},onCancel:function(){return a.colseCreateRole()}}))}}]),n}(v.a.Component)).displayName="RolesManagement",n=o))||n)||n);t.a=r},function(e,t,n){"use strict";n(35);function l(e){var t=void 0===(t=localStorage.token)?"{}":t,t=(Object(_.c)(t)&&JSON.parse(t)||{}).globalAdmin,n=[];return"naming"===e?n.push(b):"config"===e?n.push(w):n.push(w,b),t&&n.push(M),n.push(S),n.push(k),n.push(E),n.filter(function(e){return e})}var a=n(18),u=n.n(a),a=(n(46),n(24)),c=n.n(a),a=(n(43),n(26)),d=n.n(a),r=n(13),o=n(14),i=n(16),s=n(15),a=(n(27),n(6)),a=n.n(a),f=n(12),p=(n(84),n(50)),h=n.n(p),p=n(0),m=n.n(p),p=n(39),g=n(30),y=n(108),v=n(52),_=n(48),b={key:"serviceManagementVirtual",children:[{key:"serviceManagement",url:"/serviceManagement"},{key:"subscriberList",url:"/subscriberList"}]},w={key:"configurationManagementVirtual",children:[{key:"configurationManagement",url:"/configurationManagement"},{key:"historyRollback",url:"/historyRollback"},{key:"listeningToQuery",url:"/listeningToQuery"}]},M={key:"authorityControl",children:[{key:"userList",url:"/userManagement"},{key:"roleManagement",url:"/rolesManagement"},{key:"privilegeManagement",url:"/permissionsManagement"}]},S={key:"namespace",url:"/namespace"},k={key:"clusterManagementVirtual",children:[{key:"clusterManagement",url:"/clusterManagement"}]},E={key:"settingCenter",url:"/settingCenter"},x=(n(386),h.a.SubMenu),C=h.a.Item,p=(n=Object(g.b)(function(e){return Object(f.a)(Object(f.a)({},e.locale),e.base)},{getState:v.e,getNotice:v.d,getGuide:v.c}),g=a.a.config,Object(p.g)(a=n(a=g(((v=function(e){Object(i.a)(n,e);var t=Object(s.a)(n);function n(e){return Object(r.a)(this,n),(e=t.call(this,e)).state={visible:!0},e}return Object(o.a)(n,[{key:"componentDidMount",value:function(){this.props.getState(),this.props.getNotice(),this.props.getGuide()}},{key:"goBack",value:function(){this.props.history.goBack()}},{key:"navTo",value:function(e){var t=this.props.location.search,t=new URLSearchParams(t);t.set("namespace",window.nownamespace),t.set("namespaceShowName",window.namespaceShowName),this.props.history.push([e,"?",t.toString()].join(""))}},{key:"isCurrentPath",value:function(e){return e===this.props.location.pathname?"current-path next-selected":void 0}},{key:"defaultOpenKeys",value:function(){for(var t=this,e=l(this.props.functionMode),n=0,a=e.length;nthis.state.pageSize&&k.a.createElement("div",{style:{marginTop:10,textAlign:"right"}},k.a.createElement(v.a,{current:this.state.pageNo,total:a,pageSize:this.state.pageSize,onChange:function(e){return t.setState({pageNo:e},function(){return t.querySubscriberList()})}}))))}}]),n}(k.a.Component)).displayName="SubscriberList",d=n))||d)||d;t.a=f},function(e,t,n){"use strict";n(54);var a=n(36),c=n.n(a),a=(n(67),n(47)),d=n.n(a),a=(n(179),n(78)),f=n.n(a),a=(n(37),n(10)),p=n.n(a),a=(n(34),n(20)),h=n.n(a),a=(n(35),n(18)),r=n.n(a),a=(n(46),n(24)),o=n.n(a),a=(n(49),n(28)),i=n.n(a),s=n(13),l=n(14),u=n(23),m=n(16),g=n(15),a=(n(27),n(6)),a=n.n(a),y=(n(421),n(123)),v=n.n(y),y=(n(66),n(21)),_=n.n(y),y=(n(69),n(40)),y=n.n(y),b=(n(38),n(2)),w=n.n(b),b=n(0),M=n.n(b),S=n(1),b=n(144),k=n.n(b),E=n(51),x=(n(781),w.a.Item),C=y.a.Row,T=y.a.Col,L=_.a.Column,O=v.a.Panel,y=(0,a.a.config)(((b=function(e){Object(m.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(s.a)(this,a),(n=t.call(this,e)).getQueryLater=function(){setTimeout(function(){return n.queryClusterStateList()})},n.setNowNameSpace=function(e,t){return n.setState({nowNamespaceName:e,nowNamespaceId:t})},n.rowColor=function(e){return{className:(e.voteFor,"")}},n.state={loading:!1,total:0,pageSize:10,currentPage:1,keyword:"",dataSource:[]},n.field=new i.a(Object(u.a)(n)),n}return Object(l.a)(a,[{key:"componentDidMount",value:function(){this.getQueryLater()}},{key:"openLoading",value:function(){this.setState({loading:!0})}},{key:"closeLoading",value:function(){this.setState({loading:!1})}},{key:"queryClusterStateList",value:function(){var n=this,e=this.state,t=e.currentPage,a=e.pageSize,r=e.keyword,e=e.withInstances,e=["withInstances=".concat(void 0!==e&&e),"pageNo=".concat(t),"pageSize=".concat(a),"keyword=".concat(r)];Object(S.e)({url:"v3/console/core/cluster/nodes?".concat(e.join("&")),beforeSend:function(){return n.openLoading()},success:function(){var e=0this.state.pageSize&&M.a.createElement("div",{style:{marginTop:10,textAlign:"right"}},M.a.createElement(d.a,{current:this.state.currentPage,total:this.state.total,pageSize:this.state.pageSize,onChange:function(e){return t.setState({currentPage:e},function(){return t.queryClusterStateList()})}}))))}}]),a}(M.a.Component)).displayName="ClusterNodeList",n=b))||n;t.a=y},function(e,t,n){"use strict";n(34);var a=n(20),i=n.n(a),s=n(13),l=n(14),u=n(16),c=n(15),a=(n(27),n(6)),a=n.n(a),r=n(12),o=(n(114),n(75)),o=n.n(o),d=n(0),f=n.n(d),p=(n(784),n(51)),d=n(87),h=n(148),m=n(149),g=n(30),y=n(22),v=o.a.Group,g=Object(g.b)(function(e){return Object(r.a)({},e.locale)},{changeLanguage:d.a,changeTheme:h.a,changeNameShow:m.a})(o=(0,a.a.config)(((n=function(e){Object(u.a)(o,e);var r=Object(c.a)(o);function o(e){Object(s.a)(this,o),e=r.call(this,e);var t=localStorage.getItem(y.p),n=localStorage.getItem(y.j),a=localStorage.getItem(y.g);return e.state={theme:"dark"===t?"dark":"light",language:"en-US"===a?"en-US":"zh-CN",nameShow:"select"===n?"select":"label"},e}return Object(l.a)(o,[{key:"newTheme",value:function(e){this.setState({theme:e})}},{key:"newLanguage",value:function(e){this.setState({language:e})}},{key:"newNameShow",value:function(e){this.setState({nameShow:e})}},{key:"submit",value:function(){var e=this.props,t=e.changeLanguage,n=e.changeTheme,e=e.changeNameShow,a=this.state.language,r=this.state.theme,o=this.state.nameShow;t(a),n(r),e(o)}},{key:"render",value:function(){var e=this.props.locale,e=void 0===e?{}:e,t=[{value:"light",label:e.settingLight},{value:"dark",label:e.settingDark}],n=[{value:"select",label:e.settingShowSelect},{value:"label",label:e.settingShowLabel}];return f.a.createElement(f.a.Fragment,null,f.a.createElement(p.a,{title:e.settingTitle}),f.a.createElement("div",{className:"setting-box"},f.a.createElement("div",{className:"text-box"},f.a.createElement("div",{className:"setting-checkbox"},f.a.createElement("div",{className:"setting-span"},e.settingTheme),f.a.createElement(v,{dataSource:t,value:this.state.theme,onChange:this.newTheme.bind(this)})),f.a.createElement("div",{className:"setting-checkbox"},f.a.createElement("div",{className:"setting-span"},e.settingLocale),f.a.createElement(v,{dataSource:[{value:"en-US",label:"English"},{value:"zh-CN",label:"中文"}],value:this.state.language,onChange:this.newLanguage.bind(this)})),f.a.createElement("div",{className:"setting-checkbox"},f.a.createElement("div",{className:"setting-span"},e.settingShow),f.a.createElement(v,{dataSource:n,value:this.state.nameShow,onChange:this.newNameShow.bind(this)}))),f.a.createElement(i.a,{type:"primary",onClick:this.submit.bind(this)},e.settingSubmit)))}}]),o}(f.a.Component)).displayName="SettingCenter",o=n))||o)||o;t.a=g},function(e,t,V){"use strict";V.r(t),function(e){V(54);var t=V(36),a=V.n(t),t=(V(27),V(6)),r=V.n(t),o=V(13),i=V(14),s=V(16),l=V(15),n=V(12),t=V(0),u=V.n(t),t=V(25),t=V.n(t),c=V(125),d=V(429),f=V(440),p=V(30),h=V(39),m=V(73),g=(V(477),V(449)),y=V(22),v=V(450),_=V(451),b=V(443),w=V(452),M=V(453),S=V(444),k=V(454),E=V(455),x=V(456),C=V(457),T=V(458),L=V(441),O=V(445),D=V(442),N=V(459),P=V(460),j=V(446),I=V(447),A=V(448),R=V(438),H=V(461),Y=V(439),F=V(87),z=V(52),W=V(148),B=V(149),e=(V(785),e.hot,localStorage.getItem(y.g)||localStorage.setItem(y.g,"zh-CN"===navigator.language?"zh-CN":"en-US"),Object(c.b)(Object(n.a)(Object(n.a)({},Y.a),{},{routing:d.routerReducer}))),Y=Object(c.d)(e,Object(c.c)(Object(c.a)(f.a),window[y.l]?window[y.l]():function(e){return e})),U=[{path:"/",exact:!0,render:function(){return u.a.createElement(h.a,{to:"/welcome"})}},{path:"/welcome",component:R.a},{path:"/namespace",component:b.a},{path:"/newconfig",component:w.a},{path:"/configsync",component:M.a},{path:"/configdetail",component:S.a},{path:"/configeditor",component:k.a},{path:"/historyDetail",component:E.a},{path:"/configRollback",component:x.a},{path:"/historyRollback",component:C.a},{path:"/listeningToQuery",component:T.a},{path:"/configurationManagement",component:L.a},{path:"/serviceManagement",component:O.a},{path:"/serviceDetail",component:D.a},{path:"/subscriberList",component:N.a},{path:"/clusterManagement",component:P.a},{path:"/userManagement",component:j.a},{path:"/rolesManagement",component:A.a},{path:"/permissionsManagement",component:I.a},{path:"/settingCenter",component:H.a}],e=Object(p.b)(function(e){return Object(n.a)(Object(n.a)({},e.locale),e.base)},{changeLanguage:F.a,getState:z.e,changeTheme:W.a,changeNameShow:B.a})(d=function(e){Object(s.a)(n,e);var t=Object(l.a)(n);function n(e){return Object(o.a)(this,n),(e=t.call(this,e)).state={shownotice:"none",noticecontent:"",nacosLoading:{}},e}return Object(i.a)(n,[{key:"componentDidMount",value:function(){this.props.getState();var e=localStorage.getItem(y.g),t=localStorage.getItem(y.p),n=localStorage.getItem(y.j);this.props.changeLanguage(e),this.props.changeTheme(t),this.props.changeNameShow(n)}},{key:"router",get:function(){var e=this.props,t=e.loginPageEnabled,e=e.consoleUiEnable;return u.a.createElement(m.a,null,u.a.createElement(h.d,null,t&&"false"===t?null:u.a.createElement(h.b,{path:"/login",component:v.a}),u.a.createElement(h.b,{path:"/register",component:_.a}),u.a.createElement(g.a,null,e&&"true"===e&&U.map(function(e){return u.a.createElement(h.b,Object.assign({key:e.path},e))}))))}},{key:"render",value:function(){var e=this.props,t=e.locale,e=e.loginPageEnabled;return u.a.createElement(a.a,Object.assign({className:"nacos-loading",shape:"flower",tip:"loading...",visible:!e,fullScreen:!0},this.state.nacosLoading),u.a.createElement(r.a,{locale:t},this.router))}}]),n}(u.a.Component))||d;t.a.render(u.a.createElement(p.a,{store:Y},u.a.createElement(e,null)),document.getElementById("root"))}.call(this,V(463)(e))},function(e,t){e.exports=function(e){var t;return e.webpackPolyfill||((t=Object.create(e)).children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),Object.defineProperty(t,"exports",{enumerable:!0}),t.webpackPolyfill=1),t}},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(I,e,t){"use strict"; +var k=P(706),o=P(707),s=P(708);function n(){return d.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function l(e,t){if(n()=n())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n().toString(16)+" bytes");return 0|e}function f(e,t){if(d.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;var n=(e="string"!=typeof e?""+e:e).length;if(0===n)return 0;for(var a=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return L(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return O(e).length;default:if(a)return L(e).length;t=(""+t).toLowerCase(),a=!0}}function t(e,t,n){var a,r=!1;if((t=void 0===t||t<0?0:t)>this.length)return"";if((n=void 0===n||n>this.length?this.length:n)<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e=e||"utf8";;)switch(e){case"hex":var o=this,i=t,s=n,l=o.length;(!s||s<0||l=e.length){if(r)return-1;n=e.length-1}else if(n<0){if(!r)return-1;n=0}if("string"==typeof t&&(t=d.from(t,a)),d.isBuffer(t))return 0===t.length?-1:m(e,t,n,a,r);if("number"==typeof t)return t&=255,d.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?(r?Uint8Array.prototype.indexOf:Uint8Array.prototype.lastIndexOf).call(e,t,n):m(e,[t],n,a,r);throw new TypeError("val must be string, number or Buffer")}function m(e,t,n,a,r){var o=1,i=e.length,s=t.length;if(void 0!==a&&("ucs2"===(a=String(a).toLowerCase())||"ucs-2"===a||"utf16le"===a||"utf-16le"===a)){if(e.length<2||t.length<2)return-1;i/=o=2,s/=2,n/=2}function l(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(r)for(var u=-1,c=n;c>8,r.push(n%256),r.push(a);return r}(t,e.length-n),e,n,a)}function E(e,t,n){n=Math.min(e.length,n);for(var a=[],r=t;r>>10&1023|55296),c=56320|1023&c),a.push(c),r+=d}var f=a,p=f.length;if(p<=v)return String.fromCharCode.apply(String,f);for(var h="",m=0;mt)&&(e+=" ... "),""},d.prototype.compare=function(e,t,n,a,r){if(!d.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===n&&(n=e?e.length:0),void 0===a&&(a=0),void 0===r&&(r=this.length),(t=void 0===t?0:t)<0||n>e.length||a<0||r>this.length)throw new RangeError("out of range index");if(r<=a&&n<=t)return 0;if(r<=a)return-1;if(n<=t)return 1;if(this===e)return 0;for(var o=(r>>>=0)-(a>>>=0),i=(n>>>=0)-(t>>>=0),s=Math.min(o,i),l=this.slice(a,r),u=e.slice(t,n),c=0;cthis.length)throw new RangeError("Attempt to write outside buffer bounds");a=a||"utf8";for(var o,i,s,l=!1;;)switch(a){case"hex":var u=this,c=e,d=t,f=n,p=(d=Number(d)||0,u.length-d);if((!f||p<(f=Number(f)))&&(f=p),(p=c.length)%2!=0)throw new TypeError("Invalid hex string");p/2e.length)throw new RangeError("Index out of range")}function w(e,t,n,a){t<0&&(t=65535+t+1);for(var r=0,o=Math.min(e.length-n,2);r>>8*(a?r:1-r)}function M(e,t,n,a){t<0&&(t=4294967295+t+1);for(var r=0,o=Math.min(e.length-n,4);r>>8*(a?r:3-r)&255}function S(e,t,n,a){if(n+a>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function x(e,t,n,a,r){return r||S(e,0,n,4),o.write(e,t,n,a,23,4),n+4}function C(e,t,n,a,r){return r||S(e,0,n,8),o.write(e,t,n,a,52,8),n+8}d.prototype.slice=function(e,t){var n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):n>>8):w(this,e,t,!0),t+2},d.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||b(this,e,t,2,65535,0),d.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):w(this,e,t,!1),t+2},d.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||b(this,e,t,4,4294967295,0),d.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):M(this,e,t,!0),t+4},d.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||b(this,e,t,4,4294967295,0),d.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},d.prototype.writeIntLE=function(e,t,n,a){e=+e,t|=0,a||b(this,e,t,n,(a=Math.pow(2,8*n-1))-1,-a);var r=0,o=1,i=0;for(this[t]=255&e;++r>0)-i&255;return t+n},d.prototype.writeIntBE=function(e,t,n,a){e=+e,t|=0,a||b(this,e,t,n,(a=Math.pow(2,8*n-1))-1,-a);var r=n-1,o=1,i=0;for(this[t+r]=255&e;0<=--r&&(o*=256);)e<0&&0===i&&0!==this[t+r+1]&&(i=1),this[t+r]=(e/o>>0)-i&255;return t+n},d.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||b(this,e,t,1,127,-128),d.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&(e=e<0?255+e+1:e),t+1},d.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||b(this,e,t,2,32767,-32768),d.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):w(this,e,t,!0),t+2},d.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||b(this,e,t,2,32767,-32768),d.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):w(this,e,t,!1),t+2},d.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||b(this,e,t,4,2147483647,-2147483648),d.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):M(this,e,t,!0),t+4},d.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||b(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),d.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},d.prototype.writeFloatLE=function(e,t,n){return x(this,e,t,!0,n)},d.prototype.writeFloatBE=function(e,t,n){return x(this,e,t,!1,n)},d.prototype.writeDoubleLE=function(e,t,n){return C(this,e,t,!0,n)},d.prototype.writeDoubleBE=function(e,t,n){return C(this,e,t,!1,n)},d.prototype.copy=function(e,t,n,a){if(n=n||0,a||0===a||(a=this.length),t>=e.length&&(t=e.length),(a=0=this.length)throw new RangeError("sourceStart out of bounds");if(a<0)throw new RangeError("sourceEnd out of bounds");a>this.length&&(a=this.length);var r,o=(a=e.length-t>>=0,n=void 0===n?this.length:n>>>0,"number"==typeof(e=e||0))for(s=t;s>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function O(e){return k.toByteArray(function(e){var t;if((e=((t=e).trim?t.trim():t.replace(/^\s+|\s+$/g,"")).replace(T,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function D(e,t,n,a){for(var r=0;r=t.length||r>=e.length);++r)t[r+n]=e[r];return r}}.call(this,P(65))},function(e,t,n){"use strict";var o=n(138);function i(e,t){e.emit("error",t)}e.exports={destroy:function(e,t){var n=this,a=this._readableState&&this._readableState.destroyed,r=this._writableState&&this._writableState.destroyed;return a||r?t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,o.nextTick(i,this,e)):o.nextTick(i,this,e)):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?n._writableState?n._writableState.errorEmitted||(n._writableState.errorEmitted=!0,o.nextTick(i,n,e)):o.nextTick(i,n,e):t&&t(e)})),this},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},function(e,t,n){"use strict";var a=n(139).Buffer,r=a.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"==typeof t||a.isEncoding!==r&&r(e))return t||e;throw new Error("Unknown encoding: "+e)}function i(e){var t;switch(this.encoding=o(e),this.encoding){case"utf16le":this.text=u,this.end=c,t=4;break;case"utf8":this.fillLast=l,t=4;break;case"base64":this.text=d,this.end=f,t=3;break;default:return this.write=p,void(this.end=h)}this.lastNeed=0,this.lastTotal=0,this.lastChar=a.allocUnsafe(t)}function s(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function l(e){var t,n=this.lastTotal-this.lastNeed,a=(t=this,128!=(192&(a=e)[0])?(t.lastNeed=0,"�"):1e.slidesToShow&&(n=e.slideWidth*e.slidesToShow*-1,o=e.slideHeight*e.slidesToShow*-1),e.slideCount%e.slidesToScroll!=0&&(t=e.slideIndex+e.slidesToScroll>e.slideCount&&e.slideCount>e.slidesToShow,t=e.rtl?(e.slideIndex>=e.slideCount?e.slideCount-e.slideIndex:e.slideIndex)+e.slidesToScroll>e.slideCount&&e.slideCount>e.slidesToShow:t)&&(o=e.slideIndex>e.slideCount?(n=(e.slidesToShow-(e.slideIndex-e.slideCount))*e.slideWidth*-1,(e.slidesToShow-(e.slideIndex-e.slideCount))*e.slideHeight*-1):(n=e.slideCount%e.slidesToScroll*e.slideWidth*-1,e.slideCount%e.slidesToScroll*e.slideHeight*-1))):e.slideCount%e.slidesToScroll!=0&&e.slideIndex+e.slidesToScroll>e.slideCount&&e.slideCount>e.slidesToShow&&(n=(e.slidesToShow-e.slideCount%e.slidesToScroll)*e.slideWidth),e.centerMode&&(e.infinite?n+=e.slideWidth*Math.floor(e.slidesToShow/2):n=e.slideWidth*Math.floor(e.slidesToShow/2)),a=e.vertical?e.slideIndex*e.slideHeight*-1+o:e.slideIndex*e.slideWidth*-1+n,!0===e.variableWidth&&(t=void 0,a=(r=e.slideCount<=e.slidesToShow||!1===e.infinite?i.default.findDOMNode(e.trackRef).childNodes[e.slideIndex]:(t=e.slideIndex+e.slidesToShow,i.default.findDOMNode(e.trackRef).childNodes[t]))?-1*r.offsetLeft:0,!0===e.centerMode)&&(r=!1===e.infinite?i.default.findDOMNode(e.trackRef).children[e.slideIndex]:i.default.findDOMNode(e.trackRef).children[e.slideIndex+e.slidesToShow+1])?-1*r.offsetLeft+(e.listWidth-r.offsetWidth)/2:a)}},function(e,t,n){"use strict";t.__esModule=!0;var p=u(n(3)),h=u(n(17)),o=u(n(4)),i=u(n(7)),a=u(n(8)),m=u(n(0)),r=u(n(5)),g=u(n(19)),s=u(n(6)),y=u(n(26)),l=n(11);function u(e){return e&&e.__esModule?e:{default:e}}c=m.default.Component,(0,a.default)(d,c),d.prototype.render=function(){var e=this.props,t=e.title,n=e.children,a=e.className,r=e.isExpanded,o=e.disabled,i=e.style,s=e.prefix,l=e.onClick,u=e.id,e=(0,h.default)(e,["title","children","className","isExpanded","disabled","style","prefix","onClick","id"]),a=(0,g.default)(((c={})[s+"collapse-panel"]=!0,c[s+"collapse-panel-hidden"]=!r,c[s+"collapse-panel-expanded"]=r,c[s+"collapse-panel-disabled"]=o,c[a]=a,c)),c=(0,g.default)(((c={})[s+"collapse-panel-icon"]=!0,c[s+"collapse-panel-icon-expanded"]=r,c)),d=u?u+"-heading":void 0,f=u?u+"-region":void 0;return m.default.createElement("div",(0,p.default)({className:a,style:i,id:u},e),m.default.createElement("div",{id:d,className:s+"collapse-panel-title",onClick:l,onKeyDown:this.onKeyDown,tabIndex:"0","aria-disabled":o,"aria-expanded":r,"aria-controls":f,role:"button"},m.default.createElement(y.default,{type:"arrow-right",className:c,"aria-hidden":"true"}),t),m.default.createElement("div",{className:s+"collapse-panel-content",role:"region",id:f},n))},a=n=d,n.propTypes={prefix:r.default.string,style:r.default.object,children:r.default.any,isExpanded:r.default.bool,disabled:r.default.bool,title:r.default.node,className:r.default.string,onClick:r.default.func,id:r.default.string},n.defaultProps={prefix:"next-",isExpanded:!1,onClick:l.func.noop},n.isNextPanel=!0;var c,r=a;function d(){var e,n;(0,o.default)(this,d);for(var t=arguments.length,a=Array(t),r=0;r\n com.alibaba.nacos\n nacos-client\n ${version}\n \n*/\npackage com.alibaba.nacos.example;\n\nimport java.util.Properties;\nimport java.util.concurrent.Executor;\nimport com.alibaba.nacos.api.NacosFactory;\nimport com.alibaba.nacos.api.config.ConfigService;\nimport com.alibaba.nacos.api.config.listener.Listener;\nimport com.alibaba.nacos.api.exception.NacosException;\n\n/**\n * Config service example\n *\n * @author Nacos\n *\n */\npublic class ConfigExample {\n\n\tpublic static void main(String[] args) throws NacosException, InterruptedException {\n\t\tString serverAddr = "localhost";\n\t\tString dataId = "'.concat(e.dataId,'";\n\t\tString group = "').concat(e.group,'";\n\t\tProperties properties = new Properties();\n\t\tproperties.put(PropertyKeyConst.SERVER_ADDR, serverAddr);\n\t\tConfigService configService = NacosFactory.createConfigService(properties);\n\t\tString content = configService.getConfig(dataId, group, 5000);\n\t\tSystem.out.println(content);\n\t\tconfigService.addListener(dataId, group, new Listener() {\n\t\t\t@Override\n\t\t\tpublic void receiveConfigInfo(String configInfo) {\n\t\t\t\tSystem.out.println("receive:" + configInfo);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic Executor getExecutor() {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t});\n\n\t\tboolean isPublishOk = configService.publishConfig(dataId, group, "content");\n\t\tSystem.out.println(isPublishOk);\n\n\t\tThread.sleep(3000);\n\t\tcontent = configService.getConfig(dataId, group, 5000);\n\t\tSystem.out.println(content);\n\n\t\tboolean isRemoveOk = configService.removeConfig(dataId, group);\n\t\tSystem.out.println(isRemoveOk);\n\t\tThread.sleep(3000);\n\n\t\tcontent = configService.getConfig(dataId, group, 5000);\n\t\tSystem.out.println(content);\n\t\tThread.sleep(300000);\n\n\t}\n}\n')}},{key:"getNodejsCode",value:function(e){return"TODO"}},{key:"getCppCode",value:function(e){return"TODO"}},{key:"getShellCode",value:function(e){return"TODO"}},{key:"getPythonCode",value:function(e){return'/*\n* Demo for Nacos\n*/\nimport json\nimport socket\n\nimport nacos\n\n\ndef get_host_ip():\n res = socket.gethostbyname(socket.gethostname())\n return res\n\n\ndef load_config(content):\n _config = json.loads(content)\n return _config\n\n\ndef nacos_config_callback(args):\n content = args[\'raw_content\']\n load_config(content)\n\n\nclass NacosClient:\n service_name = None\n service_port = None\n service_group = None\n\n def __init__(self, server_endpoint, namespace_id, username=None, password=None):\n self.client = nacos.NacosClient(server_endpoint,\n namespace=namespace_id,\n username=username,\n password=password)\n self.endpoint = server_endpoint\n self.service_ip = get_host_ip()\n\n def register(self):\n self.client.add_naming_instance(self.service_name,\n self.service_ip,\n self.service_port,\n group_name=self.service_group)\n\n def modify(self, service_name, service_ip=None, service_port=None):\n self.client.modify_naming_instance(service_name,\n service_ip if service_ip else self.service_ip,\n service_port if service_port else self.service_port)\n\n def unregister(self):\n self.client.remove_naming_instance(self.service_name,\n self.service_ip,\n self.service_port)\n\n def set_service(self, service_name, service_ip, service_port, service_group):\n self.service_name = service_name\n self.service_ip = service_ip\n self.service_port = service_port\n self.service_group = service_group\n\n async def beat_callback(self):\n self.client.send_heartbeat(self.service_name,\n self.service_ip,\n self.service_port)\n\n def load_conf(self, data_id, group):\n return self.client.get_config(data_id=data_id, group=group, no_snapshot=True)\n\n def add_conf_watcher(self, data_id, group, callback):\n self.client.add_config_watcher(data_id=data_id, group=group, cb=callback)\n\n\nif __name__ == \'__main__\':\n nacos_config = {\n "nacos_data_id":"test",\n "nacos_server_ip":"127.0.0.1",\n "nacos_namespace":"public",\n "nacos_groupName":"DEFAULT_GROUP",\n "nacos_user":"nacos",\n "nacos_password":"1234567"\n }\n nacos_data_id = nacos_config["nacos_data_id"]\n SERVER_ADDRESSES = nacos_config["nacos_server_ip"]\n NAMESPACE = nacos_config["nacos_namespace"]\n groupName = nacos_config["nacos_groupName"]\n user = nacos_config["nacos_user"]\n password = nacos_config["nacos_password"]\n # todo 将另一个路由对象(通常定义在其他模块或文件中)合并到主应用(app)中。\n # app.include_router(custom_api.router, tags=[\'test\'])\n service_ip = get_host_ip()\n client = NacosClient(SERVER_ADDRESSES, NAMESPACE, user, password)\n client.add_conf_watcher(nacos_data_id, groupName, nacos_config_callback)\n\n # 启动时,强制同步一次配置\n data_stream = client.load_conf(nacos_data_id, groupName)\n json_config = load_config(data_stream)\n'}},{key:"getCSharpCode",value:function(e){return'/*\nDemo for Basic Nacos Opreation\nApp.csproj\n\n\n \n\n*/\n\nusing Microsoft.Extensions.DependencyInjection;\nusing Nacos.V2;\nusing Nacos.V2.DependencyInjection;\nusing System;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n string serverAddr = "http://localhost:8848";\n string dataId = "'.concat(e.dataId,'";\n string group = "').concat(e.group,'";\n\n IServiceCollection services = new ServiceCollection();\n\n services.AddNacosV2Config(x =>\n {\n x.ServerAddresses = new List { serverAddr };\n x.Namespace = "cs-test";\n\n // swich to use http or rpc\n x.ConfigUseRpc = true;\n });\n\n IServiceProvider serviceProvider = services.BuildServiceProvider();\n var configSvc = serviceProvider.GetService();\n\n var content = await configSvc.GetConfig(dataId, group, 3000);\n Console.WriteLine(content);\n\n var listener = new ConfigListener();\n\n await configSvc.AddListener(dataId, group, listener);\n\n var isPublishOk = await configSvc.PublishConfig(dataId, group, "content");\n Console.WriteLine(isPublishOk);\n\n await Task.Delay(3000);\n content = await configSvc.GetConfig(dataId, group, 5000);\n Console.WriteLine(content);\n\n var isRemoveOk = await configSvc.RemoveConfig(dataId, group);\n Console.WriteLine(isRemoveOk);\n await Task.Delay(3000);\n\n content = await configSvc.GetConfig(dataId, group, 5000);\n Console.WriteLine(content);\n await Task.Delay(300000);\n }\n\n internal class ConfigListener : IListener\n {\n public void ReceiveConfigInfo(string configInfo)\n {\n Console.WriteLine("receive:" + configInfo);\n }\n }\n}\n\n/*\nRefer to document: https://github.com/nacos-group/nacos-sdk-csharp/tree/dev/samples/MsConfigApp\nDemo for ASP.NET Core Integration\nMsConfigApp.csproj\n\n\n \n\n*/\n\nusing Microsoft.AspNetCore.Hosting;\nusing Microsoft.Extensions.Configuration;\nusing Microsoft.Extensions.Hosting;\nusing Serilog;\nusing Serilog.Events;\n\npublic class Program\n{\n public static void Main(string[] args)\n {\n Log.Logger = new LoggerConfiguration()\n .Enrich.FromLogContext()\n .MinimumLevel.Override("Microsoft", LogEventLevel.Warning)\n .MinimumLevel.Override("System", LogEventLevel.Warning)\n .MinimumLevel.Debug()\n .WriteTo.Console()\n .CreateLogger();\n\n try\n {\n Log.ForContext().Information("Application starting...");\n CreateHostBuilder(args, Log.Logger).Build().Run();\n }\n catch (System.Exception ex)\n {\n Log.ForContext().Fatal(ex, "Application start-up failed!!");\n }\n finally\n {\n Log.CloseAndFlush();\n }\n }\n\n public static IHostBuilder CreateHostBuilder(string[] args, Serilog.ILogger logger) =>\n Host.CreateDefaultBuilder(args)\n .ConfigureAppConfiguration((context, builder) =>\n {\n var c = builder.Build();\n builder.AddNacosV2Configuration(c.GetSection("NacosConfig"), logAction: x => x.AddSerilog(logger));\n })\n .ConfigureWebHostDefaults(webBuilder =>\n {\n webBuilder.UseStartup().UseUrls("http://*:8787");\n })\n .UseSerilog();\n}\n ')}},{key:"openDialog",value:function(e){var t=this;this.setState({dialogvisible:!0}),this.record=e,setTimeout(function(){t.getData()})}},{key:"closeDialog",value:function(){this.setState({dialogvisible:!1})}},{key:"createCodeMirror",value:function(e,t){var n=this.refs.codepreview;n&&(n.innerHTML="",this.cm=window.CodeMirror(n,{value:t,mode:e,height:400,width:500,lineNumbers:!0,theme:"xq-light",lint:!0,tabMode:"indent",autoMatchParens:!0,textWrapping:!0,gutters:["CodeMirror-lint-markers"],extraKeys:{F1:function(e){e.setOption("fullScreen",!e.getOption("fullScreen"))},Esc:function(e){e.getOption("fullScreen")&&e.setOption("fullScreen",!1)}}}))}},{key:"changeTab",value:function(e,t){var n=this;setTimeout(function(){n[e]=!0,n.createCodeMirror("text/javascript",t)})}},{key:"render",value:function(){var e=this.props.locale,e=void 0===e?{}:e;return x.a.createElement("div",null,x.a.createElement(y.a,{title:e.sampleCode,style:{width:"80%"},visible:this.state.dialogvisible,footer:x.a.createElement("div",null),onClose:this.closeDialog.bind(this)},x.a.createElement("div",{style:{height:500}},x.a.createElement(H.a,{tip:e.loading,style:{width:"100%"},visible:this.state.loading},x.a.createElement(L.a,{shape:"text",style:{height:40,paddingBottom:10}},x.a.createElement(O,{title:"Java",key:1,onClick:this.changeTab.bind(this,"commoneditor1",this.defaultCode)}),x.a.createElement(O,{title:"Spring Boot",key:2,onClick:this.changeTab.bind(this,"commoneditor2",this.sprigboot_code)}),x.a.createElement(O,{title:"Spring Cloud",key:21,onClick:this.changeTab.bind(this,"commoneditor21",this.sprigcloud_code)}),x.a.createElement(O,{title:"Node.js",key:3,onClick:this.changeTab.bind(this,"commoneditor3",this.nodejsCode)}),x.a.createElement(O,{title:"C++",key:4,onClick:this.changeTab.bind(this,"commoneditor4",this.cppCode)}),x.a.createElement(O,{title:"Shell",key:5,onClick:this.changeTab.bind(this,"commoneditor5",this.shellCode)}),x.a.createElement(O,{title:"Python",key:6,onClick:this.changeTab.bind(this,"commoneditor6",this.pythonCode)}),x.a.createElement(O,{title:"C#",key:7,onClick:this.changeTab.bind(this,"commoneditor7",this.csharpCode)})),x.a.createElement("div",{ref:"codepreview"})))))}}]),n}(x.a.Component)).displayName="ShowCodeing",k=k))||k,k=(t(69),t(40)),k=t.n(k),z=(t(756),k.a.Row),D=k.a.Col,W=(0,n.a.config)(((k=function(e){Object(M.a)(n,e);var t=Object(S.a)(n);function n(e){return Object(_.a)(this,n),(e=t.call(this,e)).state={visible:!1,title:"",content:"",isok:!0,dataId:"",group:""},e}return Object(b.a)(n,[{key:"componentDidMount",value:function(){this.initData()}},{key:"initData",value:function(){var e=this.props.locale;this.setState({title:(void 0===e?{}:e).confManagement})}},{key:"openDialog",value:function(e){this.setState({visible:!0,title:e.title,content:e.content,isok:e.isok,dataId:e.dataId,group:e.group,message:e.message})}},{key:"closeDialog",value:function(){this.setState({visible:!1})}},{key:"render",value:function(){var e=this.props.locale,e=void 0===e?{}:e,t=x.a.createElement("div",{style:{textAlign:"right"}},x.a.createElement(c.a,{type:"primary",onClick:this.closeDialog.bind(this)},e.determine));return x.a.createElement("div",null,x.a.createElement(y.a,{visible:this.state.visible,footer:t,style:{width:555},onCancel:this.closeDialog.bind(this),onClose:this.closeDialog.bind(this),title:e.deletetitle},x.a.createElement("div",null,x.a.createElement(z,null,x.a.createElement(D,{span:"4",style:{paddingTop:16}},x.a.createElement(m.a,{type:"".concat(this.state.isok?"success":"delete","-filling"),style:{color:this.state.isok?"green":"red"},size:"xl"})),x.a.createElement(D,{span:"20"},x.a.createElement("div",null,x.a.createElement("h3",null,this.state.isok?e.deletedSuccessfully:e.deleteFailed),x.a.createElement("p",null,x.a.createElement("span",{style:{color:"#999",marginRight:5}},"Data ID"),x.a.createElement("span",{style:{color:"#c7254e"}},this.state.dataId)),x.a.createElement("p",null,x.a.createElement("span",{style:{color:"#999",marginRight:5}},"Group"),x.a.createElement("span",{style:{color:"#c7254e"}},this.state.group)),this.state.isok?"":x.a.createElement("p",{style:{color:"red"}},this.state.message)))))))}}]),n}(x.a.Component)).displayName="DeleteDialog",k=k))||k,k=(t(757),t(436)),B=t.n(k),U=(0,n.a.config)(((k=function(e){Object(M.a)(n,e);var t=Object(S.a)(n);function n(){return Object(_.a)(this,n),t.apply(this,arguments)}return Object(b.a)(n,[{key:"render",value:function(){var e=this.props,t=e.data,t=void 0===t?{}:t,n=e.height,e=e.locale,a=void 0===e?{}:e;return x.a.createElement("div",null,"notice"===t.modeType?x.a.createElement("div",{"data-spm-click":"gostr=/aliyun;locaid=notice"},x.a.createElement(B.a,{style:{marginBottom:1\n com.alibaba.nacos\n nacos-client\n ${latest.version}\n \n*/\npackage com.alibaba.nacos.example;\n\nimport java.util.Properties;\n\nimport com.alibaba.nacos.api.exception.NacosException;\nimport com.alibaba.nacos.api.naming.NamingFactory;\nimport com.alibaba.nacos.api.naming.NamingService;\nimport com.alibaba.nacos.api.naming.listener.Event;\nimport com.alibaba.nacos.api.naming.listener.EventListener;\nimport com.alibaba.nacos.api.naming.listener.NamingEvent;\n\n/**\n * @author nkorange\n */\npublic class NamingExample {\n\n public static void main(String[] args) throws NacosException {\n\n Properties properties = new Properties();\n properties.setProperty("serverAddr", System.getProperty("serverAddr"));\n properties.setProperty("namespace", System.getProperty("namespace"));\n\n NamingService naming = NamingFactory.createNamingService(properties);\n\n naming.registerInstance("'.concat(this.record.name,'", "11.11.11.11", 8888, "TEST1");\n\n naming.registerInstance("').concat(this.record.name,'", "2.2.2.2", 9999, "DEFAULT");\n\n System.out.println(naming.getAllInstances("').concat(this.record.name,'"));\n\n naming.deregisterInstance("').concat(this.record.name,'", "2.2.2.2", 9999, "DEFAULT");\n\n System.out.println(naming.getAllInstances("').concat(this.record.name,'"));\n\n naming.subscribe("').concat(this.record.name,'", new EventListener() {\n @Override\n public void onEvent(Event event) {\n System.out.println(((NamingEvent)event).getServiceName());\n System.out.println(((NamingEvent)event).getInstances());\n }\n });\n }\n}')}},{key:"getSpringCode",value:function(e){return'/* Refer to document: https://github.com/nacos-group/nacos-examples/tree/master/nacos-spring-example/nacos-spring-discovery-example\n* pom.xml\n \n com.alibaba.nacos\n nacos-spring-context\n ${latest.version}\n \n*/\n\n// Refer to document: https://github.com/nacos-group/nacos-examples/blob/master/nacos-spring-example/nacos-spring-discovery-example/src/main/java/com/alibaba/nacos/example/spring\npackage com.alibaba.nacos.example.spring;\n\nimport com.alibaba.nacos.api.annotation.NacosProperties;\nimport com.alibaba.nacos.spring.context.annotation.discovery.EnableNacosDiscovery;\nimport org.springframework.context.annotation.Configuration;\n\n@Configuration\n@EnableNacosDiscovery(globalProperties = @NacosProperties(serverAddr = "127.0.0.1:8848"))\npublic class NacosConfiguration {\n\n}\n\n// Refer to document: https://github.com/nacos-group/nacos-examples/tree/master/nacos-spring-example/nacos-spring-discovery-example/src/main/java/com/alibaba/nacos/example/spring/controller\npackage com.alibaba.nacos.example.spring.controller;\n\nimport com.alibaba.nacos.api.annotation.NacosInjected;\nimport com.alibaba.nacos.api.exception.NacosException;\nimport com.alibaba.nacos.api.naming.NamingService;\nimport com.alibaba.nacos.api.naming.pojo.Instance;\nimport org.springframework.stereotype.Controller;\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RequestParam;\nimport org.springframework.web.bind.annotation.ResponseBody;\n\nimport java.util.List;\n\nimport static org.springframework.web.bind.annotation.RequestMethod.GET;\n\n@Controller\n@RequestMapping("discovery")\npublic class DiscoveryController {\n\n @NacosInjected\n private NamingService namingService;\n\n @RequestMapping(value = "/get", method = GET)\n @ResponseBody\n public List get(@RequestParam String serviceName) throws NacosException {\n return namingService.getAllInstances(serviceName);\n }\n}'}},{key:"getSpringBootCode",value:function(e){return'/* Refer to document: https://github.com/nacos-group/nacos-examples/blob/master/nacos-spring-boot-example/nacos-spring-boot-discovery-example\n* pom.xml\n \n com.alibaba.boot\n nacos-discovery-spring-boot-starter\n ${latest.version}\n \n*/\n/* Refer to document: https://github.com/nacos-group/nacos-examples/blob/master/nacos-spring-boot-example/nacos-spring-boot-discovery-example/src/main/resources\n* application.properties\n nacos.discovery.server-addr=127.0.0.1:8848\n*/\n// Refer to document: https://github.com/nacos-group/nacos-examples/blob/master/nacos-spring-boot-example/nacos-spring-boot-discovery-example/src/main/java/com/alibaba/nacos/example/spring/boot/controller\n\npackage com.alibaba.nacos.example.spring.boot.controller;\n\nimport com.alibaba.nacos.api.annotation.NacosInjected;\nimport com.alibaba.nacos.api.exception.NacosException;\nimport com.alibaba.nacos.api.naming.NamingService;\nimport com.alibaba.nacos.api.naming.pojo.Instance;\nimport org.springframework.stereotype.Controller;\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RequestParam;\nimport org.springframework.web.bind.annotation.ResponseBody;\n\nimport java.util.List;\n\nimport static org.springframework.web.bind.annotation.RequestMethod.GET;\n\n@Controller\n@RequestMapping("discovery")\npublic class DiscoveryController {\n\n @NacosInjected\n private NamingService namingService;\n\n @RequestMapping(value = "/get", method = GET)\n @ResponseBody\n public List get(@RequestParam String serviceName) throws NacosException {\n return namingService.getAllInstances(serviceName);\n }\n}'}},{key:"getSpringCloudCode",value:function(e){return"/* Refer to document: https://github.com/nacos-group/nacos-examples/blob/master/nacos-spring-cloud-example/nacos-spring-cloud-discovery-example/\n* pom.xml\n \n org.springframework.cloud\n spring-cloud-starter-alibaba-nacos-discovery\n ${latest.version}\n \n*/\n\n// nacos-spring-cloud-provider-example\n\n/* Refer to document: https://github.com/nacos-group/nacos-examples/tree/master/nacos-spring-cloud-example/nacos-spring-cloud-discovery-example/nacos-spring-cloud-provider-example/src/main/resources\n* application.properties\nserver.port=18080\nspring.application.name=".concat(this.record.name,'\nspring.cloud.nacos.discovery.server-addr=127.0.0.1:8848\n*/\n\n// Refer to document: https://github.com/nacos-group/nacos-examples/tree/master/nacos-spring-cloud-example/nacos-spring-cloud-discovery-example/nacos-spring-cloud-provider-example/src/main/java/com/alibaba/nacos/example/spring/cloud\npackage com.alibaba.nacos.example.spring.cloud;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\nimport org.springframework.cloud.client.discovery.EnableDiscoveryClient;\nimport org.springframework.web.bind.annotation.PathVariable;\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RequestMethod;\nimport org.springframework.web.bind.annotation.RestController;\n\n/**\n * @author xiaojing\n */\n@SpringBootApplication\n@EnableDiscoveryClient\npublic class NacosProviderApplication {\n\n public static void main(String[] args) {\n SpringApplication.run(NacosProviderApplication.class, args);\n}\n\n @RestController\n class EchoController {\n @RequestMapping(value = "/echo/{string}", method = RequestMethod.GET)\n public String echo(@PathVariable String string) {\n return "Hello Nacos Discovery " + string;\n }\n }\n}\n\n// nacos-spring-cloud-consumer-example\n\n/* Refer to document: https://github.com/nacos-group/nacos-examples/tree/master/nacos-spring-cloud-example/nacos-spring-cloud-discovery-example/nacos-spring-cloud-consumer-example/src/main/resources\n* application.properties\nspring.application.name=micro-service-oauth2\nspring.cloud.nacos.discovery.server-addr=127.0.0.1:8848\n*/\n\n// Refer to document: https://github.com/nacos-group/nacos-examples/tree/master/nacos-spring-cloud-example/nacos-spring-cloud-discovery-example/nacos-spring-cloud-consumer-example/src/main/java/com/alibaba/nacos/example/spring/cloud\npackage com.alibaba.nacos.example.spring.cloud;\n\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\nimport org.springframework.cloud.client.discovery.EnableDiscoveryClient;\nimport org.springframework.cloud.client.loadbalancer.LoadBalanced;\nimport org.springframework.context.annotation.Bean;\nimport org.springframework.web.bind.annotation.PathVariable;\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RequestMethod;\nimport org.springframework.web.bind.annotation.RestController;\nimport org.springframework.web.client.RestTemplate;\n\n/**\n * @author xiaojing\n */\n@SpringBootApplication\n@EnableDiscoveryClient\npublic class NacosConsumerApplication {\n\n @LoadBalanced\n @Bean\n public RestTemplate restTemplate() {\n return new RestTemplate();\n }\n\n public static void main(String[] args) {\n SpringApplication.run(NacosConsumerApplication.class, args);\n }\n\n @RestController\n public class TestController {\n\n private final RestTemplate restTemplate;\n\n @Autowired\n public TestController(RestTemplate restTemplate) {this.restTemplate = restTemplate;}\n\n @RequestMapping(value = "/echo/{str}", method = RequestMethod.GET)\n public String echo(@PathVariable String str) {\n return restTemplate.getForObject("http://service-provider/echo/" + str, String.class);\n }\n }\n}')}},{key:"getNodejsCode",value:function(e){return"TODO"}},{key:"getCppCode",value:function(e){return"TODO"}},{key:"getShellCode",value:function(e){return"TODO"}},{key:"getPythonCode",value:function(e){return'/*\n* Demo for Nacos\n*/\nimport json\nimport socket\n\nimport nacos\n\n\ndef get_host_ip():\n res = socket.gethostbyname(socket.gethostname())\n return res\n\n\ndef load_config(content):\n _config = json.loads(content)\n return _config\n\n\ndef nacos_config_callback(args):\n content = args[\'raw_content\']\n load_config(content)\n\n\nclass NacosClient:\n service_name = None\n service_port = None\n service_group = None\n\n def __init__(self, server_endpoint, namespace_id, username=None, password=None):\n self.client = nacos.NacosClient(server_endpoint,\n namespace=namespace_id,\n username=username,\n password=password)\n self.endpoint = server_endpoint\n self.service_ip = get_host_ip()\n\n def register(self):\n self.client.add_naming_instance(self.service_name,\n self.service_ip,\n self.service_port,\n group_name=self.service_group)\n\n def modify(self, service_name, service_ip=None, service_port=None):\n self.client.modify_naming_instance(service_name,\n service_ip if service_ip else self.service_ip,\n service_port if service_port else self.service_port)\n\n def unregister(self):\n self.client.remove_naming_instance(self.service_name,\n self.service_ip,\n self.service_port)\n\n def set_service(self, service_name, service_ip, service_port, service_group):\n self.service_name = service_name\n self.service_ip = service_ip\n self.service_port = service_port\n self.service_group = service_group\n\n async def beat_callback(self):\n self.client.send_heartbeat(self.service_name,\n self.service_ip,\n self.service_port)\n\n def load_conf(self, data_id, group):\n return self.client.get_config(data_id=data_id, group=group, no_snapshot=True)\n\n def add_conf_watcher(self, data_id, group, callback):\n self.client.add_config_watcher(data_id=data_id, group=group, cb=callback)\n\n\nif __name__ == \'__main__\':\n nacos_config = {\n "nacos_data_id":"test",\n "nacos_server_ip":"127.0.0.1",\n "nacos_namespace":"public",\n "nacos_groupName":"DEFAULT_GROUP",\n "nacos_user":"nacos",\n "nacos_password":"1234567"\n }\n nacos_data_id = nacos_config["nacos_data_id"]\n SERVER_ADDRESSES = nacos_config["nacos_server_ip"]\n NAMESPACE = nacos_config["nacos_namespace"]\n groupName = nacos_config["nacos_groupName"]\n user = nacos_config["nacos_user"]\n password = nacos_config["nacos_password"]\n # todo 将另一个路由对象(通常定义在其他模块或文件中)合并到主应用(app)中。\n # app.include_router(custom_api.router, tags=[\'test\'])\n service_ip = get_host_ip()\n client = NacosClient(SERVER_ADDRESSES, NAMESPACE, user, password)\n client.add_conf_watcher(nacos_data_id, groupName, nacos_config_callback)\n\n # 启动时,强制同步一次配置\n data_stream = client.load_conf(nacos_data_id, groupName)\n json_config = load_config(data_stream)\n #设定服务\n client.set_service(json_config["service_name"], json_config.get("service_ip", service_ip), service_port, groupName)\n #注册服务\n client.register()\n #下线服务\n client.unregister()\n'}},{key:"getCSharpCode",value:function(e){return'/* Refer to document: https://github.com/nacos-group/nacos-sdk-csharp/\nDemo for Basic Nacos Opreation\nApp.csproj\n\n\n \n\n*/\n\nusing Microsoft.Extensions.DependencyInjection;\nusing Nacos.V2;\nusing Nacos.V2.DependencyInjection;\nusing System;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n IServiceCollection services = new ServiceCollection();\n\n services.AddNacosV2Naming(x =>\n {\n x.ServerAddresses = new List { "http://localhost:8848/" };\n x.Namespace = "cs-test";\n\n // swich to use http or rpc\n x.NamingUseRpc = true;\n });\n\n IServiceProvider serviceProvider = services.BuildServiceProvider();\n var namingSvc = serviceProvider.GetService();\n\n await namingSvc.RegisterInstance("'.concat(this.record.name,'", "11.11.11.11", 8888, "TEST1");\n\n await namingSvc.RegisterInstance("').concat(this.record.name,'", "2.2.2.2", 9999, "DEFAULT");\n\n Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(await namingSvc.GetAllInstances("').concat(this.record.name,'")));\n\n await namingSvc.DeregisterInstance("').concat(this.record.name,'", "2.2.2.2", 9999, "DEFAULT");\n\n var listener = new EventListener();\n\n await namingSvc.Subscribe("').concat(this.record.name,'", listener);\n }\n\n internal class EventListener : IEventListener\n {\n public Task OnEvent(IEvent @event)\n {\n Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(@event));\n return Task.CompletedTask;\n }\n }\n}\n\n/* Refer to document: https://github.com/nacos-group/nacos-sdk-csharp/\nDemo for ASP.NET Core Integration\nApp.csproj\n\n\n \n\n*/\n\n/* Refer to document: https://github.com/nacos-group/nacos-sdk-csharp/blob/dev/samples/App1/appsettings.json\n* appsettings.json\n{\n "nacos": {\n "ServerAddresses": [ "http://localhost:8848" ],\n "DefaultTimeOut": 15000,\n "Namespace": "cs",\n "ServiceName": "App1",\n "GroupName": "DEFAULT_GROUP",\n "ClusterName": "DEFAULT",\n "Port": 0,\n "Weight": 100,\n "RegisterEnabled": true,\n "InstanceEnabled": true,\n "Ephemeral": true,\n "NamingUseRpc": true,\n "NamingLoadCacheAtStart": ""\n }\n}\n*/\n\n// Refer to document: https://github.com/nacos-group/nacos-sdk-csharp/blob/dev/samples/App1/Startup.cs\nusing Nacos.AspNetCore.V2;\n\npublic class Startup\n{\n public Startup(IConfiguration configuration)\n {\n Configuration = configuration;\n }\n\n public IConfiguration Configuration { get; }\n\n public void ConfigureServices(IServiceCollection services)\n {\n // ....\n services.AddNacosAspNet(Configuration);\n }\n\n public void Configure(IApplicationBuilder app, IWebHostEnvironment env)\n {\n // ....\n }\n}\n ')}},{key:"openDialog",value:function(e){var t=this;this.setState({dialogvisible:!0}),this.record=e,setTimeout(function(){t.getData()})}},{key:"closeDialog",value:function(){this.setState({dialogvisible:!1})}},{key:"createCodeMirror",value:function(e,t){var n=this.refs.codepreview;n&&(n.innerHTML="",this.cm=window.CodeMirror(n,{value:t,mode:e,height:400,width:500,lineNumbers:!0,theme:"xq-light",lint:!0,tabMode:"indent",autoMatchParens:!0,textWrapping:!0,gutters:["CodeMirror-lint-markers"],extraKeys:{F1:function(e){e.setOption("fullScreen",!e.getOption("fullScreen"))},Esc:function(e){e.getOption("fullScreen")&&e.setOption("fullScreen",!1)}}}),this.cm.setSize("auto","490px"))}},{key:"changeTab",value:function(e,t){var n=this;setTimeout(function(){n[e]=!0,n.createCodeMirror("text/javascript",t)})}},{key:"render",value:function(){var e=this.props.locale,e=void 0===e?{}:e;return O.a.createElement("div",null,O.a.createElement(o.a,{title:e.sampleCode,style:{width:"80%"},visible:this.state.dialogvisible,footer:O.a.createElement("div",null),onClose:this.closeDialog.bind(this)},O.a.createElement("div",{style:{height:500}},O.a.createElement(h.a,{tip:e.loading,style:{width:"100%"},visible:this.state.loading},O.a.createElement(m.a,{shape:"text",style:{height:40,paddingBottom:10}},O.a.createElement(g,{title:"Java",key:0,onClick:this.changeTab.bind(this,"commoneditor1",this.defaultCode)}),O.a.createElement(g,{title:"Spring",key:1,onClick:this.changeTab.bind(this,"commoneditor1",this.springCode)}),O.a.createElement(g,{title:"Spring Boot",key:2,onClick:this.changeTab.bind(this,"commoneditor2",this.sprigbootCode)}),O.a.createElement(g,{title:"Spring Cloud",key:21,onClick:this.changeTab.bind(this,"commoneditor21",this.sprigcloudCode)}),O.a.createElement(g,{title:"Node.js",key:3,onClick:this.changeTab.bind(this,"commoneditor3",this.nodejsCode)}),O.a.createElement(g,{title:"C++",key:4,onClick:this.changeTab.bind(this,"commoneditor4",this.cppCode)}),O.a.createElement(g,{title:"Shell",key:5,onClick:this.changeTab.bind(this,"commoneditor5",this.shellCode)}),O.a.createElement(g,{title:"Python",key:6,onClick:this.changeTab.bind(this,"commoneditor6",this.pythonCode)}),O.a.createElement(g,{title:"C#",key:7,onClick:this.changeTab.bind(this,"commoneditor7",this.csharpCode)})),O.a.createElement("div",{ref:"codepreview"})))))}}]),n}(O.a.Component)).displayName="ShowServiceCodeing",f=f))||f,Y=t(51),I=t(146),A=(t(778),t(22)),R=L.a.Item,H=d.a.Row,F=d.a.Col,z=T.a.Column,d=(0,n.a.config)(((f=function(e){Object(u.a)(n,e);var t=Object(c.a)(n);function n(e){var a;return Object(s.a)(this,n),(a=t.call(this,e)).getQueryLater=function(){setTimeout(function(){return a.queryServiceList()})},a.showcode=function(){setTimeout(function(){return a.queryServiceList()})},a.setNowNameSpace=function(e,t,n){return a.setState({nowNamespaceName:e,nowNamespaceId:t,nowNamespaceDesc:n})},a.rowColor=function(e){return{className:e.healthyInstanceCount?"":"row-bg-red"}},a.editServiceDialog=O.a.createRef(),a.showcode=O.a.createRef(),a.state={loading:!1,total:0,pageSize:10,currentPage:1,dataSource:[],search:{serviceName:Object(p.b)("serviceNameParam")||"",groupName:Object(p.b)("groupNameParam")||""},ignoreEmptyService:!("false"===localStorage.getItem("ignoreEmptyService"))},a.field=new i.a(Object(l.a)(a)),a}return Object(a.a)(n,[{key:"openLoading",value:function(){this.setState({loading:!0})}},{key:"closeLoading",value:function(){this.setState({loading:!1})}},{key:"openEditServiceDialog",value:function(){try{this.editServiceDialog.current.getInstance().show(this.state.service)}catch(e){}}},{key:"queryServiceList",value:function(){var n=this,e=this.state,t=e.currentPage,a=e.pageSize,r=e.search,o=e.withInstances,o=void 0!==o&&o,e=e.ignoreEmptyService,e=["ignoreEmptyService=".concat(e),"withInstances=".concat(o),"pageNo=".concat(t),"pageSize=".concat(a),"serviceNameParam=".concat(r.serviceName),"groupNameParam=".concat(r.groupName)];Object(p.f)({serviceNameParam:r.serviceName,groupNameParam:r.groupName}),this.openLoading(),Object(p.e)({url:"v3/console/ns/service/list?".concat(e.join("&")),success:function(e){var e=e.data,e=void 0===e?{}:e,t=e.count,e=e.serviceList;n.setState({dataSource:void 0===e?[]:e,total:void 0===t?0:t,loading:!1})},error:function(){return n.setState({dataSource:[],total:0,currentPage:0,loading:!1})}})}},{key:"showSampleCode",value:function(e){this.showcode.current.getInstance().openDialog(e)}},{key:"querySubscriber",value:function(e){var t=e.name,e=e.groupName,n=this.state.nowNamespaceId;this.props.history.push(Object(D.a)("/subscriberList",{namespace:n,name:t,groupName:e}))}},{key:"handlePageSizeChange",value:function(e){var t=this;this.setState({pageSize:e},function(){return t.queryServiceList()})}},{key:"deleteService",value:function(e){var t=this,n=this.props.locale,n=void 0===n?{}:n,a=n.prompt,n=n.promptDelete;o.a.confirm({title:a,content:n,onOk:function(){Object(p.e)({method:"DELETE",url:"v3/console/ns/service?serviceName=".concat(e.name,"&groupName=").concat(e.groupName),dataType:"json",beforeSend:function(){return t.openLoading()},success:function(e){0!==e.code?r.a.error(e.message||"删除服务失败"):(r.a.success("服务删除成功"),t.queryServiceList())},error:function(e){var t;r.a.error((null==(t=e.data)?void 0:t.responseText)||e.statusText||"请求失败")},complete:function(){return t.closeLoading()}})}})}},{key:"render",value:function(){var a=this,e=this.props.locale,t=void 0===e?{}:e,e=t.pubNoData,n=t.serviceList,r=t.serviceName,o=t.serviceNamePlaceholder,i=t.groupName,s=t.groupNamePlaceholder,l=t.hiddenEmptyService,u=t.query,c=t.create,d=t.operation,f=t.detail,p=t.sampleCode,h=t.deleteAction,m=t.subscriber,g=this.state,y=g.search,v=g.nowNamespaceName,_=g.nowNamespaceId,b=g.nowNamespaceDesc,g=g.ignoreEmptyService,w=this.field,M=w.init,w=w.getValue;return this.init=M,this.getValue=w,O.a.createElement("div",{className:"main-container service-management"},O.a.createElement(Y.a,{title:n,desc:b,namespaceId:_,namespaceName:v,nameSpace:!0}),O.a.createElement(N.a,{setNowNameSpace:this.setNowNameSpace,namespaceCallBack:this.getQueryLater}),O.a.createElement(H,{className:"demo-row",style:{marginBottom:10,padding:0}},O.a.createElement(F,{span:"24"},O.a.createElement(L.a,{inline:!0,field:this.field},O.a.createElement(R,{label:""},O.a.createElement(C.a,{type:"primary",onClick:function(){return a.openEditServiceDialog()}},c)),O.a.createElement(R,{label:r},O.a.createElement(E.a,{placeholder:o,style:{width:200},value:y.serviceName,onChange:function(e){return a.setState({search:Object(x.a)(Object(x.a)({},y),{},{serviceName:e})})},onPressEnter:function(){return a.setState({currentPage:1},function(){return a.queryServiceList()})}})),O.a.createElement(R,{label:i},O.a.createElement(E.a,{placeholder:s,style:{width:200},value:y.groupName,onChange:function(e){return a.setState({search:Object(x.a)(Object(x.a)({},y),{},{groupName:e})})},onPressEnter:function(){return a.setState({currentPage:1},function(){return a.queryServiceList()})}})),O.a.createElement(L.a.Item,{label:"".concat(l)},O.a.createElement(k.a,{checked:g,onChange:function(e){return a.setState({ignoreEmptyService:e,currentPage:1},function(){localStorage.setItem("ignoreEmptyService",e),a.queryServiceList()})}})),O.a.createElement(R,{label:""},O.a.createElement(C.a,{type:"primary",onClick:function(){return a.setState({currentPage:1},function(){return a.queryServiceList()})},style:{marginRight:10}},u))))),O.a.createElement(H,{style:{padding:0}},O.a.createElement(F,{span:"24",style:{padding:0}},O.a.createElement(T.a,{dataSource:this.state.dataSource,locale:{empty:e},rowProps:function(e){return a.rowColor(e)},loading:this.state.loading},O.a.createElement(z,{title:t.columnServiceName,dataIndex:"name"}),O.a.createElement(z,{title:t.groupName,dataIndex:"groupName"}),O.a.createElement(z,{title:t.columnClusterCount,dataIndex:"clusterCount"}),O.a.createElement(z,{title:t.columnIpCount,dataIndex:"ipCount"}),O.a.createElement(z,{title:t.columnHealthyInstanceCount,dataIndex:"healthyInstanceCount"}),O.a.createElement(z,{title:t.columnTriggerFlag,dataIndex:"triggerFlag"}),O.a.createElement(z,{title:d,align:"center",cell:function(e,t,n){return O.a.createElement("div",null,O.a.createElement("a",{onClick:function(){var e=n.name,t=n.groupName;a.props.history.push(Object(D.a)("/serviceDetail",{name:e,groupName:t}))},style:{marginRight:5}},f),O.a.createElement("span",{style:{marginRight:5}},"|"),O.a.createElement("a",{style:{marginRight:5},onClick:function(){return a.showSampleCode(n)}},p),O.a.createElement("span",{style:{marginRight:5}},"|"),O.a.createElement("a",{style:{marginRight:5},onClick:function(){return a.querySubscriber(n)}},m),O.a.createElement("span",{style:{marginRight:5}},"|"),O.a.createElement("a",{onClick:function(){return a.deleteService(n)},style:{marginRight:5}},h))}})))),O.a.createElement("div",{style:{marginTop:10,textAlign:"right"}},O.a.createElement(S.a,{current:this.state.currentPage,pageSizeList:A.f,pageSizePosition:"start",pageSizeSelector:"dropdown",popupProps:{align:"bl tl"},total:this.state.total,pageSize:this.state.pageSize,totalRender:function(e){return O.a.createElement(I.a,{locale:t,total:e})},onPageSizeChange:function(e){return a.handlePageSizeChange(e)},onChange:function(e){return a.setState({currentPage:e},function(){return a.queryServiceList()})}})),O.a.createElement(j,{ref:this.showcode}),O.a.createElement(P.a,{ref:this.editServiceDialog,openLoading:function(){return a.openLoading()},closeLoading:function(){return a.closeLoading()},queryServiceList:function(){return a.setState({currentPage:1},function(){return a.queryServiceList()})}}))}}]),n}(O.a.Component)).displayName="ServiceList",t=f))||t;e.a=d},function(e,t,n){"use strict";n(67);var a=n(47),u=n.n(a),a=(n(35),n(18)),c=n.n(a),a=(n(66),n(21)),d=n.n(a),a=(n(34),n(20)),f=n.n(a),a=(n(93),n(55)),p=n.n(a),a=(n(38),n(2)),h=n.n(a),a=(n(37),n(10)),m=n.n(a),i=n(13),s=n(14),l=n(23),g=n(16),y=n(15),a=(n(27),n(6)),a=n.n(a),r=n(0),v=n.n(r),r=n(30),_=n(45),b=n(53),w=n(32),o=(n(49),n(28)),M=n.n(o),S=(n(168),h.a.Item),k={labelCol:{fixedSpan:4},wrapperCol:{span:19}},E=(0,a.a.config)(((o=function(e){Object(g.a)(o,e);var r=Object(y.a)(o);function o(){var e;Object(i.a)(this,o);for(var t=arguments.length,n=new Array(t),a=0;ao&&v.a.createElement(u.a,{className:"users-pagination",current:i,total:n.totalCount,pageSize:o,onChange:function(e){return t.setState({pageNo:e},function(){return t.getUsers()})}}),v.a.createElement(E,{visible:s,onOk:function(e){return Object(_.d)(e).then(function(e){return t.setState({pageNo:1},function(){return t.getUsers()}),e})},onCancel:function(){return t.colseCreateUser()}}),v.a.createElement(x.a,{visible:l,username:e,onOk:function(e){return Object(_.l)(e).then(function(e){return t.getUsers(),e})},onCancel:function(){return t.setState({passwordResetUser:void 0,passwordResetUserVisible:!1})}}))}}]),n}(v.a.Component)).displayName="UserManagement",n=o))||n)||n;t.a=r},function(e,t,n){"use strict";n(46);var a=n(24),l=n.n(a),a=(n(67),n(47)),u=n.n(a),a=(n(35),n(18)),c=n.n(a),d=n(32),a=(n(66),n(21)),f=n.n(a),a=(n(34),n(20)),p=n.n(a),a=(n(93),n(55)),h=n.n(a),a=(n(38),n(2)),m=n.n(a),a=(n(37),n(10)),g=n.n(a),i=n(13),s=n(14),y=n(23),v=n(16),_=n(15),a=(n(27),n(6)),a=n.n(a),r=n(0),b=n.n(r),r=n(30),w=n(45),o=n(86),M=n(53),S=(n(49),n(28)),k=n.n(S),S=(n(59),n(29)),E=n.n(S),x=m.a.Item,C=E.a.Option,T={labelCol:{fixedSpan:4},wrapperCol:{span:19}},L=Object(r.b)(function(e){return{namespaces:e.namespace.namespaces}},{getNamespaces:o.b,searchRoles:w.m})(S=(0,a.a.config)(((S=function(e){Object(v.a)(o,e);var r=Object(_.a)(o);function o(){var t;Object(i.a)(this,o);for(var e=arguments.length,n=new Array(e),a=0;ai&&b.a.createElement(u.a,{className:"users-pagination",current:s,total:t.totalCount,pageSize:i,onChange:function(e){return a.setState({pageNo:e},function(){return a.getPermissions()})}}),b.a.createElement(L,{visible:n,onOk:function(t){return Object(w.a)(t).then(function(e){e?l.a.error({content:o.checkPermission}):Object(w.b)(t).then(function(e){return a.setState({pageNo:1},function(){return a.getPermissions()}),e})})},onCancel:function(){return a.colseCreatePermission()}}))}}]),n}(b.a.Component)).displayName="PermissionsManagement",n=S))||n)||n);t.a=r},function(e,t,n){"use strict";n(67);var a=n(47),l=n.n(a),a=(n(35),n(18)),u=n.n(a),a=(n(66),n(21)),c=n.n(a),a=(n(34),n(20)),d=n.n(a),a=(n(93),n(55)),f=n.n(a),a=(n(38),n(2)),p=n.n(a),a=(n(37),n(10)),h=n.n(a),i=n(13),s=n(14),m=n(23),g=n(16),y=n(15),a=(n(27),n(6)),a=n.n(a),r=n(0),v=n.n(r),r=n(30),_=n(45),b=n(53),o=(n(59),n(29)),w=n.n(o),o=(n(49),n(28)),M=n.n(o),S=p.a.Item,k={labelCol:{fixedSpan:4},wrapperCol:{span:19}},E=Object(r.b)(function(e){return{users:e.authority.users}},{searchUsers:_.n})(o=(0,a.a.config)(((o=function(e){Object(g.a)(o,e);var r=Object(y.a)(o);function o(){var t;Object(i.a)(this,o);for(var e=arguments.length,n=new Array(e),a=0;ao&&v.a.createElement(l.a,{className:"users-pagination",current:i,total:t.totalCount,pageSize:o,onChange:function(e){return a.setState({pageNo:e},function(){return a.getRoles()})}}),v.a.createElement(E,{visible:s,onOk:function(e){return Object(_.c)(e).then(function(e){return a.getRoles(),e})},onCancel:function(){return a.colseCreateRole()}}))}}]),n}(v.a.Component)).displayName="RolesManagement",n=o))||n)||n);t.a=r},function(e,t,n){"use strict";n(35);function l(e){var t=void 0===(t=localStorage.token)?"{}":t,t=(Object(_.c)(t)&&JSON.parse(t)||{}).globalAdmin,n=[];return"naming"===e?n.push(b):"config"===e?n.push(w):n.push(w,b),t&&n.push(M),n.push(S),n.push(k),n.push(E),n.filter(function(e){return e})}var a=n(18),u=n.n(a),a=(n(46),n(24)),c=n.n(a),a=(n(43),n(26)),d=n.n(a),r=n(13),o=n(14),i=n(16),s=n(15),a=(n(27),n(6)),a=n.n(a),f=n(12),p=(n(84),n(50)),h=n.n(p),p=n(0),m=n.n(p),p=n(39),g=n(30),y=n(108),v=n(52),_=n(48),b={key:"serviceManagementVirtual",children:[{key:"serviceManagement",url:"/serviceManagement"},{key:"subscriberList",url:"/subscriberList"}]},w={key:"configurationManagementVirtual",children:[{key:"configurationManagement",url:"/configurationManagement"},{key:"historyRollback",url:"/historyRollback"},{key:"listeningToQuery",url:"/listeningToQuery"}]},M={key:"authorityControl",children:[{key:"userList",url:"/userManagement"},{key:"roleManagement",url:"/rolesManagement"},{key:"privilegeManagement",url:"/permissionsManagement"}]},S={key:"namespace",url:"/namespace"},k={key:"clusterManagementVirtual",children:[{key:"clusterManagement",url:"/clusterManagement"}]},E={key:"settingCenter",url:"/settingCenter"},x=(n(386),h.a.SubMenu),C=h.a.Item,p=(n=Object(g.b)(function(e){return Object(f.a)(Object(f.a)({},e.locale),e.base)},{getState:v.e,getNotice:v.d,getGuide:v.c}),g=a.a.config,Object(p.g)(a=n(a=g(((v=function(e){Object(i.a)(n,e);var t=Object(s.a)(n);function n(e){return Object(r.a)(this,n),(e=t.call(this,e)).state={visible:!0},e}return Object(o.a)(n,[{key:"componentDidMount",value:function(){this.props.getState(),this.props.getNotice(),this.props.getGuide()}},{key:"goBack",value:function(){this.props.history.goBack()}},{key:"navTo",value:function(e){var t=this.props.location.search,t=new URLSearchParams(t);t.set("namespace",window.nownamespace),t.set("namespaceShowName",window.namespaceShowName),this.props.history.push([e,"?",t.toString()].join(""))}},{key:"isCurrentPath",value:function(e){return e===this.props.location.pathname?"current-path next-selected":void 0}},{key:"defaultOpenKeys",value:function(){for(var t=this,e=l(this.props.functionMode),n=0,a=e.length;nthis.state.pageSize&&k.a.createElement("div",{style:{marginTop:10,textAlign:"right"}},k.a.createElement(v.a,{current:this.state.pageNo,total:a,pageSize:this.state.pageSize,onChange:function(e){return t.setState({pageNo:e},function(){return t.querySubscriberList()})}}))))}}]),n}(k.a.Component)).displayName="SubscriberList",d=n))||d)||d;t.a=f},function(e,t,n){"use strict";n(54);var a=n(36),c=n.n(a),a=(n(67),n(47)),d=n.n(a),a=(n(179),n(78)),f=n.n(a),a=(n(37),n(10)),p=n.n(a),a=(n(34),n(20)),h=n.n(a),a=(n(35),n(18)),r=n.n(a),a=(n(46),n(24)),o=n.n(a),a=(n(49),n(28)),i=n.n(a),s=n(13),l=n(14),u=n(23),m=n(16),g=n(15),a=(n(27),n(6)),a=n.n(a),y=(n(421),n(123)),v=n.n(y),y=(n(66),n(21)),_=n.n(y),y=(n(69),n(40)),y=n.n(y),b=(n(38),n(2)),w=n.n(b),b=n(0),M=n.n(b),S=n(1),b=n(144),k=n.n(b),E=n(51),x=(n(781),w.a.Item),C=y.a.Row,T=y.a.Col,L=_.a.Column,O=v.a.Panel,y=(0,a.a.config)(((b=function(e){Object(m.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(s.a)(this,a),(n=t.call(this,e)).getQueryLater=function(){setTimeout(function(){return n.queryClusterStateList()})},n.setNowNameSpace=function(e,t){return n.setState({nowNamespaceName:e,nowNamespaceId:t})},n.rowColor=function(e){return{className:(e.voteFor,"")}},n.state={loading:!1,total:0,pageSize:10,currentPage:1,keyword:"",dataSource:[]},n.field=new i.a(Object(u.a)(n)),n}return Object(l.a)(a,[{key:"componentDidMount",value:function(){this.getQueryLater()}},{key:"openLoading",value:function(){this.setState({loading:!0})}},{key:"closeLoading",value:function(){this.setState({loading:!1})}},{key:"queryClusterStateList",value:function(){var n=this,e=this.state,t=e.currentPage,a=e.pageSize,r=e.keyword,e=e.withInstances,e=["withInstances=".concat(void 0!==e&&e),"pageNo=".concat(t),"pageSize=".concat(a),"keyword=".concat(r)];Object(S.e)({url:"v3/console/core/cluster/nodes?".concat(e.join("&")),beforeSend:function(){return n.openLoading()},success:function(){var e=0this.state.pageSize&&M.a.createElement("div",{style:{marginTop:10,textAlign:"right"}},M.a.createElement(d.a,{current:this.state.currentPage,total:this.state.total,pageSize:this.state.pageSize,onChange:function(e){return t.setState({currentPage:e},function(){return t.queryClusterStateList()})}}))))}}]),a}(M.a.Component)).displayName="ClusterNodeList",n=b))||n;t.a=y},function(e,t,n){"use strict";n(34);var a=n(20),i=n.n(a),s=n(13),l=n(14),u=n(16),c=n(15),a=(n(27),n(6)),a=n.n(a),r=n(12),o=(n(114),n(75)),o=n.n(o),d=n(0),f=n.n(d),p=(n(784),n(51)),d=n(87),h=n(148),m=n(149),g=n(30),y=n(22),v=o.a.Group,g=Object(g.b)(function(e){return Object(r.a)({},e.locale)},{changeLanguage:d.a,changeTheme:h.a,changeNameShow:m.a})(o=(0,a.a.config)(((n=function(e){Object(u.a)(o,e);var r=Object(c.a)(o);function o(e){Object(s.a)(this,o),e=r.call(this,e);var t=localStorage.getItem(y.p),n=localStorage.getItem(y.j),a=localStorage.getItem(y.g);return e.state={theme:"dark"===t?"dark":"light",language:"en-US"===a?"en-US":"zh-CN",nameShow:"select"===n?"select":"label"},e}return Object(l.a)(o,[{key:"newTheme",value:function(e){this.setState({theme:e})}},{key:"newLanguage",value:function(e){this.setState({language:e})}},{key:"newNameShow",value:function(e){this.setState({nameShow:e})}},{key:"submit",value:function(){var e=this.props,t=e.changeLanguage,n=e.changeTheme,e=e.changeNameShow,a=this.state.language,r=this.state.theme,o=this.state.nameShow;t(a),n(r),e(o)}},{key:"render",value:function(){var e=this.props.locale,e=void 0===e?{}:e,t=[{value:"light",label:e.settingLight},{value:"dark",label:e.settingDark}],n=[{value:"select",label:e.settingShowSelect},{value:"label",label:e.settingShowLabel}];return f.a.createElement(f.a.Fragment,null,f.a.createElement(p.a,{title:e.settingTitle}),f.a.createElement("div",{className:"setting-box"},f.a.createElement("div",{className:"text-box"},f.a.createElement("div",{className:"setting-checkbox"},f.a.createElement("div",{className:"setting-span"},e.settingTheme),f.a.createElement(v,{dataSource:t,value:this.state.theme,onChange:this.newTheme.bind(this)})),f.a.createElement("div",{className:"setting-checkbox"},f.a.createElement("div",{className:"setting-span"},e.settingLocale),f.a.createElement(v,{dataSource:[{value:"en-US",label:"English"},{value:"zh-CN",label:"中文"}],value:this.state.language,onChange:this.newLanguage.bind(this)})),f.a.createElement("div",{className:"setting-checkbox"},f.a.createElement("div",{className:"setting-span"},e.settingShow),f.a.createElement(v,{dataSource:n,value:this.state.nameShow,onChange:this.newNameShow.bind(this)}))),f.a.createElement(i.a,{type:"primary",onClick:this.submit.bind(this)},e.settingSubmit)))}}]),o}(f.a.Component)).displayName="SettingCenter",o=n))||o)||o;t.a=g},function(e,t,V){"use strict";V.r(t),function(e){V(54);var t=V(36),a=V.n(t),t=(V(27),V(6)),r=V.n(t),o=V(13),i=V(14),s=V(16),l=V(15),n=V(12),t=V(0),u=V.n(t),t=V(25),t=V.n(t),c=V(125),d=V(429),f=V(440),p=V(30),h=V(39),m=V(73),g=(V(477),V(449)),y=V(22),v=V(450),_=V(451),b=V(443),w=V(452),M=V(453),S=V(444),k=V(454),E=V(455),x=V(456),C=V(457),T=V(458),L=V(441),O=V(445),D=V(442),N=V(459),P=V(460),j=V(446),I=V(447),A=V(448),R=V(438),H=V(461),Y=V(439),F=V(87),z=V(52),W=V(148),B=V(149),e=(V(785),e.hot,localStorage.getItem(y.g)||localStorage.setItem(y.g,"zh-CN"===navigator.language?"zh-CN":"en-US"),Object(c.b)(Object(n.a)(Object(n.a)({},Y.a),{},{routing:d.routerReducer}))),Y=Object(c.d)(e,Object(c.c)(Object(c.a)(f.a),window[y.l]?window[y.l]():function(e){return e})),U=[{path:"/",exact:!0,render:function(){return u.a.createElement(h.a,{to:"/welcome"})}},{path:"/welcome",component:R.a},{path:"/namespace",component:b.a},{path:"/newconfig",component:w.a},{path:"/configsync",component:M.a},{path:"/configdetail",component:S.a},{path:"/configeditor",component:k.a},{path:"/historyDetail",component:E.a},{path:"/configRollback",component:x.a},{path:"/historyRollback",component:C.a},{path:"/listeningToQuery",component:T.a},{path:"/configurationManagement",component:L.a},{path:"/serviceManagement",component:O.a},{path:"/serviceDetail",component:D.a},{path:"/subscriberList",component:N.a},{path:"/clusterManagement",component:P.a},{path:"/userManagement",component:j.a},{path:"/rolesManagement",component:A.a},{path:"/permissionsManagement",component:I.a},{path:"/settingCenter",component:H.a}],e=Object(p.b)(function(e){return Object(n.a)(Object(n.a)({},e.locale),e.base)},{changeLanguage:F.a,getState:z.e,changeTheme:W.a,changeNameShow:B.a})(d=function(e){Object(s.a)(n,e);var t=Object(l.a)(n);function n(e){return Object(o.a)(this,n),(e=t.call(this,e)).state={shownotice:"none",noticecontent:"",nacosLoading:{}},e}return Object(i.a)(n,[{key:"componentDidMount",value:function(){this.props.getState();var e=localStorage.getItem(y.g),t=localStorage.getItem(y.p),n=localStorage.getItem(y.j);this.props.changeLanguage(e),this.props.changeTheme(t),this.props.changeNameShow(n)}},{key:"router",get:function(){var e=this.props,t=e.loginPageEnabled,e=e.consoleUiEnable;return u.a.createElement(m.a,null,u.a.createElement(h.d,null,t&&"false"===t?null:u.a.createElement(h.b,{path:"/login",component:v.a}),u.a.createElement(h.b,{path:"/register",component:_.a}),u.a.createElement(g.a,null,e&&"true"===e&&U.map(function(e){return u.a.createElement(h.b,Object.assign({key:e.path},e))}))))}},{key:"render",value:function(){var e=this.props,t=e.locale,e=e.loginPageEnabled;return u.a.createElement(a.a,Object.assign({className:"nacos-loading",shape:"flower",tip:"loading...",visible:!e,fullScreen:!0},this.state.nacosLoading),u.a.createElement(r.a,{locale:t},this.router))}}]),n}(u.a.Component))||d;t.a.render(u.a.createElement(p.a,{store:Y},u.a.createElement(e,null)),document.getElementById("root"))}.call(this,V(463)(e))},function(e,t){e.exports=function(e){var t;return e.webpackPolyfill||((t=Object.create(e)).children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),Object.defineProperty(t,"exports",{enumerable:!0}),t.webpackPolyfill=1),t}},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(I,e,t){"use strict"; /** @license React v16.14.0 * react.production.min.js * @@ -335,6 +335,6 @@ var k=P(706),o=P(707),s=P(708);function n(){return d.TYPED_ARRAY_SUPPORT?2147483 * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var a=60103,r=60106,o=60107,i=60108,s=60114,l=60109,u=60110,c=60112,d=60113,f=60120,p=60115,h=60116,m=60121,g=60122,y=60117,v=60129,_=60131;function b(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case a:switch(e=e.type){case o:case s:case i:case d:case f:return e;default:switch(e=e&&e.$$typeof){case u:case c:case h:case p:case l:return e;default:return t}}case r:return t}}}"function"==typeof Symbol&&Symbol.for&&(a=(w=Symbol.for)("react.element"),r=w("react.portal"),o=w("react.fragment"),i=w("react.strict_mode"),s=w("react.profiler"),l=w("react.provider"),u=w("react.context"),c=w("react.forward_ref"),d=w("react.suspense"),f=w("react.suspense_list"),p=w("react.memo"),h=w("react.lazy"),m=w("react.block"),g=w("react.server.block"),y=w("react.fundamental"),v=w("react.debug_trace_mode"),_=w("react.legacy_hidden"));var w=l,M=a,S=c,k=o,E=h,x=p,C=r,T=s,L=i,O=d;t.ContextConsumer=u,t.ContextProvider=w,t.Element=M,t.ForwardRef=S,t.Fragment=k,t.Lazy=E,t.Memo=x,t.Portal=C,t.Profiler=T,t.StrictMode=L,t.Suspense=O,t.isAsyncMode=function(){return!1},t.isConcurrentMode=function(){return!1},t.isContextConsumer=function(e){return b(e)===u},t.isContextProvider=function(e){return b(e)===l},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===a},t.isForwardRef=function(e){return b(e)===c},t.isFragment=function(e){return b(e)===o},t.isLazy=function(e){return b(e)===h},t.isMemo=function(e){return b(e)===p},t.isPortal=function(e){return b(e)===r},t.isProfiler=function(e){return b(e)===s},t.isStrictMode=function(e){return b(e)===i},t.isSuspense=function(e){return b(e)===d},t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===o||e===s||e===v||e===i||e===d||e===f||e===_||"object"==typeof e&&null!==e&&(e.$$typeof===h||e.$$typeof===p||e.$$typeof===l||e.$$typeof===u||e.$$typeof===c||e.$$typeof===y||e.$$typeof===m||e[0]===g)},t.typeOf=b},function(e,t,n){"use strict";var a,r=n(1);window.edasprefix="acm",window.globalConfig={isParentEdas:function(){return window.parent&&-1!==window.parent.location.host.indexOf("edas")}},r.e.middleWare(function(){var e=0=e.length?{value:void 0,done:!0}:(e=a(e,t),this._i+=e.length,{value:e,done:!1})})},function(e,t,n){var o=n(153),i=n(152);e.exports=function(r){return function(e,t){var n,e=String(i(e)),t=o(t),a=e.length;return t<0||a<=t?r?"":void 0:(n=e.charCodeAt(t))<55296||56319=e.length?(this._t=void 0,r(1)):r(0,"keys"==t?n:"values"==t?e[n]:[n,e[n]])},"values"),o.Arguments=o.Array,a("keys"),a("values"),a("entries")},function(e,t){e.exports=function(){}},function(e,t){e.exports=function(e,t){return{value:t,done:!!e}}},function(e,t,n){e.exports={default:n(500),__esModule:!0}},function(e,t,n){n(501),n(506),n(507),n(508),e.exports=n(81).Symbol},function(I,A,e){"use strict";function a(e){var t=T[e]=_(M[E]);return t._k=e,t}function n(e,t){m(e);for(var n,a=B(t=g(t)),r=0,o=a.length;rr;)l(T,t=n[r++])||t==x||t==H||a.push(t);return a}function i(e){for(var t,n=e===O,a=X(n?L:g(e)),r=[],o=0;a.length>o;)!l(T,t=a[o++])||n&&!l(O,t)||r.push(T[t]);return r}var s=e(80),l=e(90),u=e(82),c=e(96),R=e(211),H=e(502).KEY,d=e(113),f=e(155),p=e(161),F=e(129),h=e(100),z=e(162),W=e(163),B=e(503),U=e(504),m=e(112),V=e(98),K=e(158),g=e(99),y=e(151),v=e(126),_=e(160),q=e(505),G=e(213),b=e(157),$=e(89),J=e(127),Q=G.f,w=$.f,X=q.f,M=s.Symbol,S=s.JSON,k=S&&S.stringify,E="prototype",x=h("_hidden"),Z=h("toPrimitive"),ee={}.propertyIsEnumerable,C=f("symbol-registry"),T=f("symbols"),L=f("op-symbols"),O=Object[E],f="function"==typeof M&&!!b.f,D=s.QObject,N=!D||!D[E]||!D[E].findChild,P=u&&d(function(){return 7!=_(w({},"a",{get:function(){return w(this,"a",{value:7}).a}})).a})?function(e,t,n){var a=Q(O,t);a&&delete O[t],w(e,t,n),a&&e!==O&&w(O,t,a)}:w,j=f&&"symbol"==typeof M.iterator?function(e){return"symbol"==typeof e}:function(e){return e instanceof M},Y=function(e,t,n){return e===O&&Y(L,t,n),m(e),t=y(t,!0),m(n),(l(T,t)?(n.enumerable?(l(e,x)&&e[x][t]&&(e[x][t]=!1),n=_(n,{enumerable:v(0,!1)})):(l(e,x)||w(e,x,v(1,{})),e[x][t]=!0),P):w)(e,t,n)};f||(R((M=function(){if(this instanceof M)throw TypeError("Symbol is not a constructor!");var t=F(0ne;)h(te[ne++]);for(var ae=J(h.store),re=0;ae.length>re;)W(ae[re++]);c(c.S+c.F*!f,"Symbol",{for:function(e){return l(C,e+="")?C[e]:C[e]=M(e)},keyFor:function(e){if(!j(e))throw TypeError(e+" is not a symbol!");for(var t in C)if(C[t]===e)return t},useSetter:function(){N=!0},useSimple:function(){N=!1}}),c(c.S+c.F*!f,"Object",{create:function(e,t){return void 0===t?_(e):n(_(e),t)},defineProperty:Y,defineProperties:n,getOwnPropertyDescriptor:r,getOwnPropertyNames:o,getOwnPropertySymbols:i});D=d(function(){b.f(1)});c(c.S+c.F*D,"Object",{getOwnPropertySymbols:function(e){return b.f(K(e))}}),S&&c(c.S+c.F*(!f||d(function(){var e=M();return"[null]"!=k([e])||"{}"!=k({a:e})||"{}"!=k(Object(e))})),"JSON",{stringify:function(e){for(var t,n,a=[e],r=1;ri;)o.call(e,a=r[i++])&&t.push(a);return t}},function(e,t,n){var a=n(209);e.exports=Array.isArray||function(e){return"Array"==a(e)}},function(e,t,n){var a=n(99),r=n(212).f,o={}.toString,i="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];e.exports.f=function(e){if(!i||"[object Window]"!=o.call(e))return r(a(e));try{return r(e)}catch(e){return i.slice()}}},function(e,t){},function(e,t,n){n(163)("asyncIterator")},function(e,t,n){n(163)("observable")},function(e,t,n){e.exports={default:n(510),__esModule:!0}},function(e,t,n){n(511),e.exports=n(81).Object.setPrototypeOf},function(e,t,n){var a=n(96);a(a.S,"Object",{setPrototypeOf:n(512).set})},function(e,t,r){function o(e,t){if(a(e),!n(t)&&null!==t)throw TypeError(t+": can't set as prototype!")}var n=r(98),a=r(112);e.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(e,n,a){try{(a=r(204)(Function.call,r(213).f(Object.prototype,"__proto__").set,2))(e,[]),n=!(e instanceof Array)}catch(e){n=!0}return function(e,t){return o(e,t),n?e.__proto__=t:a(e,t),e}}({},!1):void 0),check:o}},function(e,t,n){e.exports={default:n(514),__esModule:!0}},function(e,t,n){n(515);var a=n(81).Object;e.exports=function(e,t){return a.create(e,t)}},function(e,t,n){var a=n(96);a(a.S,"Object",{create:n(160)})},function(e,t,n){"use strict";var i=n(517);function a(){}function r(){}r.resetWarningCache=a,e.exports=function(){function e(e,t,n,a,r,o){if(o!==i)throw(o=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")).name="Invariant Violation",o}function t(){return e}var n={array:e.isRequired=e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:r,resetWarningCache:a};return n.PropTypes=n}},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,n){"use strict";function l(e,t,n,a){e.removeEventListener&&e.removeEventListener(t,n,a||!1)}function a(e,t,n,a){return e.addEventListener&&e.addEventListener(t,n,a||!1),{off:function(){return l(e,t,n,a)}}}t.__esModule=!0,t.on=a,t.once=function(r,o,i,s){return a(r,o,function e(){for(var t=arguments.length,n=Array(t),a=0;a68?1900:2e3)},r=function(t){return function(e){this[t]=+e}},o=[/[+-]\d\d:?(\d\d)?|Z/,function(e){(this.zone||(this.zone={})).offset=function(e){if(!e)return 0;if("Z"===e)return 0;var t=e.match(/([+-]|\d\d)/g),n=60*t[1]+(+t[2]||0);return 0===n?0:"+"===t[0]?-n:n}(e)}],i=function(e){var t=h[e];return t&&(t.indexOf?t:t.s.concat(t.f))},s=function(e,t){var n,a=h.meridiem;if(a){for(var r=1;r<=24;r+=1)if(e.indexOf(a(r,0,t))>-1){n=r>12;break}}else n=e===(t?"pm":"PM");return n},f={A:[n,function(e){this.afternoon=s(e,!1)}],a:[n,function(e){this.afternoon=s(e,!0)}],S:[/\d/,function(e){this.milliseconds=100*+e}],SS:[e,function(e){this.milliseconds=10*+e}],SSS:[/\d{3}/,function(e){this.milliseconds=+e}],s:[t,r("seconds")],ss:[t,r("seconds")],m:[t,r("minutes")],mm:[t,r("minutes")],H:[t,r("hours")],h:[t,r("hours")],HH:[t,r("hours")],hh:[t,r("hours")],D:[t,r("day")],DD:[e,r("day")],Do:[n,function(e){var t=h.ordinal,n=e.match(/\d+/);if(this.day=n[0],t)for(var a=1;a<=31;a+=1)t(a).replace(/\[|\]/g,"")===e&&(this.day=a)}],M:[t,r("month")],MM:[e,r("month")],MMM:[n,function(e){var t=i("months"),n=(i("monthsShort")||t.map(function(e){return e.slice(0,3)})).indexOf(e)+1;if(n<1)throw new Error;this.month=n%12||n}],MMMM:[n,function(e){var t=i("months").indexOf(e)+1;if(t<1)throw new Error;this.month=t%12||t}],Y:[/[+-]?\d+/,r("year")],YY:[e,function(e){this.year=a(e)}],YYYY:[/\d{4}/,r("year")],Z:o,ZZ:o};function b(e){var t,r;t=e,r=h&&h.formats;for(var u=(e=t.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(e,t,n){var a=n&&n.toUpperCase();return t||r[n]||l[n]||r[a].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(e,t,n){return t||n.slice(1)})})).match(d),c=u.length,n=0;n-1)return new Date(("X"===t?1e3:1)*e);var a=b(t)(e),r=a.year,o=a.month,i=a.day,s=a.hours,l=a.minutes,u=a.seconds,c=a.milliseconds,d=a.zone,f=new Date,p=i||(r||o?1:f.getDate()),h=r||f.getFullYear(),m=0;r&&!o||(m=o>0?o-1:f.getMonth());var g=s||0,y=l||0,v=u||0,_=c||0;return d?new Date(Date.UTC(h,m,p,g,y,v,_+60*d.offset*1e3)):n?new Date(Date.UTC(h,m,p,g,y,v,_)):new Date(h,m,p,g,y,v,_)}catch(e){return new Date("")}}(t,r,n),this.init(),l&&!0!==l&&(this.$L=this.locale(l).$L),s&&t!=this.format(r)&&(this.$d=new Date("")),h={}}else if(r instanceof Array)for(var u=r.length,c=1;c<=u;c+=1){a[1]=r[c-1];var d=f.apply(this,a);if(d.isValid()){this.$d=d.$d,this.$L=d.$L,this.init();break}c===u&&(this.$d=new Date(""))}else p.call(this,e)}}}()},function(e,t,n){e.exports=function(){"use strict";return function(e,t,a){a.updateLocale=function(e,t){var n=a.Ls[e];if(n)return(t?Object.keys(t):[]).forEach(function(e){n[e]=t[e]}),n}}}()},function(e,t,n){e.exports=function(e,t,n){function a(e,t,n,a,r){var o,e=e.name?e:e.$locale(),t=s(e[t]),n=s(e[n]),i=t||n.map(function(e){return e.slice(0,a)});return r?(o=e.weekStart,i.map(function(e,t){return i[(t+(o||0))%7]})):i}function r(){return n.Ls[n.locale()]}function o(e,t){return e.formats[t]||e.formats[t.toUpperCase()].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(e,t,n){return t||n.slice(1)})}var t=t.prototype,s=function(e){return e&&(e.indexOf?e:e.s)};t.localeData=function(){return function(){var t=this;return{months:function(e){return e?e.format("MMMM"):a(t,"months")},monthsShort:function(e){return e?e.format("MMM"):a(t,"monthsShort","months",3)},firstDayOfWeek:function(){return t.$locale().weekStart||0},weekdays:function(e){return e?e.format("dddd"):a(t,"weekdays")},weekdaysMin:function(e){return e?e.format("dd"):a(t,"weekdaysMin","weekdays",2)},weekdaysShort:function(e){return e?e.format("ddd"):a(t,"weekdaysShort","weekdays",3)},longDateFormat:function(e){return o(t.$locale(),e)},meridiem:this.$locale().meridiem,ordinal:this.$locale().ordinal}}.bind(this)()},n.localeData=function(){var t=r();return{firstDayOfWeek:function(){return t.weekStart||0},weekdays:function(){return n.weekdays()},weekdaysShort:function(){return n.weekdaysShort()},weekdaysMin:function(){return n.weekdaysMin()},months:function(){return n.months()},monthsShort:function(){return n.monthsShort()},longDateFormat:function(e){return o(t,e)},meridiem:t.meridiem,ordinal:t.ordinal}},n.months=function(){return a(r(),"months")},n.monthsShort=function(){return a(r(),"monthsShort","months",3)},n.weekdays=function(e){return a(r(),"weekdays",null,null,e)},n.weekdaysShort=function(e){return a(r(),"weekdaysShort","weekdays",3,e)},n.weekdaysMin=function(e){return a(r(),"weekdaysMin","weekdays",2,e)}}},function(e,t,n){e.exports=function(){"use strict";var i="month",s="quarter";return function(e,t){var n=t.prototype;n.quarter=function(e){return this.$utils().u(e)?Math.ceil((this.month()+1)/3):this.month(this.month()%3+3*(e-1))};var a=n.add;n.add=function(e,t){return e=Number(e),this.$utils().p(t)===s?this.add(3*e,i):a.bind(this)(e,t)};var o=n.startOf;n.startOf=function(e,t){var n=this.$utils(),a=!!n.u(t)||t;if(n.p(e)===s){var r=this.quarter()-1;return a?this.month(3*r).startOf(i).startOf("day"):this.month(3*r+2).endOf(i).endOf("day")}return o.bind(this)(e,t)}}}()},function(e,t,n){e.exports=function(){"use strict";return function(e,t){var n=t.prototype,o=n.format;n.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return o.bind(this)(e);var a=this.$utils(),r=(e||"YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,function(e){switch(e){case"Q":return Math.ceil((t.$M+1)/3);case"Do":return n.ordinal(t.$D);case"gggg":return t.weekYear();case"GGGG":return t.isoWeekYear();case"wo":return n.ordinal(t.week(),"W");case"w":case"ww":return a.s(t.week(),"w"===e?1:2,"0");case"W":case"WW":return a.s(t.isoWeek(),"W"===e?1:2,"0");case"k":case"kk":return a.s(String(0===t.$H?24:t.$H),"k"===e?1:2,"0");case"X":return Math.floor(t.$d.getTime()/1e3);case"x":return t.$d.getTime();case"z":return"["+t.offsetName()+"]";case"zzz":return"["+t.offsetName("long")+"]";default:return e}});return o.bind(this)(r)}}}()},function(e,t,n){e.exports=function(){"use strict";var s="week",l="year";return function(e,t,i){var n=t.prototype;n.week=function(e){if(void 0===e&&(e=null),null!==e)return this.add(7*(e-this.week()),"day");var t=this.$locale().yearStart||1;if(11===this.month()&&this.date()>25){var n=i(this).startOf(l).add(1,l).date(t),a=i(this).endOf(s);if(n.isBefore(a))return 1}var r=i(this).startOf(l).date(t).startOf(s).subtract(1,"millisecond"),o=this.diff(r,s,!0);return o<0?i(this).startOf("week").week():Math.ceil(o)},n.weeks=function(e){return void 0===e&&(e=null),this.week(e)}}}()},function(e,t,n){e.exports=function(e){"use strict";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(e),a={name:"zh-cn",weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"周日_周一_周二_周三_周四_周五_周六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(e,t){return"W"===t?e+"周":e+"日"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日Ah点mm分",LLLL:"YYYY年M月D日ddddAh点mm分",l:"YYYY/M/D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s内",past:"%s前",s:"几秒",m:"1 分钟",mm:"%d 分钟",h:"1 小时",hh:"%d 小时",d:"1 天",dd:"%d 天",M:"1 个月",MM:"%d 个月",y:"1 年",yy:"%d 年"},meridiem:function(e,t){var n=100*e+t;return n<600?"凌晨":n<900?"早上":n<1100?"上午":n<1300?"中午":n<1800?"下午":"晚上"}};return n.default.locale(a,null,!0),a}(n(219))},function(e,t,n){"use strict";t.__esModule=!0,t.flex=t.transition=t.animation=void 0;var r=n(215),o=n(101);function a(e){var n,a;return!!r.hasDOM&&(n=document.createElement("div"),(a=!1,o.each)(e,function(e,t){if(void 0!==n.style[t])return!(a={end:e})}),a)}var i,s;t.animation=a({WebkitAnimation:"webkitAnimationEnd",OAnimation:"oAnimationEnd",animation:"animationend"}),t.transition=a({WebkitTransition:"webkitTransitionEnd",OTransition:"oTransitionEnd",transition:"transitionend"}),t.flex=(n={display:["flex","-webkit-flex","-moz-flex","-ms-flexbox"]},!!r.hasDOM&&(i=document.createElement("div"),(s=!1,o.each)(n,function(e,t){return(0,o.each)(e,function(e){try{i.style[t]=e,s=s||i.style[t]===e}catch(e){}return!s}),!s}),s))},function(e,t,n){"use strict";t.__esModule=!0,t.getFocusNodeList=i,t.saveLastFocusNode=function(){s=document.activeElement},t.clearLastFocusNode=function(){s=null},t.backLastFocusNode=function(){if(s)try{s.focus()}catch(e){}},t.limitTabRange=function(e,t){{var n,a;t.keyCode===r.default.TAB&&(e=i(e),n=e.length-1,-1<(a=e.indexOf(document.activeElement)))&&(a=a+(t.shiftKey?-1:1),e[a=n<(a=a<0?n:a)?0:a].focus(),t.preventDefault())}};var t=n(220),r=(t=t)&&t.__esModule?t:{default:t},a=n(101);function o(e){var t=e.nodeName.toLowerCase(),n=parseInt(e.getAttribute("tabindex"),10),n=!isNaN(n)&&-1a.height)&&(r[1]=-t.top-("t"===e?t.height:0)),r},this._getParentScrollOffset=function(e){var t=0,n=0;return e&&e.offsetParent&&e.offsetParent!==document.body&&(isNaN(e.offsetParent.scrollTop)||(t+=e.offsetParent.scrollTop),isNaN(e.offsetParent.scrollLeft)||(n+=e.offsetParent.scrollLeft)),{top:t,left:n}}};var p=a;function h(e){(0,o.default)(this,h),r.call(this),this.pinElement=e.pinElement,this.baseElement=e.baseElement,this.pinFollowBaseElementWhenFixed=e.pinFollowBaseElementWhenFixed,this.container=function(e){var t=e.container,e=e.baseElement;if("undefined"==typeof document)return t;for(var n=(n=(0,i.default)(t,e))||document.body;"static"===y.dom.getStyle(n,"position");){if(!n||n===document.body)return document.body;n=n.parentNode}return n}(e),this.autoFit=e.autoFit||!1,this.align=e.align||"tl tl",this.offset=e.offset||[0,0],this.needAdjust=e.needAdjust||!1,this.isRtl=e.isRtl||!1}t.default=p,e.exports=t.default},function(e,t,n){"use strict";t.__esModule=!0;var w=a(n(3)),M=a(n(17)),S=n(0),k=a(S),E=a(n(19)),x=a(n(196)),C=a(n(83)),T=n(11);function a(e){return e&&e.__esModule?e:{default:e}}t.default=function(e){var t,n,a,r,o,i,s,l,u,c,d,f,p,h,m,g,y,v,_,b;return S.useState&&S.useRef&&S.useEffect?(t=void 0===(t=e.prefix)?"next-":t,r=e.animation,n=void 0===r?{in:"expandInDown",out:"expandOutUp"}:r,a=e.visible,r=e.hasMask,o=e.align,o=void 0===(s=e.points)?o?o.split(" "):void 0:s,i=e.onPosition,s=e.children,b=e.className,l=e.style,u=e.wrapperClassName,c=e.beforeOpen,d=e.onOpen,f=e.afterOpen,p=e.beforeClose,h=e.onClose,m=e.afterClose,e=(0,M.default)(e,["prefix","animation","visible","hasMask","align","points","onPosition","children","className","style","wrapperClassName","beforeOpen","onOpen","afterOpen","beforeClose","onClose","afterClose"]),g=(_=(0,S.useState)(!0))[0],y=_[1],v=(0,S.useRef)(null),_=k.default.createElement(C.default.OverlayAnimate,{visible:a,animation:n,onEnter:function(){y(!1),"function"==typeof c&&c(v.current)},onEntering:function(){"function"==typeof d&&d(v.current)},onEntered:function(){"function"==typeof f&&f(v.current)},onExit:function(){"function"==typeof p&&p(v.current)},onExiting:function(){"function"==typeof h&&h(v.current)},onExited:function(){y(!0),"function"==typeof m&&m(v.current)},timeout:300,style:l},s?(0,S.cloneElement)(s,{className:(0,E.default)([t+"overlay-inner",b,s&&s.props&&s.props.className])}):k.default.createElement("span",null)),b=(0,E.default)(((l={})[t+"overlay-wrapper v2"]=!0,l[u]=u,l.opened=a,l)),k.default.createElement(x.default,(0,w.default)({},e,{visible:a,isAnimationEnd:g,hasMask:r,wrapperClassName:b,maskClassName:t+"overlay-backdrop",maskRender:function(e){return k.default.createElement(C.default.OverlayAnimate,{visible:a,animation:!!n&&{in:"fadeIn",out:"fadeOut"},timeout:300,unmountOnExit:!0},e)},points:o,onPosition:function(e){(0,w.default)(e,{align:e.config.points}),"function"==typeof i&&i(e)},ref:v}),_)):(T.log.warning("need react version > 16.8.0"),null)},e.exports=t.default},function(n,e){function a(e,t){return n.exports=a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},n.exports.__esModule=!0,n.exports.default=n.exports,a(e,t)}n.exports=a,n.exports.__esModule=!0,n.exports.default=n.exports},function(e,t,n){"use strict";t.__esModule=!0;var a,c=g(n(17)),d=g(n(3)),r=g(n(4)),o=g(n(7)),i=g(n(8)),l=n(0),f=g(l),p=n(25),s=n(31),u=g(n(5)),h=n(11),m=g(n(362));function g(e){return e&&e.__esModule?e:{default:e}}var y,n=h.func.noop,v=h.func.makeChain,_=h.func.bindCtx,u=(y=l.Component,(0,i.default)(b,y),b.getDerivedStateFromProps=function(e,t){return"visible"in e?(0,d.default)({},t,{visible:e.visible}):null},b.prototype.componentWillUnmount=function(){var t=this;["_timer","_hideTimer","_showTimer"].forEach(function(e){t[e]&&clearTimeout(t[e])})},b.prototype.handleVisibleChange=function(e,t,n){"visible"in this.props||this.setState({visible:e}),this.props.onVisibleChange(e,t,n)},b.prototype.handleTriggerClick=function(e){this.state.visible&&!this.props.canCloseByTrigger||this.handleVisibleChange(!this.state.visible,"fromTrigger",e)},b.prototype.handleTriggerKeyDown=function(e){var t=this.props.triggerClickKeycode;(Array.isArray(t)?t:[t]).includes(e.keyCode)&&(e.preventDefault(),this.handleTriggerClick(e))},b.prototype.handleTriggerMouseEnter=function(e){var t=this;this._mouseNotFirstOnMask=!1,this._hideTimer&&(clearTimeout(this._hideTimer),this._hideTimer=null),this._showTimer&&(clearTimeout(this._showTimer),this._showTimer=null),this.state.visible||(this._showTimer=setTimeout(function(){t.handleVisibleChange(!0,"fromTrigger",e)},this.props.delay))},b.prototype.handleTriggerMouseLeave=function(e,t){var n=this;this._showTimer&&(clearTimeout(this._showTimer),this._showTimer=null),this.state.visible&&(this._hideTimer=setTimeout(function(){n.handleVisibleChange(!1,t||"fromTrigger",e)},this.props.delay))},b.prototype.handleTriggerFocus=function(e){this.handleVisibleChange(!0,"fromTrigger",e)},b.prototype.handleTriggerBlur=function(e){this._isForwardContent||this.handleVisibleChange(!1,"fromTrigger",e),this._isForwardContent=!1},b.prototype.handleContentMouseDown=function(){this._isForwardContent=!0},b.prototype.handleContentMouseEnter=function(){clearTimeout(this._hideTimer)},b.prototype.handleContentMouseLeave=function(e){this.handleTriggerMouseLeave(e,"fromContent")},b.prototype.handleMaskMouseEnter=function(){this._mouseNotFirstOnMask||(clearTimeout(this._hideTimer),this._hideTimer=null,this._mouseNotFirstOnMask=!1)},b.prototype.handleMaskMouseLeave=function(){this._mouseNotFirstOnMask=!0},b.prototype.handleRequestClose=function(e,t){this.handleVisibleChange(!1,e,t)},b.prototype.renderTrigger=function(){var e,t,n,a,r,o,i,s=this,l=this.props,u=l.trigger,l=l.disabled,c={key:"trigger","aria-haspopup":!0,"aria-expanded":this.state.visible};return this.state.visible||(c["aria-describedby"]=void 0),l||(l=this.props.triggerType,l=Array.isArray(l)?l:[l],e=u&&u.props||{},t=e.onClick,n=e.onKeyDown,a=e.onMouseEnter,r=e.onMouseLeave,o=e.onFocus,i=e.onBlur,l.forEach(function(e){switch(e){case"click":c.onClick=v(s.handleTriggerClick,t),c.onKeyDown=v(s.handleTriggerKeyDown,n);break;case"hover":c.onMouseEnter=v(s.handleTriggerMouseEnter,a),c.onMouseLeave=v(s.handleTriggerMouseLeave,r);break;case"focus":c.onFocus=v(s.handleTriggerFocus,o),c.onBlur=v(s.handleTriggerBlur,i)}})),u&&f.default.cloneElement(u,c)},b.prototype.renderContent=function(){var t=this,e=this.props,n=e.children,e=e.triggerType,e=Array.isArray(e)?e:[e],n=l.Children.only(n),a=n.props,r=a.onMouseDown,o=a.onMouseEnter,i=a.onMouseLeave,s={key:"portal"};return e.forEach(function(e){switch(e){case"focus":s.onMouseDown=v(t.handleContentMouseDown,r);break;case"hover":s.onMouseEnter=v(t.handleContentMouseEnter,o),s.onMouseLeave=v(t.handleContentMouseLeave,i)}}),f.default.cloneElement(n,s)},b.prototype.renderPortal=function(){function e(){return(0,p.findDOMNode)(t)}var t=this,n=this.props,a=n.target,r=n.safeNode,o=n.followTrigger,i=n.triggerType,s=n.hasMask,l=n.wrapperStyle,n=(0,c.default)(n,["target","safeNode","followTrigger","triggerType","hasMask","wrapperStyle"]),u=this.props.container,r=Array.isArray(r)?[].concat(r):[r],l=(r.unshift(e),l||{});return o&&(u=function(e){return e&&e.parentNode||e},l.position="relative"),"hover"===i&&s&&(n.onMaskMouseEnter=this.handleMaskMouseEnter,n.onMaskMouseLeave=this.handleMaskMouseLeave),f.default.createElement(m.default,(0,d.default)({},n,{key:"overlay",ref:function(e){return t.overlay=e},visible:this.state.visible,target:a||e,container:u,safeNode:r,wrapperStyle:l,triggerType:i,hasMask:s,onRequestClose:this.handleRequestClose}),this.props.children&&this.renderContent())},b.prototype.render=function(){return[this.renderTrigger(),this.renderPortal()]},a=i=b,i.propTypes={children:u.default.node,trigger:u.default.element,triggerType:u.default.oneOfType([u.default.string,u.default.array]),triggerClickKeycode:u.default.oneOfType([u.default.number,u.default.array]),visible:u.default.bool,defaultVisible:u.default.bool,onVisibleChange:u.default.func,disabled:u.default.bool,autoFit:u.default.bool,delay:u.default.number,canCloseByTrigger:u.default.bool,target:u.default.any,safeNode:u.default.any,followTrigger:u.default.bool,container:u.default.any,hasMask:u.default.bool,wrapperStyle:u.default.object,rtl:u.default.bool,v2:u.default.bool,placement:u.default.string,placementOffset:u.default.number,autoAdjust:u.default.bool},i.defaultProps={triggerType:"hover",triggerClickKeycode:[h.KEYCODE.SPACE,h.KEYCODE.ENTER],defaultVisible:!1,onVisibleChange:n,disabled:!1,autoFit:!1,delay:200,canCloseByTrigger:!0,followTrigger:!1,container:function(){return document.body},rtl:!1},a);function b(e){(0,r.default)(this,b);var t=(0,o.default)(this,y.call(this,e));return t.state={visible:void 0===e.visible?e.defaultVisible:e.visible},_(t,["handleTriggerClick","handleTriggerKeyDown","handleTriggerMouseEnter","handleTriggerMouseLeave","handleTriggerFocus","handleTriggerBlur","handleContentMouseEnter","handleContentMouseLeave","handleContentMouseDown","handleRequestClose","handleMaskMouseEnter","handleMaskMouseLeave"]),t}u.displayName="Popup",t.default=(0,s.polyfill)(u),e.exports=t.default},function(e,t,n){"use strict";t.__esModule=!0;var L=a(n(3)),O=a(n(17)),D=n(0),N=a(D),P=a(n(19)),j=a(n(196)),Y=a(n(83)),I=n(11);function a(e){return e&&e.__esModule?e:{default:e}}t.default=function(r){var e,t,o,n,a,i,s,l,u,c,d,f,p,h,m,g,y,v,_,b,w,M,S,k,E,x,C,T;return D.useState&&D.useRef&&D.useEffect?(e=void 0===(e=r.prefix)?"next-":e,E=r.animation,t=void 0===E?{in:"expandInDown",out:"expandOutUp"}:E,E=r.defaultVisible,x=r.onVisibleChange,o=void 0===x?function(){}:x,x=r.trigger,n=void 0===(n=r.triggerType)?"hover":n,C=r.overlay,a=r.onPosition,T=r.children,i=r.className,s=r.style,l=r.wrapperClassName,u=r.triggerClickKeycode,c=r.align,d=r.beforeOpen,f=r.onOpen,p=r.afterOpen,h=r.beforeClose,m=r.onClose,g=r.afterClose,y=(0,O.default)(r,["prefix","animation","defaultVisible","onVisibleChange","trigger","triggerType","overlay","onPosition","children","className","style","wrapperClassName","triggerClickKeycode","align","beforeOpen","onOpen","afterOpen","beforeClose","onClose","afterClose"]),E=(0,D.useState)(E),v=E[0],_=E[1],E=(0,D.useState)(t),b=E[0],w=E[1],M=(E=(0,D.useState)(!0))[0],S=E[1],k=(0,D.useRef)(null),(0,D.useEffect)(function(){"visible"in r&&_(r.visible)},[r.visible]),(0,D.useEffect)(function(){"animation"in r&&b!==t&&w(t)},[t]),E=C?T:x,x=N.default.createElement(Y.default.OverlayAnimate,{visible:v,animation:b,timeout:200,onEnter:function(){S(!1),"function"==typeof d&&d(k.current)},onEntering:function(){"function"==typeof f&&f(k.current)},onEntered:function(){"function"==typeof p&&p(k.current)},onExit:function(){"function"==typeof h&&h(k.current)},onExiting:function(){"function"==typeof m&&m(k.current)},onExited:function(){S(!0),"function"==typeof g&&g(k.current)},style:s},(x=C||T)?(0,D.cloneElement)(x,{className:(0,P.default)([e+"overlay-inner",i,x&&x.props&&x.props.className])}):N.default.createElement("span",null)),C=(0,P.default)(((s={})[e+"overlay-wrapper v2"]=!0,s[l]=l,s.opened=v,s)),T={},c&&(T.points=c.split(" ")),N.default.createElement(j.default.Popup,(0,L.default)({},y,T,{wrapperClassName:C,overlay:x,visible:v,isAnimationEnd:M,triggerType:n,onVisibleChange:function(e){for(var t=arguments.length,n=Array(1 16.8.0"),null)},e.exports=t.default},function(e,t,n){"use strict";t.__esModule=!0;var l=a(n(3)),u=a(n(17)),o=n(0),c=a(o),i=a(n(25)),s=a(n(6)),d=a(n(83)),f=a(n(165)),p=n(11);function a(e){return e&&e.__esModule?e:{default:e}}var h={top:8,maxCount:0,duration:3e3},m=s.default.config(function(e){var t=e.prefix,s=void 0===t?"next-":t,t=e.dataSource,a=void 0===t?[]:t,r=(0,o.useState)()[1];return a.forEach(function(n){n.timer||(n.timer=setTimeout(function(){var e,t=a.indexOf(n);-1a&&y.shift(),i.default.render(c.default.createElement(s.default,s.default.getContext(),c.default.createElement(m,{dataSource:y})),g),{key:n,close:function(){r.timer&&clearTimeout(r.timer);var e=y.indexOf(r);-1 16.8.0")}},e.exports=t.default},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){"use strict";n(565)},function(e,t,n){},function(e,t,n){},function(e,t,n){"use strict";t.__esModule=!0,t.default=void 0;var p=l(n(3)),r=l(n(4)),o=l(n(7)),a=l(n(8)),h=l(n(42)),m=l(n(0)),i=l(n(5)),g=l(n(19)),y=n(11),s=l(n(28)),v=l(n(368));function l(e){return e&&e.__esModule?e:{default:e}}function _(e,r){var o=r.size,i=r.device,s=r.labelAlign,l=r.labelTextAlign,u=r.labelCol,c=r.wrapperCol,d=r.responsive,f=r.colon;return m.default.Children.map(e,function(e){var t,n,a;return y.obj.isReactFragment(e)?_(e.props.children,r):e&&-1<["function","object"].indexOf((0,h.default)(e.type))&&"form_item"===e.type._typeMark?(t={labelCol:e.props.labelCol||u,wrapperCol:e.props.wrapperCol||c,labelAlign:e.props.labelAlign||("phone"===i?"top":s),labelTextAlign:e.props.labelTextAlign||l,colon:"colon"in e.props?e.props.colon:f,size:e.props.size||o,responsive:d},m.default.cloneElement(e,(n=t,a={},Object.keys(n).forEach(function(e){void 0!==n[e]&&(a[e]=n[e])}),a))):e})}u=m.default.Component,(0,a.default)(b,u),b.prototype.getChildContext=function(){return{_formField:this.props.field||this._formField,_formSize:this.props.size,_formDisabled:this.props.disabled,_formPreview:this.props.isPreview,_formFullWidth:this.props.fullWidth,_formLabelForErrorMessage:this.props.useLabelForErrorMessage}},b.prototype.componentDidUpdate=function(e){var t=this.props;this._formField&&("value"in t&&t.value!==e.value&&this._formField.setValues(t.value),"error"in t)&&t.error!==e.error&&this._formField.setValues(t.error)},b.prototype.render=function(){var e=this.props,t=e.className,n=e.inline,a=e.size,r=(e.device,e.labelAlign,e.labelTextAlign,e.onSubmit),o=e.children,i=(e.labelCol,e.wrapperCol,e.style),s=e.prefix,l=e.rtl,u=e.isPreview,c=e.component,d=e.responsive,f=e.gap,n=(e.colon,(0,g.default)(((e={})[s+"form"]=!0,e[s+"inline"]=n,e[""+s+a]=a,e[s+"form-responsive-grid"]=d,e[s+"form-preview"]=u,e[t]=!!t,e))),a=_(o,this.props);return m.default.createElement(c,(0,p.default)({role:"grid"},y.obj.pickOthers(b.propTypes,this.props),{className:n,style:i,dir:l?"rtl":void 0,onSubmit:r}),d?m.default.createElement(v.default,{gap:f},a):a)},a=n=b,n.propTypes={prefix:i.default.string,inline:i.default.bool,size:i.default.oneOf(["large","medium","small"]),fullWidth:i.default.bool,labelAlign:i.default.oneOf(["top","left","inset"]),labelTextAlign:i.default.oneOf(["left","right"]),field:i.default.any,saveField:i.default.func,labelCol:i.default.object,wrapperCol:i.default.object,onSubmit:i.default.func,children:i.default.any,className:i.default.string,style:i.default.object,value:i.default.object,onChange:i.default.func,component:i.default.oneOfType([i.default.string,i.default.func]),fieldOptions:i.default.object,rtl:i.default.bool,device:i.default.oneOf(["phone","tablet","desktop"]),responsive:i.default.bool,isPreview:i.default.bool,useLabelForErrorMessage:i.default.bool,colon:i.default.bool,disabled:i.default.bool,gap:i.default.oneOfType([i.default.arrayOf(i.default.number),i.default.number])},n.defaultProps={prefix:"next-",onSubmit:function(e){e.preventDefault()},size:"medium",labelAlign:"left",onChange:y.func.noop,component:"form",saveField:y.func.noop,device:"desktop",colon:!1,disabled:!1},n.childContextTypes={_formField:i.default.object,_formSize:i.default.string,_formDisabled:i.default.bool,_formPreview:i.default.bool,_formFullWidth:i.default.bool,_formLabelForErrorMessage:i.default.bool};var u,n=a;function b(e){(0,r.default)(this,b);var t,n,a=(0,o.default)(this,u.call(this,e));return a.onChange=function(e,t){a.props.onChange(a._formField.getValues(),{name:e,value:t,field:a._formField})},a._formField=null,!1!==e.field&&(t=(0,p.default)({},e.fieldOptions,{onChange:a.onChange}),e.field?(a._formField=e.field,n=a._formField.options.onChange,t.onChange=y.func.makeChain(n,a.onChange),a._formField.setOptions&&a._formField.setOptions(t)):("value"in e&&(t.values=e.value),a._formField=new s.default(a,t)),e.locale&&e.locale.Validate&&a._formField.setOptions({messages:e.locale.Validate}),e.saveField(a._formField)),a}n.displayName="Form",t.default=n,e.exports=t.default},function(e,t,n){"use strict";var a=n(91),m=(Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,a(n(169))),i=a(n(570)),r=a(n(170)),o=a(n(116)),b=a(n(171)),w=a(n(77)),s=a(n(366)),l=a(n(367)),g=a(n(577)),M=n(586),u={state:"",valueName:"value",trigger:"onChange",inputValues:[]},a=function(){function a(e){var t=this,n=1e.length)&&(t=e.length);for(var n=0,a=new Array(t);n=a.length?n:(o=a[r],n=e(t&&t[o],n,a,r+1),t?Array.isArray(t)?((a=[].concat(t))[o]=n,a):(0,l.default)({},t,(0,i.default)({},o,n)):((r=isNaN(o)?{}:[])[o]=n,r))};t=function(){};void 0!==e&&e.env,n.warning=t}.call(this,r(103))},function(e,t,n){"use strict";t.__esModule=!0,t.cloneAndAddKey=function(e){{var t;if(e&&(0,a.isValidElement)(e))return t=e.key||"error",(0,a.cloneElement)(e,{key:t})}return e},t.scrollToFirstError=function(e){var t=e.errorsGroup,n=e.options,a=e.instance;if(t&&n.scrollToFirstError){var r,o=void 0,i=void 0;for(r in t)if(t.hasOwnProperty(r)){var s=u.default.findDOMNode(a[r]);if(!s)return;var l=s.offsetTop;(void 0===i||l), use instead of.'),k.default.cloneElement(e,{className:t,size:d||C(r)})):(0,S.isValidElement)(e)?e:k.default.createElement("span",{className:a+"btn-helper"},e)}),t=c,_=(0,b.default)({},x.obj.pickOthers(Object.keys(T.propTypes),e),{type:o,disabled:p,onClick:h,className:(0,E.default)(n)});return"button"!==t&&(delete _.type,_.disabled)&&(delete _.onClick,_.href)&&delete _.href,k.default.createElement(t,(0,b.default)({},_,{dir:g?"rtl":void 0,onMouseUp:this.onMouseUp,ref:this.buttonRefHandler}),s,u)},a=n=T,n.propTypes=(0,b.default)({},s.default.propTypes,{prefix:r.default.string,rtl:r.default.bool,type:r.default.oneOf(["primary","secondary","normal"]),size:r.default.oneOf(["small","medium","large"]),icons:r.default.shape({loading:r.default.node}),iconSize:r.default.oneOfType([r.default.oneOf(["xxs","xs","small","medium","large","xl","xxl","xxxl","inherit"]),r.default.number]),htmlType:r.default.oneOf(["submit","reset","button"]),component:r.default.oneOf(["button","a","div","span"]),loading:r.default.bool,ghost:r.default.oneOf([!0,!1,"light","dark"]),text:r.default.bool,warning:r.default.bool,disabled:r.default.bool,onClick:r.default.func,className:r.default.string,onMouseUp:r.default.func,children:r.default.node}),n.defaultProps={prefix:"next-",type:"normal",size:"medium",icons:{},htmlType:"button",component:"button",loading:!1,ghost:!1,text:!1,warning:!1,disabled:!1,onClick:function(){}};var u,s=a;function T(){var e,t;(0,o.default)(this,T);for(var n=arguments.length,a=Array(n),r=0;ra[r])return!0;if(n[r] 0, or `null`');if(U(i,"numericSeparator")&&"boolean"!=typeof i.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var t=i.numericSeparator;if(void 0===n)return"undefined";if(null===n)return"null";if("boolean"==typeof n)return n?"true":"false";if("string"==typeof n)return function e(t,n){if(t.length>n.maxStringLength)return a=t.length-n.maxStringLength,a="... "+a+" more character"+(1"}if(z(n))return 0===n.length?"[]":(l=$(n,m),h&&!function(e){for(var t=0;t "+m(e,n))}),ne("Map",_.call(n),u,h)):function(e){if(w&&e&&"object"==typeof e)try{w.call(e);try{_.call(e)}catch(e){return 1}return e instanceof Set}catch(e){}return}(n)?(c=[],M&&M.call(n,function(e){c.push(m(e,n))}),ne("Set",w.call(n),c,h)):function(e){if(S&&e&&"object"==typeof e)try{S.call(e,S);try{k.call(e,k)}catch(e){return 1}return e instanceof WeakMap}catch(e){}return}(n)?q("WeakMap"):function(e){if(k&&e&&"object"==typeof e)try{k.call(e,k);try{S.call(e,S)}catch(e){return 1}return e instanceof WeakSet}catch(e){}return}(n)?q("WeakSet"):function(e){if(E&&e&&"object"==typeof e)try{return E.call(e),1}catch(e){}return}(n)?q("WeakRef"):"[object Number]"!==V(d=n)||j&&"object"==typeof d&&j in d?function(e){if(e&&"object"==typeof e&&D)try{return D.call(e),1}catch(e){}return}(n)?K(m(D.call(n))):"[object Boolean]"!==V(t=n)||j&&"object"==typeof t&&j in t?"[object String]"!==V(e=n)||j&&"object"==typeof e&&j in e?("[object Date]"!==V(t=n)||j&&"object"==typeof t&&j in t)&&!W(n)?(e=$(n,m),t=I?I(n)===Object.prototype:n instanceof Object||n.constructor===Object,f=n instanceof Object?"":"null prototype",p=!t&&j&&Object(n)===n&&j in n?x.call(V(n),8,-1):f?"Object":"",t=(!t&&"function"==typeof n.constructor&&n.constructor.name?n.constructor.name+" ":"")+(p||f?"["+O.call(L.call([],p||[],f||[]),": ")+"] ":""),0===e.length?t+"{}":h?t+"{"+G(e,h)+"}":t+"{ "+O.call(e,", ")+" }"):String(n):K(m(String(n))):K(J.call(n)):K(m(Number(n)))};var l=Object.prototype.hasOwnProperty||function(e){return e in this};function U(e,t){return l.call(e,t)}function V(e){return i.call(e)}function ee(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,a=e.length;nu&&!d&&(o=o.slice(0,u),e=C.default.createElement(m.default,{key:"_count",type:"primary",size:p,animation:!1},c(a,t))),0, as child."),a.push(t),e.props.children)&&(t.children=n(e.props.children))}),a}(e.children):t},N.prototype.fetchInfoFromBinaryChildren=function(e){function r(e,t){return t=t||0,e.forEach(function(e){e.children?t=r(e.children,t):t+=1}),t}var a=!1,o=[],i=[],e=(function t(){var e=0r.tRight&&(e=r.tRight,r.changedPageX=r.tRight-r.startLeft),e-r.cellLefto.clientHeight,o.scrollWidth,o.clientWidth,o={},e||(o[r]=0,o[a]=0),+i&&(o.marginBottom=-i,o.paddingBottom=i,e)&&(o[a]=i),h.dom.setStyle(this.headerNode,o)),n&&!this.props.lockType&&this.headerNode&&(r=this.headerNode.querySelector("."+t+"table-header-fixer"),e=h.dom.getStyle(this.headerNode,"height"),a=h.dom.getStyle(this.headerNode,"paddingBottom"),h.dom.setStyle(r,{width:i,height:e-a}))},o.prototype.render=function(){var e=this.props,t=e.components,n=e.className,a=e.prefix,r=e.fixedHeader,o=e.lockType,i=e.dataSource,e=(e.maxBodyHeight,(0,u.default)(e,["components","className","prefix","fixedHeader","lockType","dataSource","maxBodyHeight"]));return r&&((t=(0,l.default)({},t)).Header||(t.Header=m.default),t.Body||(t.Body=g.default),t.Wrapper||(t.Wrapper=y.default),n=(0,p.default)(((r={})[a+"table-fixed"]=!0,r[a+"table-wrap-empty"]=!i.length,r[n]=n,r))),d.default.createElement(s,(0,l.default)({},e,{dataSource:i,lockType:o,components:t,className:n,prefix:a}))},o}(d.default.Component),n.FixedHeader=m.default,n.FixedBody=g.default,n.FixedWrapper=y.default,n.propTypes=(0,l.default)({hasHeader:r.default.bool,fixedHeader:r.default.bool,maxBodyHeight:r.default.oneOfType([r.default.number,r.default.string])},s.propTypes),n.defaultProps=(0,l.default)({},s.defaultProps,{hasHeader:!0,fixedHeader:!1,maxBodyHeight:200,components:{},refs:{},prefix:"next-"}),n.childContextTypes={fixedHeader:r.default.bool,getNode:r.default.func,onFixedScrollSync:r.default.func,getTableInstanceForFixed:r.default.func,maxBodyHeight:r.default.oneOfType([r.default.number,r.default.string])};var t,n=t;return n.displayName="FixedTable",(0,o.statics)(n,s),n};var d=s(n(0)),r=s(n(5)),f=n(25),p=s(n(19)),h=n(11),m=s(n(136)),g=s(n(406)),y=s(n(137)),o=n(70);function s(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},function(e,t,n){"use strict";t.__esModule=!0;var i=o(n(17)),f=o(n(3)),r=o(n(4)),s=o(n(7)),l=o(n(8)),u=(t.default=function(o){e=t=function(n){function a(e,t){(0,r.default)(this,a);var d=(0,s.default)(this,n.call(this,e,t));return d.addSelection=function(e){var t=d.props,n=t.prefix,a=t.rowSelection,t=t.size,a=a.columnProps&&a.columnProps()||{};e.find(function(e){return"selection"===e.key})||e.unshift((0,f.default)({key:"selection",title:d.renderSelectionHeader.bind(d),cell:d.renderSelectionBody.bind(d),width:"small"===t?34:50,className:n+"table-selection "+n+"table-prerow",__normalized:!0},a))},d.renderSelectionHeader=function(){var e=d.selectAllRow,t={},n=d.props,a=n.rowSelection,r=n.primaryKey,o=n.dataSource,i=n.entireDataSource,n=n.locale,s=d.state.selectedRowKeys,l=a.mode||"multiple",u=!!s.length,c=!1,i=(d.flatDataSource(i||o).filter(function(e,t){return!a.getProps||!(a.getProps(e,t)||{}).disabled}).map(function(e){return e[r]}).forEach(function(e){-1===s.indexOf(e)?u=!1:c=!0}),t.onClick=b(function(e){e.stopPropagation()},t.onClick),a.titleProps&&a.titleProps()||{});return u&&(c=!1),["multiple"===l?p.default.createElement(h.default,(0,f.default)({key:"_total",indeterminate:c,"aria-label":n.selectAll,checked:u,onChange:e},t,i)):null,a.titleAddons&&a.titleAddons()]},d.renderSelectionBody=function(e,t,n){var a=d.props,r=a.rowSelection,a=a.primaryKey,o=d.state.selectedRowKeys,i=r.mode||"multiple",o=-1l.length&&(u=o),w(u.filter(function(e){return-1=Math.max(a-y,0)&&od.clientHeight;this.isLock()?(e=this.bodyLeftNode,t=this.bodyRightNode,n=this.getWrapperNode("right"),a=f?c:0,d=d.offsetHeight-c,f||(r[l]=0,r[u]=0),+c?(r.marginBottom=-c,r.paddingBottom=c):(r.marginBottom=-20,r.paddingBottom=20),d={"max-height":d},o||+c||(d[u]=0),+c&&(d[u]=-c),e&&g.dom.setStyle(e,d),t&&g.dom.setStyle(t,d),n&&+c&&g.dom.setStyle(n,i?"left":"right",a+"px")):(r.marginBottom=-c,r.paddingBottom=c,r[u]=0,f||(r[l]=0)),s&&g.dom.setStyle(s,r)},a.prototype.adjustHeaderSize=function(){var o=this;this.isLock()&&this.tableInc.groupChildren.forEach(function(e,t){var n=o.tableInc.groupChildren[t].length-1,n=o.getHeaderCellNode(t,n),a=o.getHeaderCellNode(t,0),r=o.getHeaderCellNode(t,0,"right"),t=o.getHeaderCellNode(t,0,"left");n&&r&&(n=n.offsetHeight,g.dom.setStyle(r,"height",n),setTimeout(function(){var e=o.tableRightInc.affixRef;return e&&e.getInstance()&&e.getInstance().updatePosition()})),a&&t&&(r=a.offsetHeight,g.dom.setStyle(t,"height",r),setTimeout(function(){var e=o.tableLeftInc.affixRef;return e&&e.getInstance()&&e.getInstance().updatePosition()}))})},a.prototype.adjustRowHeight=function(){var n=this;this.isLock()&&this.tableInc.props.dataSource.forEach(function(e,t){t=""+("object"===(void 0===e?"undefined":(0,r.default)(e))&&"__rowIndex"in e?e.__rowIndex:t)+(e.__expanded?"_expanded":"");n.setRowHeight(t,"left"),n.setRowHeight(t,"right")})},a.prototype.setRowHeight=function(e,t){var t=this.getRowNode(e,t),e=this.getRowNode(e),e=(M?e&&e.offsetHeight:e&&parseFloat(getComputedStyle(e).height))||"auto",n=(M?t&&t.offsetHeight:t&&parseFloat(getComputedStyle(t).height))||"auto";t&&e!==n&&g.dom.setStyle(t,"height",e)},a.prototype.getWrapperNode=function(e){e=e?e.charAt(0).toUpperCase()+e.substr(1):"";try{return(0,u.findDOMNode)(this["lock"+e+"El"])}catch(e){return null}},a.prototype.getRowNode=function(e,t){t=this["table"+(t=t?t.charAt(0).toUpperCase()+t.substr(1):"")+"Inc"];try{return(0,u.findDOMNode)(t.getRowRef(e))}catch(e){return null}},a.prototype.getHeaderCellNode=function(e,t,n){n=this["table"+(n=n?n.charAt(0).toUpperCase()+n.substr(1):"")+"Inc"];try{return(0,u.findDOMNode)(n.getHeaderCellRef(e,t))}catch(e){return null}},a.prototype.getCellNode=function(e,t,n){n=this["table"+(n=n?n.charAt(0).toUpperCase()+n.substr(1):"")+"Inc"];try{return(0,u.findDOMNode)(n.getCellRef(e,t))}catch(e){return null}},a.prototype.render=function(){var e,t=this.props,n=(t.children,t.columns,t.prefix),a=t.components,r=t.className,o=t.dataSource,i=t.tableWidth,t=(0,f.default)(t,["children","columns","prefix","components","className","dataSource","tableWidth"]),s=this.normalizeChildrenState(this.props),l=s.lockLeftChildren,u=s.lockRightChildren,s=s.children,c={left:this.getFlatenChildrenLength(l),right:this.getFlatenChildrenLength(u),origin:this.getFlatenChildrenLength(s)};return this._notNeedAdjustLockLeft&&(l=[]),this._notNeedAdjustLockRight&&(u=[]),this.lockLeftChildren=l,this.lockRightChildren=u,this.isOriginLock()?((a=(0,p.default)({},a)).Body=a.Body||v.default,a.Header=a.Header||_.default,a.Wrapper=a.Wrapper||b.default,a.Row=a.Row||y.default,r=(0,m.default)(((e={})[n+"table-lock"]=!0,e[n+"table-wrap-empty"]=!o.length,e[r]=r,e)),e=[h.default.createElement(d,(0,p.default)({},t,{dataSource:o,key:"lock-left",columns:l,className:n+"table-lock-left",lengths:c,prefix:n,lockType:"left",components:a,ref:this.saveLockLeftRef,loading:!1,"aria-hidden":!0})),h.default.createElement(d,(0,p.default)({},t,{dataSource:o,key:"lock-right",columns:u,className:n+"table-lock-right",lengths:c,prefix:n,lockType:"right",components:a,ref:this.saveLockRightRef,loading:!1,"aria-hidden":!0}))],h.default.createElement(d,(0,p.default)({},t,{tableWidth:i,dataSource:o,columns:s,prefix:n,lengths:c,wrapperContent:e,components:a,className:r}))):h.default.createElement(d,this.props)},a}(h.default.Component),t.LockRow=y.default,t.LockBody=v.default,t.LockHeader=_.default,t.propTypes=(0,p.default)({scrollToCol:a.default.number,scrollToRow:a.default.number},d.propTypes),t.defaultProps=(0,p.default)({},d.defaultProps),t.childContextTypes={getTableInstance:a.default.func,getLockNode:a.default.func,onLockBodyScroll:a.default.func,onRowMouseEnter:a.default.func,onRowMouseLeave:a.default.func};var e,t=e;return t.displayName="LockTable",(0,w.statics)(t,d),t},n(0)),h=d(l),u=n(25),a=d(n(5)),m=d(n(19)),c=d(n(182)),g=n(11),y=d(n(184)),v=d(n(407)),_=d(n(408)),b=d(n(137)),w=n(70);function d(e){return e&&e.__esModule?e:{default:e}}var M=g.env.ieVersion;function S(e){return function n(e){return e.map(function(e){var t=(0,p.default)({},e);return e.children&&(e.children=n(e.children)),t})}(e)}e.exports=t.default},function(e,t,n){"use strict";t.__esModule=!0;var l=s(n(17)),u=s(n(3)),r=s(n(4)),o=s(n(7)),i=s(n(8)),c=(t.default=function(s){e=t=function(n){function a(e,t){(0,r.default)(this,a);var c=(0,o.default)(this,n.call(this,e));return c.state={},c.updateOffsetArr=function(){var e=c.splitChildren||{},t=e.lockLeftChildren,n=e.lockRightChildren,e=e.originChildren,a=c.getFlatenChildren(t).length,r=c.getFlatenChildren(n).length,e=a+r+c.getFlatenChildren(e).length,a=0r.top-e.offset?(t?(l.position="absolute",l.top=a-(r.top-e.offset),u="relative"):(l.position="fixed",l.top=e.offset+n.top),c._setAffixStyle(l,!0),c._setContainerStyle(s)):e.bottom&&a{e=new Date(e);if(isNaN(e))throw new TypeError("Invalid Datetime");return e}},function(e,t,n){"use strict";const a=n(186);class r extends Date{constructor(e){super(e+"Z"),this.isFloating=!0}toISOString(){return`${this.getUTCFullYear()}-${a(2,this.getUTCMonth()+1)}-`+a(2,this.getUTCDate())+"T"+(`${a(2,this.getUTCHours())}:${a(2,this.getUTCMinutes())}:${a(2,this.getUTCSeconds())}.`+a(3,this.getUTCMilliseconds()))}}e.exports=e=>{e=new r(e);if(isNaN(e))throw new TypeError("Invalid Datetime");return e}},function(a,e,r){"use strict";!function(e){const t=r(186);class n extends e.Date{constructor(e){super(e),this.isDate=!0}toISOString(){return`${this.getUTCFullYear()}-${t(2,this.getUTCMonth()+1)}-`+t(2,this.getUTCDate())}}a.exports=e=>{e=new n(e);if(isNaN(e))throw new TypeError("Invalid Datetime");return e}}.call(this,r(65))},function(e,t,n){"use strict";const a=n(186);class r extends Date{constructor(e){super(`0000-01-01T${e}Z`),this.isTime=!0}toISOString(){return`${a(2,this.getUTCHours())}:${a(2,this.getUTCMinutes())}:${a(2,this.getUTCSeconds())}.`+a(3,this.getUTCMilliseconds())}}e.exports=e=>{e=new r(e);if(isNaN(e))throw new TypeError("Invalid Datetime");return e}},function(e,t,n){"use strict";!function(s){e.exports=function(r,e){e=e||{};const n=e.blocksize||40960,o=new t;return new Promise((e,t)=>{s(i,0,n,e,t)});function i(e,t,n,a){if(e>=r.length)try{return n(o.finish())}catch(e){return a(l(e,r))}try{o.parse(r.slice(e,e+t)),s(i,e+t,t,n,a)}catch(e){a(l(e,r))}}};const t=n(185),l=n(187)}.call(this,n(412).setImmediate)},function(e,t,n){!function(e,p){!function(n,o){"use strict";var a,i,s,r,l,u,t,e;function c(e){delete i[e]}function d(e){if(s)setTimeout(d,0,e);else{var t=i[e];if(t){s=!0;try{var n=t,a=n.callback,r=n.args;switch(r.length){case 0:a();break;case 1:a(r[0]);break;case 2:a(r[0],r[1]);break;case 3:a(r[0],r[1],r[2]);break;default:a.apply(o,r)}}finally{c(e),s=!1}}}}function f(){function e(e){e.source===n&&"string"==typeof e.data&&0===e.data.indexOf(t)&&d(+e.data.slice(t.length))}var t="setImmediate$"+Math.random()+"$";n.addEventListener?n.addEventListener("message",e,!1):n.attachEvent("onmessage",e),l=function(e){n.postMessage(t+e,"*")}}n.setImmediate||(a=1,s=!(i={}),r=n.document,e=(e=Object.getPrototypeOf&&Object.getPrototypeOf(n))&&e.setTimeout?e:n,"[object process]"==={}.toString.call(n.process)?l=function(e){p.nextTick(function(){d(e)})}:!function(){var e,t;if(n.postMessage&&!n.importScripts)return e=!0,t=n.onmessage,n.onmessage=function(){e=!1},n.postMessage("","*"),n.onmessage=t,e}()?l=n.MessageChannel?((t=new MessageChannel).port1.onmessage=function(e){d(e.data)},function(e){t.port2.postMessage(e)}):r&&"onreadystatechange"in r.createElement("script")?(u=r.documentElement,function(e){var t=r.createElement("script");t.onreadystatechange=function(){d(e),t.onreadystatechange=null,u.removeChild(t),t=null},u.appendChild(t)}):function(e){setTimeout(d,0,e)}:f(),e.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n{let n,a=!1,r=!1;function o(){if(a=!0,!n)try{e(l.finish())}catch(e){t(e)}}function i(e){r=!0,t(e)}s.once("end",o),s.once("error",i),function e(){n=!0;let t;for(;null!==(t=s.read());)try{l.parse(t)}catch(e){return i(e)}n=!1;if(a)return o();if(r)return;s.once("readable",e)}()})}(e):function(){const a=new o;return new r.Transform({objectMode:!0,transform(e,t,n){try{a.parse(e.toString(t))}catch(e){this.emit("error",e)}n()},flush(e){try{this.push(a.finish())}catch(e){this.emit("error",e)}e()}})}()};const r=n(704),o=n(185)},function(e,t,n){e.exports=a;var c=n(188).EventEmitter;function a(){c.call(this)}n(105)(a,c),a.Readable=n(189),a.Writable=n(714),a.Duplex=n(715),a.Transform=n(716),a.PassThrough=n(717),(a.Stream=a).prototype.pipe=function(t,e){var n=this;function a(e){t.writable&&!1===t.write(e)&&n.pause&&n.pause()}function r(){n.readable&&n.resume&&n.resume()}n.on("data",a),t.on("drain",r),t._isStdio||e&&!1===e.end||(n.on("end",i),n.on("close",s));var o=!1;function i(){o||(o=!0,t.end())}function s(){o||(o=!0,"function"==typeof t.destroy&&t.destroy())}function l(e){if(u(),0===c.listenerCount(this,"error"))throw e}function u(){n.removeListener("data",a),t.removeListener("drain",r),n.removeListener("end",i),n.removeListener("close",s),n.removeListener("error",l),t.removeListener("error",l),n.removeListener("end",u),n.removeListener("close",u),t.removeListener("close",u)}return n.on("error",l),t.on("error",l),n.on("end",u),n.on("close",u),t.on("close",u),t.emit("pipe",n),t}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t,n){"use strict";t.byteLength=function(e){var e=c(e),t=e[0],e=e[1];return 3*(t+e)/4-e},t.toByteArray=function(e){var t,n,a=c(e),r=a[0],a=a[1],o=new u(function(e,t){return 3*(e+t)/4-t}(r,a)),i=0,s=0>16&255,o[i++]=t>>8&255,o[i++]=255&t;2===a&&(t=l[e.charCodeAt(n)]<<2|l[e.charCodeAt(n+1)]>>4,o[i++]=255&t);1===a&&(t=l[e.charCodeAt(n)]<<10|l[e.charCodeAt(n+1)]<<4|l[e.charCodeAt(n+2)]>>2,o[i++]=t>>8&255,o[i++]=255&t);return o},t.fromByteArray=function(e){for(var t,n=e.length,a=n%3,r=[],o=0,i=n-a;o>18&63]+s[e>>12&63]+s[e>>6&63]+s[63&e]}(a));return r.join("")}(e,o,i>2]+s[t<<4&63]+"==")):2==a&&(t=(e[n-2]<<8)+e[n-1],r.push(s[t>>10]+s[t>>4&63]+s[t<<2&63]+"="));return r.join("")};for(var s=[],l=[],u="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,o=a.length;r=e.length?{value:void 0,done:!0}:(e=a(e,t),this._i+=e.length,{value:e,done:!1})})},function(e,t,n){var o=n(153),i=n(152);e.exports=function(r){return function(e,t){var n,e=String(i(e)),t=o(t),a=e.length;return t<0||a<=t?r?"":void 0:(n=e.charCodeAt(t))<55296||56319=e.length?(this._t=void 0,r(1)):r(0,"keys"==t?n:"values"==t?e[n]:[n,e[n]])},"values"),o.Arguments=o.Array,a("keys"),a("values"),a("entries")},function(e,t){e.exports=function(){}},function(e,t){e.exports=function(e,t){return{value:t,done:!!e}}},function(e,t,n){e.exports={default:n(500),__esModule:!0}},function(e,t,n){n(501),n(506),n(507),n(508),e.exports=n(81).Symbol},function(I,A,e){"use strict";function a(e){var t=T[e]=_(M[E]);return t._k=e,t}function n(e,t){m(e);for(var n,a=B(t=g(t)),r=0,o=a.length;rr;)l(T,t=n[r++])||t==x||t==H||a.push(t);return a}function i(e){for(var t,n=e===O,a=X(n?L:g(e)),r=[],o=0;a.length>o;)!l(T,t=a[o++])||n&&!l(O,t)||r.push(T[t]);return r}var s=e(80),l=e(90),u=e(82),c=e(96),R=e(211),H=e(502).KEY,d=e(113),f=e(155),p=e(161),F=e(129),h=e(100),z=e(162),W=e(163),B=e(503),U=e(504),m=e(112),V=e(98),K=e(158),g=e(99),y=e(151),v=e(126),_=e(160),q=e(505),G=e(213),b=e(157),$=e(89),J=e(127),Q=G.f,w=$.f,X=q.f,M=s.Symbol,S=s.JSON,k=S&&S.stringify,E="prototype",x=h("_hidden"),Z=h("toPrimitive"),ee={}.propertyIsEnumerable,C=f("symbol-registry"),T=f("symbols"),L=f("op-symbols"),O=Object[E],f="function"==typeof M&&!!b.f,D=s.QObject,N=!D||!D[E]||!D[E].findChild,P=u&&d(function(){return 7!=_(w({},"a",{get:function(){return w(this,"a",{value:7}).a}})).a})?function(e,t,n){var a=Q(O,t);a&&delete O[t],w(e,t,n),a&&e!==O&&w(O,t,a)}:w,j=f&&"symbol"==typeof M.iterator?function(e){return"symbol"==typeof e}:function(e){return e instanceof M},Y=function(e,t,n){return e===O&&Y(L,t,n),m(e),t=y(t,!0),m(n),(l(T,t)?(n.enumerable?(l(e,x)&&e[x][t]&&(e[x][t]=!1),n=_(n,{enumerable:v(0,!1)})):(l(e,x)||w(e,x,v(1,{})),e[x][t]=!0),P):w)(e,t,n)};f||(R((M=function(){if(this instanceof M)throw TypeError("Symbol is not a constructor!");var t=F(0ne;)h(te[ne++]);for(var ae=J(h.store),re=0;ae.length>re;)W(ae[re++]);c(c.S+c.F*!f,"Symbol",{for:function(e){return l(C,e+="")?C[e]:C[e]=M(e)},keyFor:function(e){if(!j(e))throw TypeError(e+" is not a symbol!");for(var t in C)if(C[t]===e)return t},useSetter:function(){N=!0},useSimple:function(){N=!1}}),c(c.S+c.F*!f,"Object",{create:function(e,t){return void 0===t?_(e):n(_(e),t)},defineProperty:Y,defineProperties:n,getOwnPropertyDescriptor:r,getOwnPropertyNames:o,getOwnPropertySymbols:i});D=d(function(){b.f(1)});c(c.S+c.F*D,"Object",{getOwnPropertySymbols:function(e){return b.f(K(e))}}),S&&c(c.S+c.F*(!f||d(function(){var e=M();return"[null]"!=k([e])||"{}"!=k({a:e})||"{}"!=k(Object(e))})),"JSON",{stringify:function(e){for(var t,n,a=[e],r=1;ri;)o.call(e,a=r[i++])&&t.push(a);return t}},function(e,t,n){var a=n(209);e.exports=Array.isArray||function(e){return"Array"==a(e)}},function(e,t,n){var a=n(99),r=n(212).f,o={}.toString,i="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];e.exports.f=function(e){if(!i||"[object Window]"!=o.call(e))return r(a(e));try{return r(e)}catch(e){return i.slice()}}},function(e,t){},function(e,t,n){n(163)("asyncIterator")},function(e,t,n){n(163)("observable")},function(e,t,n){e.exports={default:n(510),__esModule:!0}},function(e,t,n){n(511),e.exports=n(81).Object.setPrototypeOf},function(e,t,n){var a=n(96);a(a.S,"Object",{setPrototypeOf:n(512).set})},function(e,t,r){function o(e,t){if(a(e),!n(t)&&null!==t)throw TypeError(t+": can't set as prototype!")}var n=r(98),a=r(112);e.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(e,n,a){try{(a=r(204)(Function.call,r(213).f(Object.prototype,"__proto__").set,2))(e,[]),n=!(e instanceof Array)}catch(e){n=!0}return function(e,t){return o(e,t),n?e.__proto__=t:a(e,t),e}}({},!1):void 0),check:o}},function(e,t,n){e.exports={default:n(514),__esModule:!0}},function(e,t,n){n(515);var a=n(81).Object;e.exports=function(e,t){return a.create(e,t)}},function(e,t,n){var a=n(96);a(a.S,"Object",{create:n(160)})},function(e,t,n){"use strict";var i=n(517);function a(){}function r(){}r.resetWarningCache=a,e.exports=function(){function e(e,t,n,a,r,o){if(o!==i)throw(o=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")).name="Invariant Violation",o}function t(){return e}var n={array:e.isRequired=e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:r,resetWarningCache:a};return n.PropTypes=n}},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,n){"use strict";function l(e,t,n,a){e.removeEventListener&&e.removeEventListener(t,n,a||!1)}function a(e,t,n,a){return e.addEventListener&&e.addEventListener(t,n,a||!1),{off:function(){return l(e,t,n,a)}}}t.__esModule=!0,t.on=a,t.once=function(r,o,i,s){return a(r,o,function e(){for(var t=arguments.length,n=Array(t),a=0;a68?1900:2e3)},r=function(t){return function(e){this[t]=+e}},o=[/[+-]\d\d:?(\d\d)?|Z/,function(e){(this.zone||(this.zone={})).offset=function(e){if(!e)return 0;if("Z"===e)return 0;var t=e.match(/([+-]|\d\d)/g),n=60*t[1]+(+t[2]||0);return 0===n?0:"+"===t[0]?-n:n}(e)}],i=function(e){var t=h[e];return t&&(t.indexOf?t:t.s.concat(t.f))},s=function(e,t){var n,a=h.meridiem;if(a){for(var r=1;r<=24;r+=1)if(e.indexOf(a(r,0,t))>-1){n=r>12;break}}else n=e===(t?"pm":"PM");return n},f={A:[n,function(e){this.afternoon=s(e,!1)}],a:[n,function(e){this.afternoon=s(e,!0)}],S:[/\d/,function(e){this.milliseconds=100*+e}],SS:[e,function(e){this.milliseconds=10*+e}],SSS:[/\d{3}/,function(e){this.milliseconds=+e}],s:[t,r("seconds")],ss:[t,r("seconds")],m:[t,r("minutes")],mm:[t,r("minutes")],H:[t,r("hours")],h:[t,r("hours")],HH:[t,r("hours")],hh:[t,r("hours")],D:[t,r("day")],DD:[e,r("day")],Do:[n,function(e){var t=h.ordinal,n=e.match(/\d+/);if(this.day=n[0],t)for(var a=1;a<=31;a+=1)t(a).replace(/\[|\]/g,"")===e&&(this.day=a)}],M:[t,r("month")],MM:[e,r("month")],MMM:[n,function(e){var t=i("months"),n=(i("monthsShort")||t.map(function(e){return e.slice(0,3)})).indexOf(e)+1;if(n<1)throw new Error;this.month=n%12||n}],MMMM:[n,function(e){var t=i("months").indexOf(e)+1;if(t<1)throw new Error;this.month=t%12||t}],Y:[/[+-]?\d+/,r("year")],YY:[e,function(e){this.year=a(e)}],YYYY:[/\d{4}/,r("year")],Z:o,ZZ:o};function b(e){var t,r;t=e,r=h&&h.formats;for(var u=(e=t.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(e,t,n){var a=n&&n.toUpperCase();return t||r[n]||l[n]||r[a].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(e,t,n){return t||n.slice(1)})})).match(d),c=u.length,n=0;n-1)return new Date(("X"===t?1e3:1)*e);var a=b(t)(e),r=a.year,o=a.month,i=a.day,s=a.hours,l=a.minutes,u=a.seconds,c=a.milliseconds,d=a.zone,f=new Date,p=i||(r||o?1:f.getDate()),h=r||f.getFullYear(),m=0;r&&!o||(m=o>0?o-1:f.getMonth());var g=s||0,y=l||0,v=u||0,_=c||0;return d?new Date(Date.UTC(h,m,p,g,y,v,_+60*d.offset*1e3)):n?new Date(Date.UTC(h,m,p,g,y,v,_)):new Date(h,m,p,g,y,v,_)}catch(e){return new Date("")}}(t,r,n),this.init(),l&&!0!==l&&(this.$L=this.locale(l).$L),s&&t!=this.format(r)&&(this.$d=new Date("")),h={}}else if(r instanceof Array)for(var u=r.length,c=1;c<=u;c+=1){a[1]=r[c-1];var d=f.apply(this,a);if(d.isValid()){this.$d=d.$d,this.$L=d.$L,this.init();break}c===u&&(this.$d=new Date(""))}else p.call(this,e)}}}()},function(e,t,n){e.exports=function(){"use strict";return function(e,t,a){a.updateLocale=function(e,t){var n=a.Ls[e];if(n)return(t?Object.keys(t):[]).forEach(function(e){n[e]=t[e]}),n}}}()},function(e,t,n){e.exports=function(e,t,n){function a(e,t,n,a,r){var o,e=e.name?e:e.$locale(),t=s(e[t]),n=s(e[n]),i=t||n.map(function(e){return e.slice(0,a)});return r?(o=e.weekStart,i.map(function(e,t){return i[(t+(o||0))%7]})):i}function r(){return n.Ls[n.locale()]}function o(e,t){return e.formats[t]||e.formats[t.toUpperCase()].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(e,t,n){return t||n.slice(1)})}var t=t.prototype,s=function(e){return e&&(e.indexOf?e:e.s)};t.localeData=function(){return function(){var t=this;return{months:function(e){return e?e.format("MMMM"):a(t,"months")},monthsShort:function(e){return e?e.format("MMM"):a(t,"monthsShort","months",3)},firstDayOfWeek:function(){return t.$locale().weekStart||0},weekdays:function(e){return e?e.format("dddd"):a(t,"weekdays")},weekdaysMin:function(e){return e?e.format("dd"):a(t,"weekdaysMin","weekdays",2)},weekdaysShort:function(e){return e?e.format("ddd"):a(t,"weekdaysShort","weekdays",3)},longDateFormat:function(e){return o(t.$locale(),e)},meridiem:this.$locale().meridiem,ordinal:this.$locale().ordinal}}.bind(this)()},n.localeData=function(){var t=r();return{firstDayOfWeek:function(){return t.weekStart||0},weekdays:function(){return n.weekdays()},weekdaysShort:function(){return n.weekdaysShort()},weekdaysMin:function(){return n.weekdaysMin()},months:function(){return n.months()},monthsShort:function(){return n.monthsShort()},longDateFormat:function(e){return o(t,e)},meridiem:t.meridiem,ordinal:t.ordinal}},n.months=function(){return a(r(),"months")},n.monthsShort=function(){return a(r(),"monthsShort","months",3)},n.weekdays=function(e){return a(r(),"weekdays",null,null,e)},n.weekdaysShort=function(e){return a(r(),"weekdaysShort","weekdays",3,e)},n.weekdaysMin=function(e){return a(r(),"weekdaysMin","weekdays",2,e)}}},function(e,t,n){e.exports=function(){"use strict";var i="month",s="quarter";return function(e,t){var n=t.prototype;n.quarter=function(e){return this.$utils().u(e)?Math.ceil((this.month()+1)/3):this.month(this.month()%3+3*(e-1))};var a=n.add;n.add=function(e,t){return e=Number(e),this.$utils().p(t)===s?this.add(3*e,i):a.bind(this)(e,t)};var o=n.startOf;n.startOf=function(e,t){var n=this.$utils(),a=!!n.u(t)||t;if(n.p(e)===s){var r=this.quarter()-1;return a?this.month(3*r).startOf(i).startOf("day"):this.month(3*r+2).endOf(i).endOf("day")}return o.bind(this)(e,t)}}}()},function(e,t,n){e.exports=function(){"use strict";return function(e,t){var n=t.prototype,o=n.format;n.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return o.bind(this)(e);var a=this.$utils(),r=(e||"YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,function(e){switch(e){case"Q":return Math.ceil((t.$M+1)/3);case"Do":return n.ordinal(t.$D);case"gggg":return t.weekYear();case"GGGG":return t.isoWeekYear();case"wo":return n.ordinal(t.week(),"W");case"w":case"ww":return a.s(t.week(),"w"===e?1:2,"0");case"W":case"WW":return a.s(t.isoWeek(),"W"===e?1:2,"0");case"k":case"kk":return a.s(String(0===t.$H?24:t.$H),"k"===e?1:2,"0");case"X":return Math.floor(t.$d.getTime()/1e3);case"x":return t.$d.getTime();case"z":return"["+t.offsetName()+"]";case"zzz":return"["+t.offsetName("long")+"]";default:return e}});return o.bind(this)(r)}}}()},function(e,t,n){e.exports=function(){"use strict";var s="week",l="year";return function(e,t,i){var n=t.prototype;n.week=function(e){if(void 0===e&&(e=null),null!==e)return this.add(7*(e-this.week()),"day");var t=this.$locale().yearStart||1;if(11===this.month()&&this.date()>25){var n=i(this).startOf(l).add(1,l).date(t),a=i(this).endOf(s);if(n.isBefore(a))return 1}var r=i(this).startOf(l).date(t).startOf(s).subtract(1,"millisecond"),o=this.diff(r,s,!0);return o<0?i(this).startOf("week").week():Math.ceil(o)},n.weeks=function(e){return void 0===e&&(e=null),this.week(e)}}}()},function(e,t,n){e.exports=function(e){"use strict";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(e),a={name:"zh-cn",weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"周日_周一_周二_周三_周四_周五_周六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(e,t){return"W"===t?e+"周":e+"日"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日Ah点mm分",LLLL:"YYYY年M月D日ddddAh点mm分",l:"YYYY/M/D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s内",past:"%s前",s:"几秒",m:"1 分钟",mm:"%d 分钟",h:"1 小时",hh:"%d 小时",d:"1 天",dd:"%d 天",M:"1 个月",MM:"%d 个月",y:"1 年",yy:"%d 年"},meridiem:function(e,t){var n=100*e+t;return n<600?"凌晨":n<900?"早上":n<1100?"上午":n<1300?"中午":n<1800?"下午":"晚上"}};return n.default.locale(a,null,!0),a}(n(219))},function(e,t,n){"use strict";t.__esModule=!0,t.flex=t.transition=t.animation=void 0;var r=n(215),o=n(101);function a(e){var n,a;return!!r.hasDOM&&(n=document.createElement("div"),(a=!1,o.each)(e,function(e,t){if(void 0!==n.style[t])return!(a={end:e})}),a)}var i,s;t.animation=a({WebkitAnimation:"webkitAnimationEnd",OAnimation:"oAnimationEnd",animation:"animationend"}),t.transition=a({WebkitTransition:"webkitTransitionEnd",OTransition:"oTransitionEnd",transition:"transitionend"}),t.flex=(n={display:["flex","-webkit-flex","-moz-flex","-ms-flexbox"]},!!r.hasDOM&&(i=document.createElement("div"),(s=!1,o.each)(n,function(e,t){return(0,o.each)(e,function(e){try{i.style[t]=e,s=s||i.style[t]===e}catch(e){}return!s}),!s}),s))},function(e,t,n){"use strict";t.__esModule=!0,t.getFocusNodeList=i,t.saveLastFocusNode=function(){s=document.activeElement},t.clearLastFocusNode=function(){s=null},t.backLastFocusNode=function(){if(s)try{s.focus()}catch(e){}},t.limitTabRange=function(e,t){{var n,a;t.keyCode===r.default.TAB&&(e=i(e),n=e.length-1,-1<(a=e.indexOf(document.activeElement)))&&(a=a+(t.shiftKey?-1:1),e[a=n<(a=a<0?n:a)?0:a].focus(),t.preventDefault())}};var t=n(220),r=(t=t)&&t.__esModule?t:{default:t},a=n(101);function o(e){var t=e.nodeName.toLowerCase(),n=parseInt(e.getAttribute("tabindex"),10),n=!isNaN(n)&&-1a.height)&&(r[1]=-t.top-("t"===e?t.height:0)),r},this._getParentScrollOffset=function(e){var t=0,n=0;return e&&e.offsetParent&&e.offsetParent!==document.body&&(isNaN(e.offsetParent.scrollTop)||(t+=e.offsetParent.scrollTop),isNaN(e.offsetParent.scrollLeft)||(n+=e.offsetParent.scrollLeft)),{top:t,left:n}}};var p=a;function h(e){(0,o.default)(this,h),r.call(this),this.pinElement=e.pinElement,this.baseElement=e.baseElement,this.pinFollowBaseElementWhenFixed=e.pinFollowBaseElementWhenFixed,this.container=function(e){var t=e.container,e=e.baseElement;if("undefined"==typeof document)return t;for(var n=(n=(0,i.default)(t,e))||document.body;"static"===y.dom.getStyle(n,"position");){if(!n||n===document.body)return document.body;n=n.parentNode}return n}(e),this.autoFit=e.autoFit||!1,this.align=e.align||"tl tl",this.offset=e.offset||[0,0],this.needAdjust=e.needAdjust||!1,this.isRtl=e.isRtl||!1}t.default=p,e.exports=t.default},function(e,t,n){"use strict";t.__esModule=!0;var w=a(n(3)),M=a(n(17)),S=n(0),k=a(S),E=a(n(19)),x=a(n(196)),C=a(n(83)),T=n(11);function a(e){return e&&e.__esModule?e:{default:e}}t.default=function(e){var t,n,a,r,o,i,s,l,u,c,d,f,p,h,m,g,y,v,_,b;return S.useState&&S.useRef&&S.useEffect?(t=void 0===(t=e.prefix)?"next-":t,r=e.animation,n=void 0===r?{in:"expandInDown",out:"expandOutUp"}:r,a=e.visible,r=e.hasMask,o=e.align,o=void 0===(s=e.points)?o?o.split(" "):void 0:s,i=e.onPosition,s=e.children,b=e.className,l=e.style,u=e.wrapperClassName,c=e.beforeOpen,d=e.onOpen,f=e.afterOpen,p=e.beforeClose,h=e.onClose,m=e.afterClose,e=(0,M.default)(e,["prefix","animation","visible","hasMask","align","points","onPosition","children","className","style","wrapperClassName","beforeOpen","onOpen","afterOpen","beforeClose","onClose","afterClose"]),g=(_=(0,S.useState)(!0))[0],y=_[1],v=(0,S.useRef)(null),_=k.default.createElement(C.default.OverlayAnimate,{visible:a,animation:n,onEnter:function(){y(!1),"function"==typeof c&&c(v.current)},onEntering:function(){"function"==typeof d&&d(v.current)},onEntered:function(){"function"==typeof f&&f(v.current)},onExit:function(){"function"==typeof p&&p(v.current)},onExiting:function(){"function"==typeof h&&h(v.current)},onExited:function(){y(!0),"function"==typeof m&&m(v.current)},timeout:300,style:l},s?(0,S.cloneElement)(s,{className:(0,E.default)([t+"overlay-inner",b,s&&s.props&&s.props.className])}):k.default.createElement("span",null)),b=(0,E.default)(((l={})[t+"overlay-wrapper v2"]=!0,l[u]=u,l.opened=a,l)),k.default.createElement(x.default,(0,w.default)({},e,{visible:a,isAnimationEnd:g,hasMask:r,wrapperClassName:b,maskClassName:t+"overlay-backdrop",maskRender:function(e){return k.default.createElement(C.default.OverlayAnimate,{visible:a,animation:!!n&&{in:"fadeIn",out:"fadeOut"},timeout:300,unmountOnExit:!0},e)},points:o,onPosition:function(e){(0,w.default)(e,{align:e.config.points}),"function"==typeof i&&i(e)},ref:v}),_)):(T.log.warning("need react version > 16.8.0"),null)},e.exports=t.default},function(n,e){function a(e,t){return n.exports=a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},n.exports.__esModule=!0,n.exports.default=n.exports,a(e,t)}n.exports=a,n.exports.__esModule=!0,n.exports.default=n.exports},function(e,t,n){"use strict";t.__esModule=!0;var a,c=g(n(17)),d=g(n(3)),r=g(n(4)),o=g(n(7)),i=g(n(8)),l=n(0),f=g(l),p=n(25),s=n(31),u=g(n(5)),h=n(11),m=g(n(362));function g(e){return e&&e.__esModule?e:{default:e}}var y,n=h.func.noop,v=h.func.makeChain,_=h.func.bindCtx,u=(y=l.Component,(0,i.default)(b,y),b.getDerivedStateFromProps=function(e,t){return"visible"in e?(0,d.default)({},t,{visible:e.visible}):null},b.prototype.componentWillUnmount=function(){var t=this;["_timer","_hideTimer","_showTimer"].forEach(function(e){t[e]&&clearTimeout(t[e])})},b.prototype.handleVisibleChange=function(e,t,n){"visible"in this.props||this.setState({visible:e}),this.props.onVisibleChange(e,t,n)},b.prototype.handleTriggerClick=function(e){this.state.visible&&!this.props.canCloseByTrigger||this.handleVisibleChange(!this.state.visible,"fromTrigger",e)},b.prototype.handleTriggerKeyDown=function(e){var t=this.props.triggerClickKeycode;(Array.isArray(t)?t:[t]).includes(e.keyCode)&&(e.preventDefault(),this.handleTriggerClick(e))},b.prototype.handleTriggerMouseEnter=function(e){var t=this;this._mouseNotFirstOnMask=!1,this._hideTimer&&(clearTimeout(this._hideTimer),this._hideTimer=null),this._showTimer&&(clearTimeout(this._showTimer),this._showTimer=null),this.state.visible||(this._showTimer=setTimeout(function(){t.handleVisibleChange(!0,"fromTrigger",e)},this.props.delay))},b.prototype.handleTriggerMouseLeave=function(e,t){var n=this;this._showTimer&&(clearTimeout(this._showTimer),this._showTimer=null),this.state.visible&&(this._hideTimer=setTimeout(function(){n.handleVisibleChange(!1,t||"fromTrigger",e)},this.props.delay))},b.prototype.handleTriggerFocus=function(e){this.handleVisibleChange(!0,"fromTrigger",e)},b.prototype.handleTriggerBlur=function(e){this._isForwardContent||this.handleVisibleChange(!1,"fromTrigger",e),this._isForwardContent=!1},b.prototype.handleContentMouseDown=function(){this._isForwardContent=!0},b.prototype.handleContentMouseEnter=function(){clearTimeout(this._hideTimer)},b.prototype.handleContentMouseLeave=function(e){this.handleTriggerMouseLeave(e,"fromContent")},b.prototype.handleMaskMouseEnter=function(){this._mouseNotFirstOnMask||(clearTimeout(this._hideTimer),this._hideTimer=null,this._mouseNotFirstOnMask=!1)},b.prototype.handleMaskMouseLeave=function(){this._mouseNotFirstOnMask=!0},b.prototype.handleRequestClose=function(e,t){this.handleVisibleChange(!1,e,t)},b.prototype.renderTrigger=function(){var e,t,n,a,r,o,i,s=this,l=this.props,u=l.trigger,l=l.disabled,c={key:"trigger","aria-haspopup":!0,"aria-expanded":this.state.visible};return this.state.visible||(c["aria-describedby"]=void 0),l||(l=this.props.triggerType,l=Array.isArray(l)?l:[l],e=u&&u.props||{},t=e.onClick,n=e.onKeyDown,a=e.onMouseEnter,r=e.onMouseLeave,o=e.onFocus,i=e.onBlur,l.forEach(function(e){switch(e){case"click":c.onClick=v(s.handleTriggerClick,t),c.onKeyDown=v(s.handleTriggerKeyDown,n);break;case"hover":c.onMouseEnter=v(s.handleTriggerMouseEnter,a),c.onMouseLeave=v(s.handleTriggerMouseLeave,r);break;case"focus":c.onFocus=v(s.handleTriggerFocus,o),c.onBlur=v(s.handleTriggerBlur,i)}})),u&&f.default.cloneElement(u,c)},b.prototype.renderContent=function(){var t=this,e=this.props,n=e.children,e=e.triggerType,e=Array.isArray(e)?e:[e],n=l.Children.only(n),a=n.props,r=a.onMouseDown,o=a.onMouseEnter,i=a.onMouseLeave,s={key:"portal"};return e.forEach(function(e){switch(e){case"focus":s.onMouseDown=v(t.handleContentMouseDown,r);break;case"hover":s.onMouseEnter=v(t.handleContentMouseEnter,o),s.onMouseLeave=v(t.handleContentMouseLeave,i)}}),f.default.cloneElement(n,s)},b.prototype.renderPortal=function(){function e(){return(0,p.findDOMNode)(t)}var t=this,n=this.props,a=n.target,r=n.safeNode,o=n.followTrigger,i=n.triggerType,s=n.hasMask,l=n.wrapperStyle,n=(0,c.default)(n,["target","safeNode","followTrigger","triggerType","hasMask","wrapperStyle"]),u=this.props.container,r=Array.isArray(r)?[].concat(r):[r],l=(r.unshift(e),l||{});return o&&(u=function(e){return e&&e.parentNode||e},l.position="relative"),"hover"===i&&s&&(n.onMaskMouseEnter=this.handleMaskMouseEnter,n.onMaskMouseLeave=this.handleMaskMouseLeave),f.default.createElement(m.default,(0,d.default)({},n,{key:"overlay",ref:function(e){return t.overlay=e},visible:this.state.visible,target:a||e,container:u,safeNode:r,wrapperStyle:l,triggerType:i,hasMask:s,onRequestClose:this.handleRequestClose}),this.props.children&&this.renderContent())},b.prototype.render=function(){return[this.renderTrigger(),this.renderPortal()]},a=i=b,i.propTypes={children:u.default.node,trigger:u.default.element,triggerType:u.default.oneOfType([u.default.string,u.default.array]),triggerClickKeycode:u.default.oneOfType([u.default.number,u.default.array]),visible:u.default.bool,defaultVisible:u.default.bool,onVisibleChange:u.default.func,disabled:u.default.bool,autoFit:u.default.bool,delay:u.default.number,canCloseByTrigger:u.default.bool,target:u.default.any,safeNode:u.default.any,followTrigger:u.default.bool,container:u.default.any,hasMask:u.default.bool,wrapperStyle:u.default.object,rtl:u.default.bool,v2:u.default.bool,placement:u.default.string,placementOffset:u.default.number,autoAdjust:u.default.bool},i.defaultProps={triggerType:"hover",triggerClickKeycode:[h.KEYCODE.SPACE,h.KEYCODE.ENTER],defaultVisible:!1,onVisibleChange:n,disabled:!1,autoFit:!1,delay:200,canCloseByTrigger:!0,followTrigger:!1,container:function(){return document.body},rtl:!1},a);function b(e){(0,r.default)(this,b);var t=(0,o.default)(this,y.call(this,e));return t.state={visible:void 0===e.visible?e.defaultVisible:e.visible},_(t,["handleTriggerClick","handleTriggerKeyDown","handleTriggerMouseEnter","handleTriggerMouseLeave","handleTriggerFocus","handleTriggerBlur","handleContentMouseEnter","handleContentMouseLeave","handleContentMouseDown","handleRequestClose","handleMaskMouseEnter","handleMaskMouseLeave"]),t}u.displayName="Popup",t.default=(0,s.polyfill)(u),e.exports=t.default},function(e,t,n){"use strict";t.__esModule=!0;var L=a(n(3)),O=a(n(17)),D=n(0),N=a(D),P=a(n(19)),j=a(n(196)),Y=a(n(83)),I=n(11);function a(e){return e&&e.__esModule?e:{default:e}}t.default=function(r){var e,t,o,n,a,i,s,l,u,c,d,f,p,h,m,g,y,v,_,b,w,M,S,k,E,x,C,T;return D.useState&&D.useRef&&D.useEffect?(e=void 0===(e=r.prefix)?"next-":e,E=r.animation,t=void 0===E?{in:"expandInDown",out:"expandOutUp"}:E,E=r.defaultVisible,x=r.onVisibleChange,o=void 0===x?function(){}:x,x=r.trigger,n=void 0===(n=r.triggerType)?"hover":n,C=r.overlay,a=r.onPosition,T=r.children,i=r.className,s=r.style,l=r.wrapperClassName,u=r.triggerClickKeycode,c=r.align,d=r.beforeOpen,f=r.onOpen,p=r.afterOpen,h=r.beforeClose,m=r.onClose,g=r.afterClose,y=(0,O.default)(r,["prefix","animation","defaultVisible","onVisibleChange","trigger","triggerType","overlay","onPosition","children","className","style","wrapperClassName","triggerClickKeycode","align","beforeOpen","onOpen","afterOpen","beforeClose","onClose","afterClose"]),E=(0,D.useState)(E),v=E[0],_=E[1],E=(0,D.useState)(t),b=E[0],w=E[1],M=(E=(0,D.useState)(!0))[0],S=E[1],k=(0,D.useRef)(null),(0,D.useEffect)(function(){"visible"in r&&_(r.visible)},[r.visible]),(0,D.useEffect)(function(){"animation"in r&&b!==t&&w(t)},[t]),E=C?T:x,x=N.default.createElement(Y.default.OverlayAnimate,{visible:v,animation:b,timeout:200,onEnter:function(){S(!1),"function"==typeof d&&d(k.current)},onEntering:function(){"function"==typeof f&&f(k.current)},onEntered:function(){"function"==typeof p&&p(k.current)},onExit:function(){"function"==typeof h&&h(k.current)},onExiting:function(){"function"==typeof m&&m(k.current)},onExited:function(){S(!0),"function"==typeof g&&g(k.current)},style:s},(x=C||T)?(0,D.cloneElement)(x,{className:(0,P.default)([e+"overlay-inner",i,x&&x.props&&x.props.className])}):N.default.createElement("span",null)),C=(0,P.default)(((s={})[e+"overlay-wrapper v2"]=!0,s[l]=l,s.opened=v,s)),T={},c&&(T.points=c.split(" ")),N.default.createElement(j.default.Popup,(0,L.default)({},y,T,{wrapperClassName:C,overlay:x,visible:v,isAnimationEnd:M,triggerType:n,onVisibleChange:function(e){for(var t=arguments.length,n=Array(1 16.8.0"),null)},e.exports=t.default},function(e,t,n){"use strict";t.__esModule=!0;var l=a(n(3)),u=a(n(17)),o=n(0),c=a(o),i=a(n(25)),s=a(n(6)),d=a(n(83)),f=a(n(165)),p=n(11);function a(e){return e&&e.__esModule?e:{default:e}}var h={top:8,maxCount:0,duration:3e3},m=s.default.config(function(e){var t=e.prefix,s=void 0===t?"next-":t,t=e.dataSource,a=void 0===t?[]:t,r=(0,o.useState)()[1];return a.forEach(function(n){n.timer||(n.timer=setTimeout(function(){var e,t=a.indexOf(n);-1a&&y.shift(),i.default.render(c.default.createElement(s.default,s.default.getContext(),c.default.createElement(m,{dataSource:y})),g),{key:n,close:function(){r.timer&&clearTimeout(r.timer);var e=y.indexOf(r);-1 16.8.0")}},e.exports=t.default},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){"use strict";n(565)},function(e,t,n){},function(e,t,n){},function(e,t,n){"use strict";t.__esModule=!0,t.default=void 0;var p=l(n(3)),r=l(n(4)),o=l(n(7)),a=l(n(8)),h=l(n(42)),m=l(n(0)),i=l(n(5)),g=l(n(19)),y=n(11),s=l(n(28)),v=l(n(368));function l(e){return e&&e.__esModule?e:{default:e}}function _(e,r){var o=r.size,i=r.device,s=r.labelAlign,l=r.labelTextAlign,u=r.labelCol,c=r.wrapperCol,d=r.responsive,f=r.colon;return m.default.Children.map(e,function(e){var t,n,a;return y.obj.isReactFragment(e)?_(e.props.children,r):e&&-1<["function","object"].indexOf((0,h.default)(e.type))&&"form_item"===e.type._typeMark?(t={labelCol:e.props.labelCol||u,wrapperCol:e.props.wrapperCol||c,labelAlign:e.props.labelAlign||("phone"===i?"top":s),labelTextAlign:e.props.labelTextAlign||l,colon:"colon"in e.props?e.props.colon:f,size:e.props.size||o,responsive:d},m.default.cloneElement(e,(n=t,a={},Object.keys(n).forEach(function(e){void 0!==n[e]&&(a[e]=n[e])}),a))):e})}u=m.default.Component,(0,a.default)(b,u),b.prototype.getChildContext=function(){return{_formField:this.props.field||this._formField,_formSize:this.props.size,_formDisabled:this.props.disabled,_formPreview:this.props.isPreview,_formFullWidth:this.props.fullWidth,_formLabelForErrorMessage:this.props.useLabelForErrorMessage}},b.prototype.componentDidUpdate=function(e){var t=this.props;this._formField&&("value"in t&&t.value!==e.value&&this._formField.setValues(t.value),"error"in t)&&t.error!==e.error&&this._formField.setValues(t.error)},b.prototype.render=function(){var e=this.props,t=e.className,n=e.inline,a=e.size,r=(e.device,e.labelAlign,e.labelTextAlign,e.onSubmit),o=e.children,i=(e.labelCol,e.wrapperCol,e.style),s=e.prefix,l=e.rtl,u=e.isPreview,c=e.component,d=e.responsive,f=e.gap,n=(e.colon,(0,g.default)(((e={})[s+"form"]=!0,e[s+"inline"]=n,e[""+s+a]=a,e[s+"form-responsive-grid"]=d,e[s+"form-preview"]=u,e[t]=!!t,e))),a=_(o,this.props);return m.default.createElement(c,(0,p.default)({role:"grid"},y.obj.pickOthers(b.propTypes,this.props),{className:n,style:i,dir:l?"rtl":void 0,onSubmit:r}),d?m.default.createElement(v.default,{gap:f},a):a)},a=n=b,n.propTypes={prefix:i.default.string,inline:i.default.bool,size:i.default.oneOf(["large","medium","small"]),fullWidth:i.default.bool,labelAlign:i.default.oneOf(["top","left","inset"]),labelTextAlign:i.default.oneOf(["left","right"]),field:i.default.any,saveField:i.default.func,labelCol:i.default.object,wrapperCol:i.default.object,onSubmit:i.default.func,children:i.default.any,className:i.default.string,style:i.default.object,value:i.default.object,onChange:i.default.func,component:i.default.oneOfType([i.default.string,i.default.func]),fieldOptions:i.default.object,rtl:i.default.bool,device:i.default.oneOf(["phone","tablet","desktop"]),responsive:i.default.bool,isPreview:i.default.bool,useLabelForErrorMessage:i.default.bool,colon:i.default.bool,disabled:i.default.bool,gap:i.default.oneOfType([i.default.arrayOf(i.default.number),i.default.number])},n.defaultProps={prefix:"next-",onSubmit:function(e){e.preventDefault()},size:"medium",labelAlign:"left",onChange:y.func.noop,component:"form",saveField:y.func.noop,device:"desktop",colon:!1,disabled:!1},n.childContextTypes={_formField:i.default.object,_formSize:i.default.string,_formDisabled:i.default.bool,_formPreview:i.default.bool,_formFullWidth:i.default.bool,_formLabelForErrorMessage:i.default.bool};var u,n=a;function b(e){(0,r.default)(this,b);var t,n,a=(0,o.default)(this,u.call(this,e));return a.onChange=function(e,t){a.props.onChange(a._formField.getValues(),{name:e,value:t,field:a._formField})},a._formField=null,!1!==e.field&&(t=(0,p.default)({},e.fieldOptions,{onChange:a.onChange}),e.field?(a._formField=e.field,n=a._formField.options.onChange,t.onChange=y.func.makeChain(n,a.onChange),a._formField.setOptions&&a._formField.setOptions(t)):("value"in e&&(t.values=e.value),a._formField=new s.default(a,t)),e.locale&&e.locale.Validate&&a._formField.setOptions({messages:e.locale.Validate}),e.saveField(a._formField)),a}n.displayName="Form",t.default=n,e.exports=t.default},function(e,t,n){"use strict";var a=n(91),m=(Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,a(n(169))),i=a(n(570)),r=a(n(170)),o=a(n(116)),b=a(n(171)),w=a(n(77)),s=a(n(366)),l=a(n(367)),g=a(n(577)),M=n(586),u={state:"",valueName:"value",trigger:"onChange",inputValues:[]},a=function(){function a(e){var t=this,n=1e.length)&&(t=e.length);for(var n=0,a=new Array(t);n=a.length?n:(o=a[r],n=e(t&&t[o],n,a,r+1),t?Array.isArray(t)?((a=[].concat(t))[o]=n,a):(0,l.default)({},t,(0,i.default)({},o,n)):((r=isNaN(o)?{}:[])[o]=n,r))};t=function(){};void 0!==e&&e.env,n.warning=t}.call(this,r(103))},function(e,t,n){"use strict";t.__esModule=!0,t.cloneAndAddKey=function(e){{var t;if(e&&(0,a.isValidElement)(e))return t=e.key||"error",(0,a.cloneElement)(e,{key:t})}return e},t.scrollToFirstError=function(e){var t=e.errorsGroup,n=e.options,a=e.instance;if(t&&n.scrollToFirstError){var r,o=void 0,i=void 0;for(r in t)if(t.hasOwnProperty(r)){var s=u.default.findDOMNode(a[r]);if(!s)return;var l=s.offsetTop;(void 0===i||l), use instead of.'),k.default.cloneElement(e,{className:t,size:d||C(r)})):(0,S.isValidElement)(e)?e:k.default.createElement("span",{className:a+"btn-helper"},e)}),t=c,_=(0,b.default)({},x.obj.pickOthers(Object.keys(T.propTypes),e),{type:o,disabled:p,onClick:h,className:(0,E.default)(n)});return"button"!==t&&(delete _.type,_.disabled)&&(delete _.onClick,_.href)&&delete _.href,k.default.createElement(t,(0,b.default)({},_,{dir:g?"rtl":void 0,onMouseUp:this.onMouseUp,ref:this.buttonRefHandler}),s,u)},a=n=T,n.propTypes=(0,b.default)({},s.default.propTypes,{prefix:r.default.string,rtl:r.default.bool,type:r.default.oneOf(["primary","secondary","normal"]),size:r.default.oneOf(["small","medium","large"]),icons:r.default.shape({loading:r.default.node}),iconSize:r.default.oneOfType([r.default.oneOf(["xxs","xs","small","medium","large","xl","xxl","xxxl","inherit"]),r.default.number]),htmlType:r.default.oneOf(["submit","reset","button"]),component:r.default.oneOf(["button","a","div","span"]),loading:r.default.bool,ghost:r.default.oneOf([!0,!1,"light","dark"]),text:r.default.bool,warning:r.default.bool,disabled:r.default.bool,onClick:r.default.func,className:r.default.string,onMouseUp:r.default.func,children:r.default.node}),n.defaultProps={prefix:"next-",type:"normal",size:"medium",icons:{},htmlType:"button",component:"button",loading:!1,ghost:!1,text:!1,warning:!1,disabled:!1,onClick:function(){}};var u,s=a;function T(){var e,t;(0,o.default)(this,T);for(var n=arguments.length,a=Array(n),r=0;ra[r])return!0;if(n[r] 0, or `null`');if(U(i,"numericSeparator")&&"boolean"!=typeof i.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var t=i.numericSeparator;if(void 0===n)return"undefined";if(null===n)return"null";if("boolean"==typeof n)return n?"true":"false";if("string"==typeof n)return function e(t,n){if(t.length>n.maxStringLength)return a=t.length-n.maxStringLength,a="... "+a+" more character"+(1"}if(z(n))return 0===n.length?"[]":(l=$(n,m),h&&!function(e){for(var t=0;t "+m(e,n))}),ne("Map",_.call(n),u,h)):function(e){if(w&&e&&"object"==typeof e)try{w.call(e);try{_.call(e)}catch(e){return 1}return e instanceof Set}catch(e){}return}(n)?(c=[],M&&M.call(n,function(e){c.push(m(e,n))}),ne("Set",w.call(n),c,h)):function(e){if(S&&e&&"object"==typeof e)try{S.call(e,S);try{k.call(e,k)}catch(e){return 1}return e instanceof WeakMap}catch(e){}return}(n)?q("WeakMap"):function(e){if(k&&e&&"object"==typeof e)try{k.call(e,k);try{S.call(e,S)}catch(e){return 1}return e instanceof WeakSet}catch(e){}return}(n)?q("WeakSet"):function(e){if(E&&e&&"object"==typeof e)try{return E.call(e),1}catch(e){}return}(n)?q("WeakRef"):"[object Number]"!==V(d=n)||j&&"object"==typeof d&&j in d?function(e){if(e&&"object"==typeof e&&D)try{return D.call(e),1}catch(e){}return}(n)?K(m(D.call(n))):"[object Boolean]"!==V(t=n)||j&&"object"==typeof t&&j in t?"[object String]"!==V(e=n)||j&&"object"==typeof e&&j in e?("[object Date]"!==V(t=n)||j&&"object"==typeof t&&j in t)&&!W(n)?(e=$(n,m),t=I?I(n)===Object.prototype:n instanceof Object||n.constructor===Object,f=n instanceof Object?"":"null prototype",p=!t&&j&&Object(n)===n&&j in n?x.call(V(n),8,-1):f?"Object":"",t=(!t&&"function"==typeof n.constructor&&n.constructor.name?n.constructor.name+" ":"")+(p||f?"["+O.call(L.call([],p||[],f||[]),": ")+"] ":""),0===e.length?t+"{}":h?t+"{"+G(e,h)+"}":t+"{ "+O.call(e,", ")+" }"):String(n):K(m(String(n))):K(J.call(n)):K(m(Number(n)))};var l=Object.prototype.hasOwnProperty||function(e){return e in this};function U(e,t){return l.call(e,t)}function V(e){return i.call(e)}function ee(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,a=e.length;nu&&!d&&(o=o.slice(0,u),e=C.default.createElement(m.default,{key:"_count",type:"primary",size:p,animation:!1},c(a,t))),0, as child."),a.push(t),e.props.children)&&(t.children=n(e.props.children))}),a}(e.children):t},N.prototype.fetchInfoFromBinaryChildren=function(e){function r(e,t){return t=t||0,e.forEach(function(e){e.children?t=r(e.children,t):t+=1}),t}var a=!1,o=[],i=[],e=(function t(){var e=0r.tRight&&(e=r.tRight,r.changedPageX=r.tRight-r.startLeft),e-r.cellLefto.clientHeight,o.scrollWidth,o.clientWidth,o={},e||(o[r]=0,o[a]=0),+i&&(o.marginBottom=-i,o.paddingBottom=i,e)&&(o[a]=i),h.dom.setStyle(this.headerNode,o)),n&&!this.props.lockType&&this.headerNode&&(r=this.headerNode.querySelector("."+t+"table-header-fixer"),e=h.dom.getStyle(this.headerNode,"height"),a=h.dom.getStyle(this.headerNode,"paddingBottom"),h.dom.setStyle(r,{width:i,height:e-a}))},o.prototype.render=function(){var e=this.props,t=e.components,n=e.className,a=e.prefix,r=e.fixedHeader,o=e.lockType,i=e.dataSource,e=(e.maxBodyHeight,(0,u.default)(e,["components","className","prefix","fixedHeader","lockType","dataSource","maxBodyHeight"]));return r&&((t=(0,l.default)({},t)).Header||(t.Header=m.default),t.Body||(t.Body=g.default),t.Wrapper||(t.Wrapper=y.default),n=(0,p.default)(((r={})[a+"table-fixed"]=!0,r[a+"table-wrap-empty"]=!i.length,r[n]=n,r))),d.default.createElement(s,(0,l.default)({},e,{dataSource:i,lockType:o,components:t,className:n,prefix:a}))},o}(d.default.Component),n.FixedHeader=m.default,n.FixedBody=g.default,n.FixedWrapper=y.default,n.propTypes=(0,l.default)({hasHeader:r.default.bool,fixedHeader:r.default.bool,maxBodyHeight:r.default.oneOfType([r.default.number,r.default.string])},s.propTypes),n.defaultProps=(0,l.default)({},s.defaultProps,{hasHeader:!0,fixedHeader:!1,maxBodyHeight:200,components:{},refs:{},prefix:"next-"}),n.childContextTypes={fixedHeader:r.default.bool,getNode:r.default.func,onFixedScrollSync:r.default.func,getTableInstanceForFixed:r.default.func,maxBodyHeight:r.default.oneOfType([r.default.number,r.default.string])};var t,n=t;return n.displayName="FixedTable",(0,o.statics)(n,s),n};var d=s(n(0)),r=s(n(5)),f=n(25),p=s(n(19)),h=n(11),m=s(n(136)),g=s(n(406)),y=s(n(137)),o=n(70);function s(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},function(e,t,n){"use strict";t.__esModule=!0;var i=o(n(17)),f=o(n(3)),r=o(n(4)),s=o(n(7)),l=o(n(8)),u=(t.default=function(o){e=t=function(n){function a(e,t){(0,r.default)(this,a);var d=(0,s.default)(this,n.call(this,e,t));return d.addSelection=function(e){var t=d.props,n=t.prefix,a=t.rowSelection,t=t.size,a=a.columnProps&&a.columnProps()||{};e.find(function(e){return"selection"===e.key})||e.unshift((0,f.default)({key:"selection",title:d.renderSelectionHeader.bind(d),cell:d.renderSelectionBody.bind(d),width:"small"===t?34:50,className:n+"table-selection "+n+"table-prerow",__normalized:!0},a))},d.renderSelectionHeader=function(){var e=d.selectAllRow,t={},n=d.props,a=n.rowSelection,r=n.primaryKey,o=n.dataSource,i=n.entireDataSource,n=n.locale,s=d.state.selectedRowKeys,l=a.mode||"multiple",u=!!s.length,c=!1,i=(d.flatDataSource(i||o).filter(function(e,t){return!a.getProps||!(a.getProps(e,t)||{}).disabled}).map(function(e){return e[r]}).forEach(function(e){-1===s.indexOf(e)?u=!1:c=!0}),t.onClick=b(function(e){e.stopPropagation()},t.onClick),a.titleProps&&a.titleProps()||{});return u&&(c=!1),["multiple"===l?p.default.createElement(h.default,(0,f.default)({key:"_total",indeterminate:c,"aria-label":n.selectAll,checked:u,onChange:e},t,i)):null,a.titleAddons&&a.titleAddons()]},d.renderSelectionBody=function(e,t,n){var a=d.props,r=a.rowSelection,a=a.primaryKey,o=d.state.selectedRowKeys,i=r.mode||"multiple",o=-1l.length&&(u=o),w(u.filter(function(e){return-1=Math.max(a-y,0)&&od.clientHeight;this.isLock()?(e=this.bodyLeftNode,t=this.bodyRightNode,n=this.getWrapperNode("right"),a=f?c:0,d=d.offsetHeight-c,f||(r[l]=0,r[u]=0),+c?(r.marginBottom=-c,r.paddingBottom=c):(r.marginBottom=-20,r.paddingBottom=20),d={"max-height":d},o||+c||(d[u]=0),+c&&(d[u]=-c),e&&g.dom.setStyle(e,d),t&&g.dom.setStyle(t,d),n&&+c&&g.dom.setStyle(n,i?"left":"right",a+"px")):(r.marginBottom=-c,r.paddingBottom=c,r[u]=0,f||(r[l]=0)),s&&g.dom.setStyle(s,r)},a.prototype.adjustHeaderSize=function(){var o=this;this.isLock()&&this.tableInc.groupChildren.forEach(function(e,t){var n=o.tableInc.groupChildren[t].length-1,n=o.getHeaderCellNode(t,n),a=o.getHeaderCellNode(t,0),r=o.getHeaderCellNode(t,0,"right"),t=o.getHeaderCellNode(t,0,"left");n&&r&&(n=n.offsetHeight,g.dom.setStyle(r,"height",n),setTimeout(function(){var e=o.tableRightInc.affixRef;return e&&e.getInstance()&&e.getInstance().updatePosition()})),a&&t&&(r=a.offsetHeight,g.dom.setStyle(t,"height",r),setTimeout(function(){var e=o.tableLeftInc.affixRef;return e&&e.getInstance()&&e.getInstance().updatePosition()}))})},a.prototype.adjustRowHeight=function(){var n=this;this.isLock()&&this.tableInc.props.dataSource.forEach(function(e,t){t=""+("object"===(void 0===e?"undefined":(0,r.default)(e))&&"__rowIndex"in e?e.__rowIndex:t)+(e.__expanded?"_expanded":"");n.setRowHeight(t,"left"),n.setRowHeight(t,"right")})},a.prototype.setRowHeight=function(e,t){var t=this.getRowNode(e,t),e=this.getRowNode(e),e=(M?e&&e.offsetHeight:e&&parseFloat(getComputedStyle(e).height))||"auto",n=(M?t&&t.offsetHeight:t&&parseFloat(getComputedStyle(t).height))||"auto";t&&e!==n&&g.dom.setStyle(t,"height",e)},a.prototype.getWrapperNode=function(e){e=e?e.charAt(0).toUpperCase()+e.substr(1):"";try{return(0,u.findDOMNode)(this["lock"+e+"El"])}catch(e){return null}},a.prototype.getRowNode=function(e,t){t=this["table"+(t=t?t.charAt(0).toUpperCase()+t.substr(1):"")+"Inc"];try{return(0,u.findDOMNode)(t.getRowRef(e))}catch(e){return null}},a.prototype.getHeaderCellNode=function(e,t,n){n=this["table"+(n=n?n.charAt(0).toUpperCase()+n.substr(1):"")+"Inc"];try{return(0,u.findDOMNode)(n.getHeaderCellRef(e,t))}catch(e){return null}},a.prototype.getCellNode=function(e,t,n){n=this["table"+(n=n?n.charAt(0).toUpperCase()+n.substr(1):"")+"Inc"];try{return(0,u.findDOMNode)(n.getCellRef(e,t))}catch(e){return null}},a.prototype.render=function(){var e,t=this.props,n=(t.children,t.columns,t.prefix),a=t.components,r=t.className,o=t.dataSource,i=t.tableWidth,t=(0,f.default)(t,["children","columns","prefix","components","className","dataSource","tableWidth"]),s=this.normalizeChildrenState(this.props),l=s.lockLeftChildren,u=s.lockRightChildren,s=s.children,c={left:this.getFlatenChildrenLength(l),right:this.getFlatenChildrenLength(u),origin:this.getFlatenChildrenLength(s)};return this._notNeedAdjustLockLeft&&(l=[]),this._notNeedAdjustLockRight&&(u=[]),this.lockLeftChildren=l,this.lockRightChildren=u,this.isOriginLock()?((a=(0,p.default)({},a)).Body=a.Body||v.default,a.Header=a.Header||_.default,a.Wrapper=a.Wrapper||b.default,a.Row=a.Row||y.default,r=(0,m.default)(((e={})[n+"table-lock"]=!0,e[n+"table-wrap-empty"]=!o.length,e[r]=r,e)),e=[h.default.createElement(d,(0,p.default)({},t,{dataSource:o,key:"lock-left",columns:l,className:n+"table-lock-left",lengths:c,prefix:n,lockType:"left",components:a,ref:this.saveLockLeftRef,loading:!1,"aria-hidden":!0})),h.default.createElement(d,(0,p.default)({},t,{dataSource:o,key:"lock-right",columns:u,className:n+"table-lock-right",lengths:c,prefix:n,lockType:"right",components:a,ref:this.saveLockRightRef,loading:!1,"aria-hidden":!0}))],h.default.createElement(d,(0,p.default)({},t,{tableWidth:i,dataSource:o,columns:s,prefix:n,lengths:c,wrapperContent:e,components:a,className:r}))):h.default.createElement(d,this.props)},a}(h.default.Component),t.LockRow=y.default,t.LockBody=v.default,t.LockHeader=_.default,t.propTypes=(0,p.default)({scrollToCol:a.default.number,scrollToRow:a.default.number},d.propTypes),t.defaultProps=(0,p.default)({},d.defaultProps),t.childContextTypes={getTableInstance:a.default.func,getLockNode:a.default.func,onLockBodyScroll:a.default.func,onRowMouseEnter:a.default.func,onRowMouseLeave:a.default.func};var e,t=e;return t.displayName="LockTable",(0,w.statics)(t,d),t},n(0)),h=d(l),u=n(25),a=d(n(5)),m=d(n(19)),c=d(n(182)),g=n(11),y=d(n(184)),v=d(n(407)),_=d(n(408)),b=d(n(137)),w=n(70);function d(e){return e&&e.__esModule?e:{default:e}}var M=g.env.ieVersion;function S(e){return function n(e){return e.map(function(e){var t=(0,p.default)({},e);return e.children&&(e.children=n(e.children)),t})}(e)}e.exports=t.default},function(e,t,n){"use strict";t.__esModule=!0;var l=s(n(17)),u=s(n(3)),r=s(n(4)),o=s(n(7)),i=s(n(8)),c=(t.default=function(s){e=t=function(n){function a(e,t){(0,r.default)(this,a);var c=(0,o.default)(this,n.call(this,e));return c.state={},c.updateOffsetArr=function(){var e=c.splitChildren||{},t=e.lockLeftChildren,n=e.lockRightChildren,e=e.originChildren,a=c.getFlatenChildren(t).length,r=c.getFlatenChildren(n).length,e=a+r+c.getFlatenChildren(e).length,a=0r.top-e.offset?(t?(l.position="absolute",l.top=a-(r.top-e.offset),u="relative"):(l.position="fixed",l.top=e.offset+n.top),c._setAffixStyle(l,!0),c._setContainerStyle(s)):e.bottom&&a{e=new Date(e);if(isNaN(e))throw new TypeError("Invalid Datetime");return e}},function(e,t,n){"use strict";const a=n(186);class r extends Date{constructor(e){super(e+"Z"),this.isFloating=!0}toISOString(){return`${this.getUTCFullYear()}-${a(2,this.getUTCMonth()+1)}-`+a(2,this.getUTCDate())+"T"+(`${a(2,this.getUTCHours())}:${a(2,this.getUTCMinutes())}:${a(2,this.getUTCSeconds())}.`+a(3,this.getUTCMilliseconds()))}}e.exports=e=>{e=new r(e);if(isNaN(e))throw new TypeError("Invalid Datetime");return e}},function(a,e,r){"use strict";!function(e){const t=r(186);class n extends e.Date{constructor(e){super(e),this.isDate=!0}toISOString(){return`${this.getUTCFullYear()}-${t(2,this.getUTCMonth()+1)}-`+t(2,this.getUTCDate())}}a.exports=e=>{e=new n(e);if(isNaN(e))throw new TypeError("Invalid Datetime");return e}}.call(this,r(65))},function(e,t,n){"use strict";const a=n(186);class r extends Date{constructor(e){super(`0000-01-01T${e}Z`),this.isTime=!0}toISOString(){return`${a(2,this.getUTCHours())}:${a(2,this.getUTCMinutes())}:${a(2,this.getUTCSeconds())}.`+a(3,this.getUTCMilliseconds())}}e.exports=e=>{e=new r(e);if(isNaN(e))throw new TypeError("Invalid Datetime");return e}},function(e,t,n){"use strict";!function(s){e.exports=function(r,e){e=e||{};const n=e.blocksize||40960,o=new t;return new Promise((e,t)=>{s(i,0,n,e,t)});function i(e,t,n,a){if(e>=r.length)try{return n(o.finish())}catch(e){return a(l(e,r))}try{o.parse(r.slice(e,e+t)),s(i,e+t,t,n,a)}catch(e){a(l(e,r))}}};const t=n(185),l=n(187)}.call(this,n(412).setImmediate)},function(e,t,n){!function(e,p){!function(n,o){"use strict";var a,i,s,r,l,u,t,e;function c(e){delete i[e]}function d(e){if(s)setTimeout(d,0,e);else{var t=i[e];if(t){s=!0;try{var n=t,a=n.callback,r=n.args;switch(r.length){case 0:a();break;case 1:a(r[0]);break;case 2:a(r[0],r[1]);break;case 3:a(r[0],r[1],r[2]);break;default:a.apply(o,r)}}finally{c(e),s=!1}}}}function f(){function e(e){e.source===n&&"string"==typeof e.data&&0===e.data.indexOf(t)&&d(+e.data.slice(t.length))}var t="setImmediate$"+Math.random()+"$";n.addEventListener?n.addEventListener("message",e,!1):n.attachEvent("onmessage",e),l=function(e){n.postMessage(t+e,"*")}}n.setImmediate||(a=1,s=!(i={}),r=n.document,e=(e=Object.getPrototypeOf&&Object.getPrototypeOf(n))&&e.setTimeout?e:n,"[object process]"==={}.toString.call(n.process)?l=function(e){p.nextTick(function(){d(e)})}:!function(){var e,t;if(n.postMessage&&!n.importScripts)return e=!0,t=n.onmessage,n.onmessage=function(){e=!1},n.postMessage("","*"),n.onmessage=t,e}()?l=n.MessageChannel?((t=new MessageChannel).port1.onmessage=function(e){d(e.data)},function(e){t.port2.postMessage(e)}):r&&"onreadystatechange"in r.createElement("script")?(u=r.documentElement,function(e){var t=r.createElement("script");t.onreadystatechange=function(){d(e),t.onreadystatechange=null,u.removeChild(t),t=null},u.appendChild(t)}):function(e){setTimeout(d,0,e)}:f(),e.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n{let n,a=!1,r=!1;function o(){if(a=!0,!n)try{e(l.finish())}catch(e){t(e)}}function i(e){r=!0,t(e)}s.once("end",o),s.once("error",i),function e(){n=!0;let t;for(;null!==(t=s.read());)try{l.parse(t)}catch(e){return i(e)}n=!1;if(a)return o();if(r)return;s.once("readable",e)}()})}(e):function(){const a=new o;return new r.Transform({objectMode:!0,transform(e,t,n){try{a.parse(e.toString(t))}catch(e){this.emit("error",e)}n()},flush(e){try{this.push(a.finish())}catch(e){this.emit("error",e)}e()}})}()};const r=n(704),o=n(185)},function(e,t,n){e.exports=a;var c=n(188).EventEmitter;function a(){c.call(this)}n(105)(a,c),a.Readable=n(189),a.Writable=n(714),a.Duplex=n(715),a.Transform=n(716),a.PassThrough=n(717),(a.Stream=a).prototype.pipe=function(t,e){var n=this;function a(e){t.writable&&!1===t.write(e)&&n.pause&&n.pause()}function r(){n.readable&&n.resume&&n.resume()}n.on("data",a),t.on("drain",r),t._isStdio||e&&!1===e.end||(n.on("end",i),n.on("close",s));var o=!1;function i(){o||(o=!0,t.end())}function s(){o||(o=!0,"function"==typeof t.destroy&&t.destroy())}function l(e){if(u(),0===c.listenerCount(this,"error"))throw e}function u(){n.removeListener("data",a),t.removeListener("drain",r),n.removeListener("end",i),n.removeListener("close",s),n.removeListener("error",l),t.removeListener("error",l),n.removeListener("end",u),n.removeListener("close",u),t.removeListener("close",u)}return n.on("error",l),t.on("error",l),n.on("end",u),n.on("close",u),t.on("close",u),t.emit("pipe",n),t}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t,n){"use strict";t.byteLength=function(e){var e=c(e),t=e[0],e=e[1];return 3*(t+e)/4-e},t.toByteArray=function(e){var t,n,a=c(e),r=a[0],a=a[1],o=new u(function(e,t){return 3*(e+t)/4-t}(r,a)),i=0,s=0>16&255,o[i++]=t>>8&255,o[i++]=255&t;2===a&&(t=l[e.charCodeAt(n)]<<2|l[e.charCodeAt(n+1)]>>4,o[i++]=255&t);1===a&&(t=l[e.charCodeAt(n)]<<10|l[e.charCodeAt(n+1)]<<4|l[e.charCodeAt(n+2)]>>2,o[i++]=t>>8&255,o[i++]=255&t);return o},t.fromByteArray=function(e){for(var t,n=e.length,a=n%3,r=[],o=0,i=n-a;o>18&63]+s[e>>12&63]+s[e>>6&63]+s[63&e]}(a));return r.join("")}(e,o,i>2]+s[t<<4&63]+"==")):2==a&&(t=(e[n-2]<<8)+e[n-1],r.push(s[t>>10]+s[t>>4&63]+s[t<<2&63]+"="));return r.join("")};for(var s=[],l=[],u="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,o=a.length;r */ t.read=function(e,t,n,a,r){var o,i,s=8*r-a-1,l=(1<>1,c=-7,d=n?r-1:0,f=n?-1:1,r=e[t+d];for(d+=f,o=r&(1<<-c)-1,r>>=-c,c+=s;0>=-c,c+=a;0>1,d=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,f=a?0:o-1,p=a?1:-1,o=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,i=u):(i=Math.floor(Math.log(t)/Math.LN2),t*(a=Math.pow(2,-i))<1&&(i--,a*=2),2<=(t+=1<=i+c?d/a:d*Math.pow(2,1-c))*a&&(i++,a/=2),u<=i+c?(s=0,i=u):1<=i+c?(s=(t*a-1)*Math.pow(2,r),i+=c):(s=t*Math.pow(2,c-1)*Math.pow(2,r),i=0));8<=r;e[n+f]=255&s,f+=p,s/=256,r-=8);for(i=i<>>0),r=this.head,o=0;r;)t=r.data,n=o,t.copy(a,n),o+=r.data.length,r=r.next;return a},r),a&&a.inspect&&a.inspect.custom&&(e.exports.prototype[a.inspect.custom]=function(){var e=a.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){!function(t){function a(e){try{if(!t.localStorage)return}catch(e){return}e=t.localStorage[e];return null!=e&&"true"===String(e).toLowerCase()}e.exports=function(e,t){if(a("noDeprecation"))return e;var n=!1;return function(){if(!n){if(a("throwDeprecation"))throw new Error(t);a("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}}}.call(this,n(65))},function(e,t,n){"use strict";e.exports=r;var a=n(418),e=Object.create(n(118));function r(e){if(!(this instanceof r))return new r(e);a.call(this,e)}e.inherits=n(105),e.inherits(r,a),r.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){e.exports=n(190)},function(e,t,n){e.exports=n(92)},function(e,t,n){e.exports=n(189).Transform},function(e,t,n){e.exports=n(189).PassThrough},function(e,t,n){"use strict";function u(e){return new Error("Can only stringify objects, not "+e)}function c(t){return Object.keys(t).filter(e=>p(t[e]))}function d(e){var t,n=Array.isArray(e)?[]:Object.prototype.hasOwnProperty.call(e,"__proto__")?{["__proto__"]:void 0}:{};for(t of Object.keys(e))!e[t]||"function"!=typeof e[t].toJSON||"toISOString"in e[t]?n[t]=e[t]:n[t]=e[t].toJSON();return n}function f(t,e,n){var a,r,o=c(n=d(n));r=n,a=Object.keys(r).filter(e=>!p(r[e]));const i=[],s=e||"",l=(o.forEach(e=>{var t=h(n[e]);"undefined"!==t&&"null"!==t&&i.push(s+m(e)+" = "+g(n[e],!0))}),0{i.push(function(e,t,n,a){var r=h(a);{if("array"===r)return function(e,t,n,a){var r=h((a=d(a))[0]);if("table"!==r)throw u(r);const o=e+m(n);let i="";return a.forEach(e=>{0"\\u"+function(e,t){for(;t.lengths(e).replace(/"(?="")/g,'\\"')).join("\n");return'"'===e.slice(-1)&&(e+="\\\n"),'"""\n'+e+'"""';return}case"string":return i(t);case"string-literal":return"'"+t+"'";case"integer":return y(t);case"float":n=t;return n===1/0?"inf":n===-1/0?"-inf":Object.is(n,NaN)?"nan":Object.is(n,-0)?"-0.0":([n,a]=String(n).split("."),y(n)+"."+a);case"boolean":return String(t);case"datetime":return t.toISOString();case"array":{var a=t.filter(e=>"null"!==h(e)&&"undefined"!==h(e)&&"nan"!==h(e));a=d(a);let e="[";a=a.map(e=>l(e));60{o.push(m(e)+" = "+g(r[e],!1))}),"{ "+o.join(", ")+(0=P.KEYCODE.LEFT&&t<=P.KEYCODE.DOWN&&e.preventDefault(),e=void 0,t===P.KEYCODE.RIGHT||t===P.KEYCODE.DOWN?(e=o.getNextActiveKey(!0),o.handleTriggerEvent(o.props.triggerType,e)):t!==P.KEYCODE.LEFT&&t!==P.KEYCODE.UP||(e=o.getNextActiveKey(!1),o.handleTriggerEvent(o.props.triggerType,e)))},o.state={activeKey:o.getDefaultActiveKey(e)},o}s.displayName="Tab",t.default=(0,l.polyfill)(s),e.exports=t.default},function(e,t,n){"use strict";t.__esModule=!0;var _=d(n(3)),a=d(n(4)),r=d(n(7)),o=d(n(8)),b=d(n(0)),i=n(25),s=d(n(5)),w=d(n(19)),M=d(n(26)),l=d(n(64)),u=d(n(50)),S=(d(n(20)),d(n(83))),h=n(11),c=n(420);function d(e){return e&&e.__esModule?e:{default:e}}var f,k={float:"right",zIndex:1},E={float:"left",zIndex:1},p={dropdown:"arrow-down",prev:"arrow-left",next:"arrow-right"},m=l.default.Popup,l=(f=b.default.Component,(0,o.default)(g,f),g.prototype.componentDidMount=function(){this.props.animation||this.initialSettings(),h.events.on(window,"resize",this.onWindowResized)},g.prototype.componentDidUpdate=function(e){var t=this;clearTimeout(this.scrollTimer),this.scrollTimer=setTimeout(function(){t.scrollToActiveTab()},410),clearTimeout(this.slideTimer),this.slideTimer=setTimeout(function(){t.setSlideBtn()},410),"dropdown"!==this.props.excessMode||(0,c.tabsArrayShallowEqual)(this.props.tabs,e.tabs)||this.getDropdownItems(this.props)},g.prototype.componentWillUnmount=function(){h.events.off(window,"resize",this.onWindowResized)},g.prototype.initialSettings=function(){this.setSlideBtn(),this.getDropdownItems(this.props)},g.prototype.setOffset=function(e){var t=!(1n&&(t.current=n),this.setState(t),this.props.onPageSizeChange(e)},I.prototype.renderPageTotal=function(){var e=this.props,t=e.prefix,n=e.total,e=e.totalRender,a=this.state,r=a.currentPageSize,a=a.current;return N.default.createElement("div",{className:t+"pagination-total"},e(n,[(a-1)*r+1,a*r]))},I.prototype.renderPageItem=function(e){var t=this.props,n=t.prefix,a=t.size,r=t.link,o=t.pageNumberRender,i=t.total,s=t.pageSize,t=t.locale,l=this.state.current,i=Y(i,s),s=parseInt(e,10)===l,a={size:a,className:(0,P.default)(((l={})[n+"pagination-item"]=!0,l[n+"current"]=s,l)),onClick:s?m:this.onPageItemClick.bind(this,e)};return r&&(a.component="a",a.href=r.replace("{page}",e)),N.default.createElement(d.default,(0,D.default)({"aria-label":j.str.template(t.total,{current:e,total:i})},a,{key:e}),o(e))},I.prototype.renderPageFirst=function(e){var t=this.props,n=t.prefix,a=t.size,r=t.shape,t=t.locale,a={disabled:e<=1,size:a,className:(0,P.default)(((a={})[n+"pagination-item"]=!0,a[n+"prev"]=!0,a)),onClick:this.onPageItemClick.bind(this,e-1)},n=N.default.createElement(c.default,{type:"arrow-left",className:n+"pagination-icon-prev"});return N.default.createElement(d.default,(0,D.default)({},a,{"aria-label":j.str.template(t.labelPrev,{current:e})}),n,"arrow-only"===r||"arrow-prev-only"===r||"no-border"===r?"":t.prev)},I.prototype.renderPageLast=function(e,t){var n=this.props,a=n.prefix,r=n.size,o=n.shape,n=n.locale,r={disabled:t<=e,size:r,className:(0,P.default)(((t={})[a+"pagination-item"]=!0,t[a+"next"]=!0,t)),onClick:this.onPageItemClick.bind(this,e+1)},t=N.default.createElement(c.default,{type:"arrow-right",className:a+"pagination-icon-next"});return N.default.createElement(d.default,(0,D.default)({},r,{"aria-label":j.str.template(n.labelNext,{current:e})}),"arrow-only"===o||"no-border"===o?"":n.next,t)},I.prototype.renderPageEllipsis=function(e){var t=this.props.prefix;return N.default.createElement(c.default,{className:t+"pagination-ellipsis "+t+"pagination-icon-ellipsis",type:"ellipsis",key:"ellipsis-"+e})},I.prototype.renderPageJump=function(){var t=this,e=this.props,n=e.prefix,a=e.size,e=e.locale,r=this.state.inputValue;return[N.default.createElement("span",{className:n+"pagination-jump-text"},e.goTo),N.default.createElement(f.default,{className:n+"pagination-jump-input",type:"text","aria-label":e.inputAriaLabel,size:a,value:r,onChange:this.onInputChange.bind(this),onKeyDown:function(e){e.keyCode===j.KEYCODE.ENTER&&t.handleJump(e)}}),N.default.createElement("span",{className:n+"pagination-jump-text"},e.page),N.default.createElement(d.default,{className:n+"pagination-jump-go",size:a,onClick:this.handleJump},e.go)]},I.prototype.renderPageDisplay=function(e,t){var n=this.props,a=n.prefix,n=n.pageNumberRender;return N.default.createElement("span",{className:a+"pagination-display"},N.default.createElement("em",null,n(e)),"/",n(t))},I.prototype.renderPageList=function(e,t){var n=this.props,a=n.prefix,n=n.pageShowCount,r=[];if(t<=n)for(var o=1;o<=t;o++)r.push(this.renderPageItem(o));else{var n=n-3,i=parseInt(n/2,10),s=void 0,l=void 0;r.push(this.renderPageItem(1)),l=e+i,(s=e-i)<=1&&(l=(s=2)+n),2=e.length&&-1=this.props.children.length?(this.update(this.props),this.changeSlide({message:"index",index:this.props.children.length-this.props.slidesToShow,currentSlide:this.state.currentSlide})):(n=[],Object.keys(t).forEach(function(e){e in a.props&&t[e]!==a.props[e]&&n.push(e)}),1===n.length&&"children"===n[0]||l.obj.shallowEqual(t,this.props)||this.update(this.props)),this.adaptHeight()},p.prototype.componentWillUnmount=function(){this.animationEndCallback&&clearTimeout(this.animationEndCallback),l.events.off(window,"resize",this.onWindowResized),this.state.autoPlayTimer&&clearInterval(this.state.autoPlayTimer)},p.prototype.onWindowResized=function(){this.update(this.props),this.setState({animating:!1}),clearTimeout(this.animationEndCallback),delete this.animationEndCallback},p.prototype.slickGoTo=function(e){"number"==typeof e&&this.changeSlide({message:"index",index:e,currentSlide:this.state.currentSlide})},p.prototype.onEnterArrow=function(e){this.arrowHoverHandler(e)},p.prototype.onLeaveArrow=function(){this.arrowHoverHandler()},p.prototype._instanceRefHandler=function(e,t){this[e]=t},p.prototype.render=function(){var e=this.props,t=e.prefix,n=e.animation,a=e.arrows,r=e.arrowSize,o=e.arrowPosition,i=e.arrowDirection,s=e.dots,l=e.dotsClass,u=e.cssEase,c=e.speed,d=e.infinite,f=e.centerMode,p=e.centerPadding,h=e.lazyLoad,m=e.dotsDirection,g=e.rtl,y=e.slidesToShow,v=e.slidesToScroll,_=e.variableWidth,b=e.vertical,w=e.verticalSwiping,M=e.focusOnSelect,S=e.children,k=e.dotsRender,e=e.triggerType,E=this.state,x=E.currentSlide,C=E.lazyLoadedList,T=E.slideCount,L=E.slideWidth,O=E.slideHeight,D=E.trackStyle,N=E.listHeight,E=E.dragging,u={prefix:t,animation:n,cssEase:u,speed:c,infinite:d,centerMode:f,focusOnSelect:M?this.selectHandler:null,currentSlide:x,lazyLoad:h,lazyLoadedList:C,rtl:g,slideWidth:L,slideHeight:O,slidesToShow:y,slidesToScroll:v,slideCount:T,trackStyle:D,variableWidth:_,vertical:b,verticalSwiping:w,triggerType:e},c=void 0,h=(!0===s&&yt.startX?1:-1),!0===this.props.verticalSwiping&&(t.swipeLength=Math.round(Math.sqrt(Math.pow(t.curY-t.startY,2))),a=t.curY>t.startY?1:-1),r=this.state.currentSlide,s=Math.ceil(this.state.slideCount/this.props.slidesToScroll),o=this.swipeDirection(this.state.touchObject),i=t.swipeLength,!1===this.props.infinite&&(0===r&&"right"===o||s<=r+1&&"left"===o)&&(i=t.swipeLength*this.props.edgeFriction,!1===this.state.edgeDragged)&&this.props.edgeEvent&&(this.props.edgeEvent(o),this.setState({edgeDragged:!0})),!1===this.state.swiped&&this.props.swipeEvent&&(this.props.swipeEvent(o),this.setState({swiped:!0})),this.setState({touchObject:t,swipeLeft:s=n+i*a,trackStyle:(0,u.getTrackCSS)((0,l.default)({left:s},this.props,this.state))}),Math.abs(t.curX-t.startX)<.8*Math.abs(t.curY-t.startY))||4t[t.length-1])e=t[t.length-1];else for(var a in t){if(e-1*n.state.swipeLeft)return t=e,!1}else if(e.offsetLeft-a+(n.getWidth(e)||0)/2>-1*n.state.swipeLeft)return t=e,!1;return!0}),Math.abs(t.dataset.index-this.state.currentSlide)||1):this.props.slidesToScroll},swipeEnd:function(e){if(this.state.dragging){var t=this.state.touchObject,n=this.state.listWidth/this.props.touchThreshold,a=this.swipeDirection(t);if(this.props.verticalSwiping&&(n=this.state.listHeight/this.props.touchThreshold),this.setState({dragging:!1,edgeDragged:!1,swiped:!1,swipeLeft:null,touchObject:{}}),t.swipeLength)if(t.swipeLength>n){e.preventDefault();var r=void 0,o=void 0;switch(a){case"left":case"down":o=this.state.currentSlide+this.getSlideCount(),r=this.props.swipeToSlide?this.checkNavigable(o):o,this.setState({currentDirection:0});break;case"right":case"up":o=this.state.currentSlide-this.getSlideCount(),r=this.props.swipeToSlide?this.checkNavigable(o):o,this.setState({currentDirection:1});break;default:r=this.state.currentSlide}this.slideHandler(r)}else{t=(0,u.getTrackLeft)((0,l.default)({slideIndex:this.state.currentSlide,trackRef:this.track},this.props,this.state));this.setState({trackStyle:(0,u.getTrackAnimateCSS)((0,l.default)({left:t},this.props,this.state))})}}else this.props.swipe&&e.preventDefault()},onInnerSliderEnter:function(){this.props.autoplay&&this.props.pauseOnHover&&this.pause()},onInnerSliderLeave:function(){this.props.autoplay&&this.props.pauseOnHover&&this.autoPlay()}},e.exports=t.default},function(e,t,n){"use strict";t.__esModule=!0;var g=a(n(3)),c=a(n(0)),d=a(n(25)),y=n(423);function a(e){return e&&e.__esModule?e:{default:e}}t.default={initialize:function(t){var n=this,e=d.default.findDOMNode(this.list),a=c.default.Children.count(t.children),r=this.getWidth(e)||0,o=this.getWidth(d.default.findDOMNode(this.track))||0,i=void 0,e=(i=t.vertical?r:(r-(t.centerMode&&2*parseInt(t.centerPadding)))/t.slidesToShow,this.getHeight(e.querySelector('[data-index="0"]'))||0),s=e*t.slidesToShow,l=t.slidesToShow||1,u="activeIndex"in t?t.activeIndex:t.defaultActiveIndex,l=t.rtl?a-1-(l-1)-u:u;this.setState({slideCount:a,slideWidth:i,listWidth:r,trackWidth:o,currentSlide:l,slideHeight:e,listHeight:s},function(){var e=(0,y.getTrackLeft)((0,g.default)({slideIndex:n.state.currentSlide,trackRef:n.track},t,n.state)),e=(0,y.getTrackCSS)((0,g.default)({left:e},t,n.state));n.setState({trackStyle:e}),n.autoPlay()})},update:function(e){this.initialize(e)},getWidth:function(e){return"clientWidth"in e?e.clientWidth:e&&e.getBoundingClientRect().width},getHeight:function(e){return"clientHeight"in e?e.clientHeight:e&&e.getBoundingClientRect().height},adaptHeight:function(){var e,t;this.props.adaptiveHeight&&(t='[data-index="'+this.state.currentSlide+'"]',this.list)&&(t=(e=d.default.findDOMNode(this.list)).querySelector(t).offsetHeight,e.style.height=t+"px")},canGoNext:function(e){var t=!0;return e.infinite||(e.centerMode?e.currentSlide>=e.slideCount-1&&(t=!1):(e.slideCount<=e.slidesToShow||e.currentSlide>=e.slideCount-e.slidesToShow)&&(t=!1)),t},slideHandler:function(e){var t=this,n=this.props.rtl,a=void 0,r=void 0,o=void 0;if(!this.props.waitForAnimate||!this.state.animating){if("fade"===this.props.animation)return r=this.state.currentSlide,!1===this.props.infinite&&(e<0||e>=this.state.slideCount)?void 0:(a=e<0?e+this.state.slideCount:e>=this.state.slideCount?e-this.state.slideCount:e,this.props.lazyLoad&&this.state.lazyLoadedList.indexOf(a)<0&&this.setState({lazyLoadedList:this.state.lazyLoadedList.concat(a)}),o=function(){t.setState({animating:!1}),t.props.onChange(a),delete t.animationEndCallback},this.props.onBeforeChange(this.state.currentSlide,a),this.setState({animating:!0,currentSlide:a},function(){this.animationEndCallback=setTimeout(o,this.props.speed+20)}),void this.autoPlay());a=e,n?a<0?!1===this.props.infinite?r=0:this.state.slideCount%this.props.slidesToScroll!=0?a+this.props.slidesToScroll<=0?(r=this.state.slideCount+a,a=this.state.slideCount-this.props.slidesToScroll):r=a=0:r=this.state.slideCount+a:r=a>=this.state.slideCount?!1===this.props.infinite?this.state.slideCount-this.props.slidesToShow:this.state.slideCount%this.props.slidesToScroll!=0?0:a-this.state.slideCount:a:r=a<0?!1===this.props.infinite?0:this.state.slideCount%this.props.slidesToScroll!=0?this.state.slideCount-this.state.slideCount%this.props.slidesToScroll:this.state.slideCount+a:a>=this.state.slideCount?!1===this.props.infinite?this.state.slideCount-this.props.slidesToShow:this.state.slideCount%this.props.slidesToScroll!=0?0:a-this.state.slideCount:a;var i,e=(0,y.getTrackLeft)((0,g.default)({slideIndex:a,trackRef:this.track},this.props,this.state)),s=(0,y.getTrackLeft)((0,g.default)({slideIndex:r,trackRef:this.track},this.props,this.state));if(!1===this.props.infinite&&(e=s),this.props.lazyLoad){for(var l=!0,u=[],c=this.state.slideCount,d=a<0?c+a:r,f=d;f=l.activeIndex?"visible":"hidden",c.transition="opacity "+l.speed+"ms "+l.cssEase,c.WebkitTransition="opacity "+l.speed+"ms "+l.cssEase,l.vertical?c.top=-l.activeIndex*l.slideHeight:c.left=-l.activeIndex*l.slideWidth),l.vertical&&(c.width="100%"),c),u=(c=(0,v.default)({activeIndex:e},d),a=c.prefix,u=r=i=void 0,o=(u=c.rtl?c.slideCount-1-c.activeIndex:c.activeIndex)<0||u>=c.slideCount,c.centerMode?(n=Math.floor(c.slidesToShow/2),r=(u-c.currentSlide)%c.slideCount==0,u>c.currentSlide-n-1&&u<=c.currentSlide+n&&(i=!0)):i=c.currentSlide<=u&&u=u,u=(0,S.default)(((v={})[o+"upload-list-item"]=!0,v[o+"hidden"]=u,v)),v=this.props.children||i.card.addPhoto,d=r?k.func.prevent:d,_=k.obj.pickOthers(C.propTypes,this.props),b=k.obj.pickOthers(E.default.propTypes,_);if(h&&"function"==typeof m)return e=(0,S.default)(((e={})[o+"form-preview"]=!0,e[s]=!!s,e)),M.default.createElement("div",{style:l,className:e},m(this.state.value,this.props));return M.default.createElement(E.default,(0,w.default)({className:s,style:l,listType:"card",closable:!0,locale:i,value:this.state.value,onRemove:d,onCancel:f,onPreview:c,itemRender:g,isPreview:h,uploader:this.uploaderRef,reUpload:y,showDownload:n},_),M.default.createElement(x.default,(0,w.default)({},b,{shape:"card",prefix:o,disabled:r,action:a,timeout:p,isPreview:h,value:this.state.value,onProgress:this.onProgress,onChange:this.onChange,ref:function(e){return t.saveRef(e)},className:u}),v))},c=n=C,n.displayName="Card",n.propTypes={prefix:s.default.string,locale:s.default.object,children:s.default.object,value:s.default.oneOfType([s.default.array,s.default.object]),defaultValue:s.default.oneOfType([s.default.array,s.default.object]),onPreview:s.default.func,onChange:s.default.func,onRemove:s.default.func,onCancel:s.default.func,itemRender:s.default.func,reUpload:s.default.bool,showDownload:s.default.bool,onProgress:s.default.func,isPreview:s.default.bool,renderPreview:s.default.func},n.defaultProps={prefix:"next-",locale:u.default.Upload,showDownload:!0,onChange:k.func.noop,onPreview:k.func.noop,onProgress:k.func.noop},a=function(){var n=this;this.onProgress=function(e,t){n.setState({value:e}),n.props.onProgress(e,t)},this.onChange=function(e,t){"value"in n.props||n.setState({value:e}),n.props.onChange(e,t)}};var f,i=c;function C(e){(0,r.default)(this,C);var t=(0,o.default)(this,f.call(this,e)),n=(a.call(t),void 0),n="value"in e?e.value:e.defaultValue;return t.state={value:Array.isArray(n)?n:[],uploaderRef:t.uploaderRef},t}t.default=(0,l.polyfill)(i),e.exports=t.default},function(e,t,n){"use strict";t.__esModule=!0;var u=m(n(3)),c=m(n(17)),o=m(n(4)),i=m(n(7)),a=m(n(8)),d=m(n(0)),r=m(n(5)),f=m(n(19)),p=m(n(26)),s=n(11),l=m(n(44)),h=m(n(193));function m(e){return e&&e.__esModule?e:{default:e}}g=d.default.Component,(0,a.default)(y,g),y.prototype.abort=function(e){this.uploaderRef.abort(e)},y.prototype.startUpload=function(){this.uploaderRef.startUpload()},y.prototype.render=function(){var e=this.props,t=e.className,n=e.style,a=e.shape,r=e.locale,o=e.prefix,i=e.listType,e=(0,c.default)(e,["className","style","shape","locale","prefix","listType"]),s=o+"upload-drag",t=(0,f.default)(((l={})[s]=!0,l[s+"-over"]=this.state.dragOver,l[t]=!!t,l)),l=this.props.children||d.default.createElement("div",{className:t},d.default.createElement("p",{className:s+"-icon"},d.default.createElement(p.default,{size:"large",className:s+"-upload-icon"})),d.default.createElement("p",{className:s+"-text"},r.drag.text),d.default.createElement("p",{className:s+"-hint"},r.drag.hint));return d.default.createElement(h.default,(0,u.default)({},e,{prefix:o,shape:a,listType:i,dragable:!0,style:n,onDragOver:this.onDragOver,onDragLeave:this.onDragLeave,onDrop:this.onDrop,ref:this.saveUploaderRef}),l)},a=n=y,n.propTypes={prefix:r.default.string,locale:r.default.object,shape:r.default.string,onDragOver:r.default.func,onDragLeave:r.default.func,onDrop:r.default.func,limit:r.default.number,className:r.default.string,style:r.default.object,defaultValue:r.default.array,children:r.default.node,listType:r.default.string,timeout:r.default.number},n.defaultProps={prefix:"next-",onDragOver:s.func.noop,onDragLeave:s.func.noop,onDrop:s.func.noop,locale:l.default.Upload};var g,r=a;function y(){var e,t;(0,o.default)(this,y);for(var n=arguments.length,a=Array(n),r=0;r cachedBuilders; - private MockMvc mockmvc; private ConfigurableEnvironment environment; - @BeforeAll - static void setUpBeforeAll() { - cachedBuilders = (List) ReflectionTestUtils.getField(ModuleStateHolder.getInstance(), - "moduleStateBuilders"); - List mockBuilders = new LinkedList<>(); - mockBuilders.add(new ModuleStateBuilder() { - @Override - public ModuleState build() { - ModuleState moduleState = new ModuleState("mock"); - moduleState.newState(Constants.STARTUP_MODE_STATE, EnvUtil.STANDALONE_MODE_CLUSTER); - moduleState.newState(Constants.FUNCTION_MODE_STATE, null); - moduleState.newState(Constants.NACOS_VERSION, VersionUtils.version); - return moduleState; - } - - @Override - public boolean isCacheable() { - return false; - } - }); - ReflectionTestUtils.setField(ModuleStateHolder.getInstance(), "moduleStateBuilders", mockBuilders); - } - @BeforeEach void setUp() { environment = new MockEnvironment(); EnvUtil.setEnvironment(environment); + Map mock = new HashMap<>(); + mock.put(Constants.STARTUP_MODE_STATE, EnvUtil.STANDALONE_MODE_CLUSTER); + mock.put(Constants.FUNCTION_MODE_STATE, null); + mock.put(Constants.NACOS_VERSION, VersionUtils.version); + when(stateService.getServerState()).thenReturn(mock); mockmvc = MockMvcBuilders.standaloneSetup(serverStateController).build(); } - @AfterAll - static void tearDownAfterAll() { - ReflectionTestUtils.setField(ModuleStateHolder.getInstance(), "moduleStateBuilders", cachedBuilders); - } - @Test void serverState() throws Exception { MockHttpServletRequestBuilder builder = MockMvcRequestBuilders.get(CONSOLE_URL); diff --git a/console/src/test/java/com/alibaba/nacos/console/controller/v2/NamespaceControllerV2Test.java b/console/src/test/java/com/alibaba/nacos/console/controller/v2/NamespaceControllerV2Test.java index 658b0706a6..e0b087b873 100644 --- a/console/src/test/java/com/alibaba/nacos/console/controller/v2/NamespaceControllerV2Test.java +++ b/console/src/test/java/com/alibaba/nacos/console/controller/v2/NamespaceControllerV2Test.java @@ -19,7 +19,7 @@ package com.alibaba.nacos.console.controller.v2; import com.alibaba.nacos.api.exception.NacosException; import com.alibaba.nacos.api.model.v2.ErrorCode; import com.alibaba.nacos.api.model.v2.Result; -import com.alibaba.nacos.core.namespace.model.Namespace; +import com.alibaba.nacos.api.model.response.Namespace; import com.alibaba.nacos.core.namespace.model.NamespaceTypeEnum; import com.alibaba.nacos.core.namespace.model.form.NamespaceForm; import com.alibaba.nacos.core.namespace.repository.NamespacePersistService; diff --git a/console/src/test/java/com/alibaba/nacos/console/controller/v3/core/ConsoleNamespaceControllerTest.java b/console/src/test/java/com/alibaba/nacos/console/controller/v3/core/ConsoleNamespaceControllerTest.java index 7335122087..0e40929deb 100644 --- a/console/src/test/java/com/alibaba/nacos/console/controller/v3/core/ConsoleNamespaceControllerTest.java +++ b/console/src/test/java/com/alibaba/nacos/console/controller/v3/core/ConsoleNamespaceControllerTest.java @@ -20,7 +20,7 @@ package com.alibaba.nacos.console.controller.v3.core; import com.alibaba.nacos.api.model.v2.ErrorCode; import com.alibaba.nacos.api.model.v2.Result; import com.alibaba.nacos.console.proxy.core.NamespaceProxy; -import com.alibaba.nacos.core.namespace.model.Namespace; +import com.alibaba.nacos.api.model.response.Namespace; import com.alibaba.nacos.core.namespace.model.form.NamespaceForm; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/console/src/test/java/com/alibaba/nacos/console/controller/v3/naming/ConsoleInstanceControllerTest.java b/console/src/test/java/com/alibaba/nacos/console/controller/v3/naming/ConsoleInstanceControllerTest.java index e9e8c51c5b..a7dd855ac2 100644 --- a/console/src/test/java/com/alibaba/nacos/console/controller/v3/naming/ConsoleInstanceControllerTest.java +++ b/console/src/test/java/com/alibaba/nacos/console/controller/v3/naming/ConsoleInstanceControllerTest.java @@ -17,6 +17,7 @@ package com.alibaba.nacos.console.controller.v3.naming; +import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.api.model.v2.ErrorCode; import com.alibaba.nacos.api.model.v2.Result; import com.alibaba.nacos.api.naming.pojo.Instance; @@ -25,7 +26,6 @@ import com.alibaba.nacos.naming.misc.SwitchDomain; import com.alibaba.nacos.naming.model.form.InstanceForm; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -45,8 +45,8 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; /** * ConsoleInstanceControllerTest. @@ -74,9 +74,9 @@ public class ConsoleInstanceControllerTest { @Test void testGetInstanceList() throws Exception { - ObjectNode instances = JsonNodeFactory.instance.objectNode(); - when(instanceProxy.listInstances(anyString(), anyString(), anyString(), anyString(), anyInt(), - anyInt())).thenReturn(instances); + Page page = new Page<>(); + doReturn(page).when(instanceProxy) + .listInstances(anyString(), anyString(), anyString(), anyString(), anyInt(), anyInt()); MockHttpServletRequestBuilder builder = MockMvcRequestBuilders.get("/v3/console/ns/instance/list") .param("namespaceId", "default").param("serviceName", "testService").param("pageNo", "1") diff --git a/console/src/test/java/com/alibaba/nacos/console/controller/v3/naming/ConsoleServiceControllerTest.java b/console/src/test/java/com/alibaba/nacos/console/controller/v3/naming/ConsoleServiceControllerTest.java index 907c6deabb..fba2c9332f 100644 --- a/console/src/test/java/com/alibaba/nacos/console/controller/v3/naming/ConsoleServiceControllerTest.java +++ b/console/src/test/java/com/alibaba/nacos/console/controller/v3/naming/ConsoleServiceControllerTest.java @@ -21,6 +21,7 @@ import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.api.model.v2.ErrorCode; import com.alibaba.nacos.api.model.v2.Result; import com.alibaba.nacos.api.naming.pojo.maintainer.ServiceDetailInfo; +import com.alibaba.nacos.api.naming.pojo.maintainer.ServiceView; import com.alibaba.nacos.api.naming.pojo.maintainer.SubscriberInfo; import com.alibaba.nacos.console.proxy.naming.ServiceProxy; import com.alibaba.nacos.core.model.form.AggregationForm; @@ -146,9 +147,9 @@ public class ConsoleServiceControllerTest { serviceForm.setNamespaceId("testNamespace"); serviceForm.setGroupName("testGroup"); Result actual = consoleServiceController.getServiceDetail(serviceForm); - + verify(serviceProxy).getServiceDetail(any(String.class), any(String.class), any(String.class)); - + assertEquals(ErrorCode.SUCCESS.getCode(), actual.getCode()); // controller transfer ServiceDetailInfo to old console result assertNotEquals(serviceDetail, actual.getData()); @@ -202,8 +203,11 @@ public class ConsoleServiceControllerTest { @Test void testGetServiceList() throws Exception { + Page expected = new Page<>(); + expected.setTotalCount(1); + expected.getPageItems().add(new ServiceView()); when(serviceProxy.getServiceList(anyBoolean(), anyString(), anyInt(), anyInt(), anyString(), anyString(), - anyBoolean())).thenReturn(Collections.singletonList(new Object())); + anyBoolean())).thenReturn(expected); PageForm pageForm = new PageForm(); pageForm.setPageNo(1); pageForm.setPageSize(10); @@ -217,8 +221,8 @@ public class ConsoleServiceControllerTest { anyBoolean()); assertEquals(ErrorCode.SUCCESS.getCode(), actual.getCode()); - assertInstanceOf(List.class, actual.getData()); - assertEquals(1, ((List) actual.getData()).size()); + assertInstanceOf(Page.class, actual.getData()); + assertEquals(1, ((Page) actual.getData()).getPageItems().size()); } @Test diff --git a/core/src/main/java/com/alibaba/nacos/core/auth/NacosServerAuthConfig.java b/core/src/main/java/com/alibaba/nacos/core/auth/NacosServerAuthConfig.java index 3c3e4be41b..078cb3d68c 100644 --- a/core/src/main/java/com/alibaba/nacos/core/auth/NacosServerAuthConfig.java +++ b/core/src/main/java/com/alibaba/nacos/core/auth/NacosServerAuthConfig.java @@ -18,15 +18,12 @@ package com.alibaba.nacos.core.auth; import com.alibaba.nacos.api.exception.runtime.NacosRuntimeException; import com.alibaba.nacos.auth.config.AuthErrorCode; -import com.alibaba.nacos.auth.config.AuthModuleStateBuilder; import com.alibaba.nacos.auth.config.NacosAuthConfig; import com.alibaba.nacos.common.utils.StringUtils; import com.alibaba.nacos.core.config.AbstractDynamicConfig; import com.alibaba.nacos.plugin.auth.constant.ApiType; import com.alibaba.nacos.plugin.auth.constant.Constants; import com.alibaba.nacos.sys.env.EnvUtil; -import com.alibaba.nacos.sys.module.ModuleState; -import com.alibaba.nacos.sys.module.ModuleStateHolder; import com.alibaba.nacos.sys.utils.PropertiesUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -156,11 +153,6 @@ public class NacosServerAuthConfig extends AbstractDynamicConfig implements Naco serverIdentityKey = EnvUtil.getProperty(Constants.Auth.NACOS_CORE_AUTH_SERVER_IDENTITY_KEY, ""); serverIdentityValue = EnvUtil.getProperty(Constants.Auth.NACOS_CORE_AUTH_SERVER_IDENTITY_VALUE, ""); refreshPluginProperties(); - ModuleStateHolder.getInstance().getModuleState(AuthModuleStateBuilder.AUTH_MODULE) - .ifPresent(moduleState -> { - ModuleState temp = new AuthModuleStateBuilder().build(); - moduleState.getStates().putAll(temp.getStates()); - }); } catch (Exception e) { LOGGER.warn("Upgrade auth config from env failed, use old value", e); } diff --git a/core/src/main/java/com/alibaba/nacos/core/controller/v3/NamespaceControllerV3.java b/core/src/main/java/com/alibaba/nacos/core/controller/v3/NamespaceControllerV3.java index 843b29f33f..7b7c6d37e1 100644 --- a/core/src/main/java/com/alibaba/nacos/core/controller/v3/NamespaceControllerV3.java +++ b/core/src/main/java/com/alibaba/nacos/core/controller/v3/NamespaceControllerV3.java @@ -19,11 +19,11 @@ package com.alibaba.nacos.core.controller.v3; import com.alibaba.nacos.api.annotation.NacosApi; import com.alibaba.nacos.api.exception.NacosException; import com.alibaba.nacos.api.exception.api.NacosApiException; +import com.alibaba.nacos.api.model.response.Namespace; import com.alibaba.nacos.api.model.v2.ErrorCode; import com.alibaba.nacos.api.model.v2.Result; import com.alibaba.nacos.auth.annotation.Secured; import com.alibaba.nacos.common.utils.StringUtils; -import com.alibaba.nacos.core.namespace.model.Namespace; import com.alibaba.nacos.core.namespace.model.form.NamespaceForm; import com.alibaba.nacos.core.namespace.repository.NamespacePersistService; import com.alibaba.nacos.core.service.NamespaceOperationService; @@ -53,7 +53,7 @@ import static com.alibaba.nacos.core.utils.Commons.NACOS_ADMIN_CORE_CONTEXT_V3; */ @NacosApi @RestController -@RequestMapping(NACOS_ADMIN_CORE_CONTEXT_V3 + "namespace") +@RequestMapping(NACOS_ADMIN_CORE_CONTEXT_V3 + "/namespace") public class NamespaceControllerV3 { private final NamespaceOperationService namespaceOperationService; @@ -116,6 +116,7 @@ public class NamespaceControllerV3 { if (StringUtils.isBlank(namespaceId)) { namespaceId = UUID.randomUUID().toString(); } else { + // TODO check should be parameter check filter. namespaceId = namespaceId.trim(); if (!namespaceIdCheckPattern.matcher(namespaceId).matches()) { throw new NacosApiException(HttpStatus.BAD_REQUEST.value(), ErrorCode.ILLEGAL_NAMESPACE, @@ -125,11 +126,6 @@ public class NamespaceControllerV3 { throw new NacosApiException(HttpStatus.BAD_REQUEST.value(), ErrorCode.ILLEGAL_NAMESPACE, "too long namespaceId, over " + NAMESPACE_ID_MAX_LENGTH); } - // check unique - if (namespacePersistService.tenantInfoCountByTenantId(namespaceId) > 0) { - throw new NacosApiException(HttpStatus.BAD_REQUEST.value(), ErrorCode.ILLEGAL_NAMESPACE, - "the namespaceId is existed, namespaceId: " + namespaceForm.getNamespaceId()); - } } // contains illegal chars if (!namespaceNameCheckPattern.matcher(namespaceName).matches()) { diff --git a/core/src/main/java/com/alibaba/nacos/core/controller/v3/ServerStateController.java b/core/src/main/java/com/alibaba/nacos/core/controller/v3/ServerStateController.java new file mode 100644 index 0000000000..fc08ab2bc9 --- /dev/null +++ b/core/src/main/java/com/alibaba/nacos/core/controller/v3/ServerStateController.java @@ -0,0 +1,84 @@ +/* + * Copyright 1999-2025 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.nacos.core.controller.v3; + +import com.alibaba.nacos.api.annotation.NacosApi; +import com.alibaba.nacos.api.exception.NacosException; +import com.alibaba.nacos.api.model.v2.Result; +import com.alibaba.nacos.core.cluster.health.ModuleHealthCheckerHolder; +import com.alibaba.nacos.core.cluster.health.ReadinessResult; +import com.alibaba.nacos.core.service.NacosServerStateService; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +import static com.alibaba.nacos.core.utils.Commons.NACOS_ADMIN_CORE_CONTEXT_V3; + +/** + * Server state controller for admin API. + * + * @author xiweng.yy + */ +@NacosApi +@RestController +@RequestMapping(NACOS_ADMIN_CORE_CONTEXT_V3 + "/state") +public class ServerStateController { + + private final NacosServerStateService stateService; + + public ServerStateController(NacosServerStateService stateService) { + this.stateService = stateService; + } + + /** + * Get server state of current server. + * + * @return state key-value map. + */ + @GetMapping() + public Result> serverState() { + return Result.success(stateService.getServerState()); + } + + /** + * Whether the Nacos is in broken states or not, and cannot recover except by being restarted. + * + * @return HTTP code equal to 200 indicates that Nacos is in right states. HTTP code equal to 500 indicates that + * Nacos is in broken states. + */ + @GetMapping("/liveness") + public Result liveness() { + return Result.success("ok"); + } + + /** + * Ready to receive the request or not. + * + * @return HTTP code equal to 200 indicates that Nacos is ready. HTTP code equal to 500 indicates that Nacos is not + * ready. + */ + @GetMapping("/readiness") + public Result readiness() throws NacosException { + ReadinessResult result = ModuleHealthCheckerHolder.getInstance().checkReadiness(); + if (result.isSuccess()) { + return Result.success("ok"); + } + return Result.failure(result.getResultMessage()); + } +} diff --git a/core/src/main/java/com/alibaba/nacos/core/namespace/injector/AbstractNamespaceDetailInjector.java b/core/src/main/java/com/alibaba/nacos/core/namespace/injector/AbstractNamespaceDetailInjector.java index 19e136147f..392c11648c 100644 --- a/core/src/main/java/com/alibaba/nacos/core/namespace/injector/AbstractNamespaceDetailInjector.java +++ b/core/src/main/java/com/alibaba/nacos/core/namespace/injector/AbstractNamespaceDetailInjector.java @@ -16,7 +16,7 @@ package com.alibaba.nacos.core.namespace.injector; -import com.alibaba.nacos.core.namespace.model.Namespace; +import com.alibaba.nacos.api.model.response.Namespace; /** * Namespace detail injector. diff --git a/core/src/main/java/com/alibaba/nacos/core/namespace/injector/NamespaceDetailInjectorHolder.java b/core/src/main/java/com/alibaba/nacos/core/namespace/injector/NamespaceDetailInjectorHolder.java index a56dddbddd..d742ec5f01 100644 --- a/core/src/main/java/com/alibaba/nacos/core/namespace/injector/NamespaceDetailInjectorHolder.java +++ b/core/src/main/java/com/alibaba/nacos/core/namespace/injector/NamespaceDetailInjectorHolder.java @@ -16,7 +16,7 @@ package com.alibaba.nacos.core.namespace.injector; -import com.alibaba.nacos.core.namespace.model.Namespace; +import com.alibaba.nacos.api.model.response.Namespace; import java.util.HashSet; import java.util.Set; diff --git a/core/src/main/java/com/alibaba/nacos/core/namespace/model/Namespace.java b/core/src/main/java/com/alibaba/nacos/core/namespace/model/Namespace.java deleted file mode 100644 index 65d9e62339..0000000000 --- a/core/src/main/java/com/alibaba/nacos/core/namespace/model/Namespace.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 1999-2023 Alibaba Group Holding Ltd. - * - * Licensed 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 com.alibaba.nacos.core.namespace.model; - -/** - * Namespace. - * - * @author diamond - */ -public class Namespace { - - private String namespace; - - private String namespaceShowName; - - private String namespaceDesc; - - private int quota; - - private int configCount; - - /** - * see {@link NamespaceTypeEnum}. - */ - private int type; - - public String getNamespaceShowName() { - return namespaceShowName; - } - - public void setNamespaceShowName(String namespaceShowName) { - this.namespaceShowName = namespaceShowName; - } - - public String getNamespace() { - return namespace; - } - - public void setNamespace(String namespace) { - this.namespace = namespace; - } - - public Namespace() { - } - - public Namespace(String namespace, String namespaceShowName) { - this.namespace = namespace; - this.namespaceShowName = namespaceShowName; - } - - public Namespace(String namespace, String namespaceShowName, int quota, int configCount, int type) { - this.namespace = namespace; - this.namespaceShowName = namespaceShowName; - this.quota = quota; - this.configCount = configCount; - this.type = type; - } - - public Namespace(String namespace, String namespaceShowName, String namespaceDesc, int quota, int configCount, - int type) { - this.namespace = namespace; - this.namespaceShowName = namespaceShowName; - this.quota = quota; - this.configCount = configCount; - this.type = type; - this.namespaceDesc = namespaceDesc; - } - - public String getNamespaceDesc() { - return namespaceDesc; - } - - public void setNamespaceDesc(String namespaceDesc) { - this.namespaceDesc = namespaceDesc; - } - - public int getQuota() { - return quota; - } - - public void setQuota(int quota) { - this.quota = quota; - } - - public int getConfigCount() { - return configCount; - } - - public void setConfigCount(int configCount) { - this.configCount = configCount; - } - - public int getType() { - return type; - } - - public void setType(int type) { - this.type = type; - } - -} diff --git a/core/src/main/java/com/alibaba/nacos/core/namespace/model/TenantInfo.java b/core/src/main/java/com/alibaba/nacos/core/namespace/model/TenantInfo.java index e12b343a87..2a5838c27e 100644 --- a/core/src/main/java/com/alibaba/nacos/core/namespace/model/TenantInfo.java +++ b/core/src/main/java/com/alibaba/nacos/core/namespace/model/TenantInfo.java @@ -21,7 +21,7 @@ import java.io.Serializable; /** * TenantInfo. * - *

Old name of {@link Namespace}

+ *

Old name of {@link com.alibaba.nacos.api.model.response.Namespace}

* * @author Nacos */ diff --git a/core/src/main/java/com/alibaba/nacos/core/service/NacosServerStateService.java b/core/src/main/java/com/alibaba/nacos/core/service/NacosServerStateService.java new file mode 100644 index 0000000000..62a90ab7a9 --- /dev/null +++ b/core/src/main/java/com/alibaba/nacos/core/service/NacosServerStateService.java @@ -0,0 +1,46 @@ +/* + * Copyright 1999-2025 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.nacos.core.service; + +import com.alibaba.nacos.sys.module.ModuleState; +import com.alibaba.nacos.sys.module.ModuleStateHolder; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.Map; + +/** + * Nacos server state service. + * + * @author xiweng.yy + */ +@Service +public class NacosServerStateService { + + /** + * Get current server states. + * + * @return server states key-value map. + */ + public Map getServerState() { + Map serverState = new HashMap<>(4); + for (ModuleState each : ModuleStateHolder.getInstance().getAllModuleStates()) { + each.getStates().forEach((s, o) -> serverState.put(s, null == o ? null : o.toString())); + } + return serverState; + } +} diff --git a/core/src/main/java/com/alibaba/nacos/core/service/NamespaceOperationService.java b/core/src/main/java/com/alibaba/nacos/core/service/NamespaceOperationService.java index 15ae7aa897..3cb65af98f 100644 --- a/core/src/main/java/com/alibaba/nacos/core/service/NamespaceOperationService.java +++ b/core/src/main/java/com/alibaba/nacos/core/service/NamespaceOperationService.java @@ -18,11 +18,11 @@ package com.alibaba.nacos.core.service; import com.alibaba.nacos.api.exception.NacosException; import com.alibaba.nacos.api.exception.api.NacosApiException; +import com.alibaba.nacos.api.model.response.Namespace; import com.alibaba.nacos.api.model.v2.ErrorCode; import com.alibaba.nacos.common.utils.NamespaceUtil; import com.alibaba.nacos.common.utils.StringUtils; import com.alibaba.nacos.core.namespace.injector.NamespaceDetailInjectorHolder; -import com.alibaba.nacos.core.namespace.model.Namespace; import com.alibaba.nacos.core.namespace.model.NamespaceTypeEnum; import com.alibaba.nacos.core.namespace.model.TenantInfo; import com.alibaba.nacos.core.namespace.repository.NamespacePersistService; diff --git a/core/src/test/java/com/alibaba/nacos/core/controller/v3/NamespaceControllerV3Test.java b/core/src/test/java/com/alibaba/nacos/core/controller/v3/NamespaceControllerV3Test.java index a3d24b0acf..75f719cddb 100644 --- a/core/src/test/java/com/alibaba/nacos/core/controller/v3/NamespaceControllerV3Test.java +++ b/core/src/test/java/com/alibaba/nacos/core/controller/v3/NamespaceControllerV3Test.java @@ -18,9 +18,9 @@ package com.alibaba.nacos.core.controller.v3; import com.alibaba.nacos.api.exception.NacosException; import com.alibaba.nacos.api.exception.api.NacosApiException; +import com.alibaba.nacos.api.model.response.Namespace; import com.alibaba.nacos.api.model.v2.ErrorCode; import com.alibaba.nacos.api.model.v2.Result; -import com.alibaba.nacos.core.namespace.model.Namespace; import com.alibaba.nacos.core.namespace.model.form.NamespaceForm; import com.alibaba.nacos.core.namespace.repository.NamespacePersistService; import com.alibaba.nacos.core.service.NamespaceOperationService; @@ -102,19 +102,16 @@ class NamespaceControllerV3Test { form.setNamespaceName(TEST_NAMESPACE_NAME); form.setNamespaceDesc(TEST_NAMESPACE_DESC); - when(namespaceOperationService.createNamespace( - TEST_NAMESPACE_ID, - TEST_NAMESPACE_NAME, - TEST_NAMESPACE_DESC - )).thenReturn(true); + when(namespaceOperationService.createNamespace(TEST_NAMESPACE_ID, TEST_NAMESPACE_NAME, + TEST_NAMESPACE_DESC)).thenReturn(true); Result result = namespaceControllerV3.createNamespace(form); Assertions.assertNotNull(result); Assertions.assertEquals(ErrorCode.SUCCESS.getCode(), (int) result.getCode()); Assertions.assertTrue(result.getData()); - verify(namespaceOperationService, times(1)) - .createNamespace(TEST_NAMESPACE_ID, TEST_NAMESPACE_NAME, TEST_NAMESPACE_DESC); + verify(namespaceOperationService, times(1)).createNamespace(TEST_NAMESPACE_ID, TEST_NAMESPACE_NAME, + TEST_NAMESPACE_DESC); } @Test @@ -138,19 +135,15 @@ class NamespaceControllerV3Test { form.setNamespaceName("updated-name"); form.setNamespaceDesc("updated-desc"); - when(namespaceOperationService.editNamespace( - TEST_NAMESPACE_ID, - "updated-name", - "updated-desc" - )).thenReturn(true); + when(namespaceOperationService.editNamespace(TEST_NAMESPACE_ID, "updated-name", "updated-desc")).thenReturn( + true); Result result = namespaceControllerV3.updateNamespace(form); Assertions.assertNotNull(result); Assertions.assertEquals(ErrorCode.SUCCESS.getCode(), (int) result.getCode()); Assertions.assertTrue(result.getData()); - verify(namespaceOperationService, times(1)) - .editNamespace(TEST_NAMESPACE_ID, "updated-name", "updated-desc"); + verify(namespaceOperationService, times(1)).editNamespace(TEST_NAMESPACE_ID, "updated-name", "updated-desc"); } @Test diff --git a/core/src/test/java/com/alibaba/nacos/core/service/NamespaceOperationServiceTest.java b/core/src/test/java/com/alibaba/nacos/core/service/NamespaceOperationServiceTest.java index 061c8c4f1d..5585646a20 100644 --- a/core/src/test/java/com/alibaba/nacos/core/service/NamespaceOperationServiceTest.java +++ b/core/src/test/java/com/alibaba/nacos/core/service/NamespaceOperationServiceTest.java @@ -21,7 +21,7 @@ import com.alibaba.nacos.api.exception.NacosException; import com.alibaba.nacos.api.exception.api.NacosApiException; import com.alibaba.nacos.common.utils.NamespaceUtil; import com.alibaba.nacos.core.namespace.injector.AbstractNamespaceDetailInjector; -import com.alibaba.nacos.core.namespace.model.Namespace; +import com.alibaba.nacos.api.model.response.Namespace; import com.alibaba.nacos.core.namespace.model.NamespaceTypeEnum; import com.alibaba.nacos.core.namespace.model.TenantInfo; import com.alibaba.nacos.core.namespace.repository.NamespacePersistService; diff --git a/distribution/conf/application.properties b/distribution/conf/application.properties index 3bf95275bf..16b51447e6 100644 --- a/distribution/conf/application.properties +++ b/distribution/conf/application.properties @@ -190,6 +190,9 @@ nacos.console.port=8080 ### Nacos Server Web context path: nacos.console.contextPath= +### Nacos Server context path, which link to nacos server `nacos.server.contextPath`, works when deployment type is `console` +nacos.console.remote.server.context-path=/nacos + #************** Console UI Configuration ***************# ### Turn on/off the nacos console ui. diff --git a/maintainer-client/src/main/java/com/alibaba/nacos/maintainer/client/constants/Constants.java b/maintainer-client/src/main/java/com/alibaba/nacos/maintainer/client/constants/Constants.java index eb7171427e..99d2aaae65 100644 --- a/maintainer-client/src/main/java/com/alibaba/nacos/maintainer/client/constants/Constants.java +++ b/maintainer-client/src/main/java/com/alibaba/nacos/maintainer/client/constants/Constants.java @@ -71,6 +71,8 @@ public class Constants { public static final String CORE_OPS_ADMIN_PATH = "/v3/admin/core/ops"; public static final String CORE_NAMESPACE_ADMIN_PATH = "/v3/admin/core/namespace"; + + public static final String CORE_STATE_ADMIN_PATH = "/v3/admin/core/state"; } } diff --git a/maintainer-client/src/main/java/com/alibaba/nacos/maintainer/client/core/AbstractCoreMaintainerService.java b/maintainer-client/src/main/java/com/alibaba/nacos/maintainer/client/core/AbstractCoreMaintainerService.java index 96d8e7fe6a..15fafed19c 100644 --- a/maintainer-client/src/main/java/com/alibaba/nacos/maintainer/client/core/AbstractCoreMaintainerService.java +++ b/maintainer-client/src/main/java/com/alibaba/nacos/maintainer/client/core/AbstractCoreMaintainerService.java @@ -52,6 +52,33 @@ public abstract class AbstractCoreMaintainerService implements CoreMaintainerSer ParamUtil.initSerialization(); } + @Override + public Map getServerState() throws NacosException { + HttpRequest httpRequest = new HttpRequest.Builder().setHttpMethod(HttpMethod.GET) + .setPath(Constants.AdminApiPath.CORE_STATE_ADMIN_PATH).build(); + HttpRestResult httpRestResult = clientHttpProxy.executeSyncHttpRequest(httpRequest); + Result> result = JacksonUtils.toObj(httpRestResult.getData(), + new TypeReference>>() { + }); + return result.getData(); + } + + @Override + public Boolean liveness() throws NacosException { + HttpRequest httpRequest = new HttpRequest.Builder().setHttpMethod(HttpMethod.GET) + .setPath(Constants.AdminApiPath.CORE_STATE_ADMIN_PATH + "/liveness").build(); + HttpRestResult httpRestResult = clientHttpProxy.executeSyncHttpRequest(httpRequest); + return httpRestResult.ok(); + } + + @Override + public Boolean readiness() throws NacosException { + HttpRequest httpRequest = new HttpRequest.Builder().setHttpMethod(HttpMethod.GET) + .setPath(Constants.AdminApiPath.CORE_OPS_ADMIN_PATH + "/readiness").build(); + HttpRestResult httpRestResult = clientHttpProxy.executeSyncHttpRequest(httpRequest); + return httpRestResult.ok(); + } + @Override public String raftOps(String command, String value, String groupId) throws NacosException { Map params = new HashMap<>(8); @@ -201,9 +228,8 @@ public abstract class AbstractCoreMaintainerService implements CoreMaintainerSer HttpRequest httpRequest = new HttpRequest.Builder().setHttpMethod(HttpMethod.GET) .setPath(Constants.AdminApiPath.CORE_NAMESPACE_ADMIN_PATH).setParamValue(params).build(); HttpRestResult httpRestResult = clientHttpProxy.executeSyncHttpRequest(httpRequest); - Result result = JacksonUtils.toObj(httpRestResult.getData(), - new TypeReference>() { - }); + Result result = JacksonUtils.toObj(httpRestResult.getData(), new TypeReference>() { + }); return result.getData(); } @@ -218,9 +244,8 @@ public abstract class AbstractCoreMaintainerService implements CoreMaintainerSer HttpRequest httpRequest = new HttpRequest.Builder().setHttpMethod(HttpMethod.POST) .setPath(Constants.AdminApiPath.CORE_NAMESPACE_ADMIN_PATH).setParamValue(params).build(); HttpRestResult httpRestResult = clientHttpProxy.executeSyncHttpRequest(httpRequest); - Result result = JacksonUtils.toObj(httpRestResult.getData(), - new TypeReference>() { - }); + Result result = JacksonUtils.toObj(httpRestResult.getData(), new TypeReference>() { + }); return result.getData(); } @@ -235,9 +260,8 @@ public abstract class AbstractCoreMaintainerService implements CoreMaintainerSer HttpRequest httpRequest = new HttpRequest.Builder().setHttpMethod(HttpMethod.PUT) .setPath(Constants.AdminApiPath.CORE_NAMESPACE_ADMIN_PATH).setParamValue(params).build(); HttpRestResult httpRestResult = clientHttpProxy.executeSyncHttpRequest(httpRequest); - Result result = JacksonUtils.toObj(httpRestResult.getData(), - new TypeReference>() { - }); + Result result = JacksonUtils.toObj(httpRestResult.getData(), new TypeReference>() { + }); return result.getData(); } @@ -249,9 +273,8 @@ public abstract class AbstractCoreMaintainerService implements CoreMaintainerSer HttpRequest httpRequest = new HttpRequest.Builder().setHttpMethod(HttpMethod.DELETE) .setPath(Constants.AdminApiPath.CORE_NAMESPACE_ADMIN_PATH).setParamValue(params).build(); HttpRestResult httpRestResult = clientHttpProxy.executeSyncHttpRequest(httpRequest); - Result result = JacksonUtils.toObj(httpRestResult.getData(), - new TypeReference>() { - }); + Result result = JacksonUtils.toObj(httpRestResult.getData(), new TypeReference>() { + }); return result.getData(); } @@ -263,9 +286,8 @@ public abstract class AbstractCoreMaintainerService implements CoreMaintainerSer HttpRequest httpRequest = new HttpRequest.Builder().setHttpMethod(HttpMethod.GET) .setPath(Constants.AdminApiPath.CORE_NAMESPACE_ADMIN_PATH + "/check").setParamValue(params).build(); HttpRestResult httpRestResult = clientHttpProxy.executeSyncHttpRequest(httpRequest); - Result result = JacksonUtils.toObj(httpRestResult.getData(), - new TypeReference>() { - }); + Result result = JacksonUtils.toObj(httpRestResult.getData(), new TypeReference>() { + }); return result.getData() > 0; } diff --git a/maintainer-client/src/main/java/com/alibaba/nacos/maintainer/client/core/CoreMaintainerService.java b/maintainer-client/src/main/java/com/alibaba/nacos/maintainer/client/core/CoreMaintainerService.java index f6a43f38b0..59de1ba397 100644 --- a/maintainer-client/src/main/java/com/alibaba/nacos/maintainer/client/core/CoreMaintainerService.java +++ b/maintainer-client/src/main/java/com/alibaba/nacos/maintainer/client/core/CoreMaintainerService.java @@ -22,6 +22,7 @@ import com.alibaba.nacos.api.model.response.IdGeneratorInfo; import com.alibaba.nacos.api.model.response.NacosMember; import com.alibaba.nacos.api.model.response.Namespace; import com.alibaba.nacos.api.model.response.ServerLoaderMetrics; +import com.alibaba.nacos.common.utils.StringUtils; import java.util.Collection; import java.util.List; @@ -34,6 +35,30 @@ import java.util.Map; */ public interface CoreMaintainerService { + /** + * Get Nacos server states. + * + * @return the states key-value map + * @throws NacosException if the operation fails. + */ + Map getServerState() throws NacosException; + + /** + * Detect server liveness. + * + * @return {@code true} detect successfully, {@code false} otherwise. + * @throws NacosException if the operation fails. + */ + Boolean liveness() throws NacosException; + + /** + * Detect server readiness. + * + * @return {@code true} detect successfully, {@code false} otherwise. + * @throws NacosException if the operation fails. + */ + Boolean readiness() throws NacosException; + /** * Execute a Raft operation with the specified command, value, and group ID. * @@ -143,10 +168,22 @@ public interface CoreMaintainerService { */ Namespace getNamespace(String namespaceId) throws NacosException; + /** + * Create a new namespace with the provided details and auto-generate UUID. + * + * @param namespaceName The name of the new namespace. + * @param namespaceDesc The description of the new namespace. + * @return {@code true} if the namespace is created successfully, {@code false} otherwise. + * @throws NacosException Thrown if any error occurs during the creation. + */ + default Boolean createNamespace(String namespaceName, String namespaceDesc) throws NacosException { + return createNamespace(StringUtils.EMPTY, namespaceName, namespaceDesc); + } + /** * Create a new namespace with the provided details. * - * @param namespaceId The unique identifier for the new namespace. + * @param namespaceId The unique identifier for the new namespace, if null or empty will use auto-generate UUID. * @param namespaceName The name of the new namespace. * @param namespaceDesc The description of the new namespace. * @return {@code true} if the namespace is created successfully, {@code false} otherwise. @@ -159,7 +196,7 @@ public interface CoreMaintainerService { * * @param namespaceId The unique identifier of the namespace to be updated. * @param namespaceName The new name for the namespace (can be null). - * @param namespaceDesc The new description for the namespace (can be null). + * @param namespaceDesc The new description for the namespace. * @return {@code true} if the namespace is updated successfully, {@code false} otherwise. * @throws NacosException Thrown if any error occurs during the update. */ diff --git a/maintainer-client/src/main/java/com/alibaba/nacos/maintainer/client/naming/NacosNamingMaintainerServiceImpl.java b/maintainer-client/src/main/java/com/alibaba/nacos/maintainer/client/naming/NacosNamingMaintainerServiceImpl.java index 44527670cc..6a1c705140 100644 --- a/maintainer-client/src/main/java/com/alibaba/nacos/maintainer/client/naming/NacosNamingMaintainerServiceImpl.java +++ b/maintainer-client/src/main/java/com/alibaba/nacos/maintainer/client/naming/NacosNamingMaintainerServiceImpl.java @@ -117,23 +117,23 @@ public class NacosNamingMaintainerServiceImpl extends AbstractCoreMaintainerServ } @Override - public List listServices(String namespaceId, String groupNameParam, String serviceNameParam, + public Page listServices(String namespaceId, String groupNameParam, String serviceNameParam, boolean ignoreEmptyService, int pageNo, int pageSize) throws NacosException { HttpRestResult httpRestResult = doListServices(namespaceId, groupNameParam, serviceNameParam, false, ignoreEmptyService, pageNo, pageSize); - Result> result = JacksonUtils.toObj(httpRestResult.getData(), - new TypeReference>>() { + Result> result = JacksonUtils.toObj(httpRestResult.getData(), + new TypeReference>>() { }); return result.getData(); } @Override - public List listServicesWithDetail(String namespaceId, String groupNameParam, + public Page listServicesWithDetail(String namespaceId, String groupNameParam, String serviceNameParam, int pageNo, int pageSize) throws NacosException { HttpRestResult httpRestResult = doListServices(namespaceId, groupNameParam, serviceNameParam, true, false, pageNo, pageSize); - Result> result = JacksonUtils.toObj(httpRestResult.getData(), - new TypeReference>>() { + Result> result = JacksonUtils.toObj(httpRestResult.getData(), + new TypeReference>>() { }); return result.getData(); } diff --git a/maintainer-client/src/main/java/com/alibaba/nacos/maintainer/client/naming/ServiceMaintainerService.java b/maintainer-client/src/main/java/com/alibaba/nacos/maintainer/client/naming/ServiceMaintainerService.java index 7c812589b3..1723628fe3 100644 --- a/maintainer-client/src/main/java/com/alibaba/nacos/maintainer/client/naming/ServiceMaintainerService.java +++ b/maintainer-client/src/main/java/com/alibaba/nacos/maintainer/client/naming/ServiceMaintainerService.java @@ -330,10 +330,10 @@ public interface ServiceMaintainerService { *

Only list the first 100 services if this namespace contains more than 100 services

* * @param namespaceId target namespace id - * @return list of service view, {@link ServiceView} is a summary of service. + * @return page of service view, {@link ServiceView} is a summary of service. * @throws NacosException if an error occurs */ - default List listServices(String namespaceId) throws NacosException { + default Page listServices(String namespaceId) throws NacosException { return listServices(namespaceId, StringUtils.EMPTY, StringUtils.EMPTY); } @@ -345,10 +345,10 @@ public interface ServiceMaintainerService { * @param namespaceId target namespace id * @param groupNameParam the group name pattern, e.g., "" for all groups, "group" for all services groupName match `.*group.*`. * @param serviceNameParam the service name pattern, e.g., "" for all services, "service" for all services name match `.*service.*`. - * @return list of service view, {@link ServiceView} is a summary of service. + * @return page of service view, {@link ServiceView} is a summary of service. * @throws NacosException if an error occurs */ - default List listServices(String namespaceId, String groupNameParam, String serviceNameParam) + default Page listServices(String namespaceId, String groupNameParam, String serviceNameParam) throws NacosException { return listServices(namespaceId, groupNameParam, serviceNameParam, true, 1, 100); } @@ -364,10 +364,10 @@ public interface ServiceMaintainerService { * @param ignoreEmptyService whether ignore empty service, {@code true} will exclude these services without any instance. * @param pageNo page number, start from 1 * @param pageSize page size per page - * @return list of service view, {@link ServiceView} is a summary of service. + * @return page of service view, {@link ServiceView} is a summary of service. * @throws NacosException if an error occurs */ - List listServices(String namespaceId, String groupNameParam, String serviceNameParam, + Page listServices(String namespaceId, String groupNameParam, String serviceNameParam, boolean ignoreEmptyService, int pageNo, int pageSize) throws NacosException; /** @@ -381,10 +381,10 @@ public interface ServiceMaintainerService { *

* * @param namespaceId target namespace id - * @return list of service detail, {@link ServiceDetailInfo} is a detail info of service. + * @return page of service detail, {@link ServiceDetailInfo} is a detail info of service. * @throws NacosException if an error occurs */ - default List listServicesWithDetail(String namespaceId) throws NacosException { + default Page listServicesWithDetail(String namespaceId) throws NacosException { return listServicesWithDetail(namespaceId, StringUtils.EMPTY, StringUtils.EMPTY); } @@ -401,10 +401,10 @@ public interface ServiceMaintainerService { * @param namespaceId target namespace id * @param groupNameParam the group name pattern, e.g., "" for all groups, "group" for all services groupName match `.*group.*`. * @param serviceNameParam the service name pattern, e.g., "" for all services, "service" for all services name match `.*service.*`. - * @return list of service detail, {@link ServiceDetailInfo} is a detail info of service. + * @return page of service detail, {@link ServiceDetailInfo} is a detail info of service. * @throws NacosException if an error occurs */ - default List listServicesWithDetail(String namespaceId, String groupNameParam, + default Page listServicesWithDetail(String namespaceId, String groupNameParam, String serviceNameParam) throws NacosException { return listServicesWithDetail(namespaceId, groupNameParam, serviceNameParam, 1, 100); } @@ -423,10 +423,10 @@ public interface ServiceMaintainerService { * @param serviceNameParam the service name pattern, e.g., "" for all services, "service" for all services name match `.*service.*`. * @param pageNo page number, start from 1 * @param pageSize page size per page - * @return list of service detail, {@link ServiceDetailInfo} is a detail info of service. + * @return page of service detail, {@link ServiceDetailInfo} is a detail info of service. * @throws NacosException if an error occurs */ - List listServicesWithDetail(String namespaceId, String groupNameParam, String serviceNameParam, + Page listServicesWithDetail(String namespaceId, String groupNameParam, String serviceNameParam, int pageNo, int pageSize) throws NacosException; /** diff --git a/maintainer-client/src/main/java/com/alibaba/nacos/maintainer/client/remote/ClientHttpProxy.java b/maintainer-client/src/main/java/com/alibaba/nacos/maintainer/client/remote/ClientHttpProxy.java index 8b2f52ab9c..7f7e246bc9 100644 --- a/maintainer-client/src/main/java/com/alibaba/nacos/maintainer/client/remote/ClientHttpProxy.java +++ b/maintainer-client/src/main/java/com/alibaba/nacos/maintainer/client/remote/ClientHttpProxy.java @@ -43,7 +43,6 @@ import org.slf4j.LoggerFactory; import java.io.File; import java.net.HttpURLConnection; -import java.util.HashMap; import java.util.Map; import java.util.Properties; import java.util.concurrent.ScheduledExecutorService; @@ -206,13 +205,8 @@ public class ClientHttpProxy { clientAuthPluginManager.getAuthServiceSpiImplSet().forEach(clientAuthService -> { LoginIdentityContext loginIdentityContext = clientAuthService.getLoginIdentityContext( new RequestResource()); - if (loginIdentityContext != null) { - if (loginIdentityContext.getAllKey().contains(NacosAuthLoginConstant.ACCESSTOKEN)) { - Map accessToken = new HashMap<>(4); - accessToken.put(NacosAuthLoginConstant.ACCESSTOKEN, - loginIdentityContext.getParameter(NacosAuthLoginConstant.ACCESSTOKEN)); - header.addAll(accessToken); - } + for (String key : loginIdentityContext.getAllKey()) { + header.addParam(key, loginIdentityContext.getParameter(key)); } }); } diff --git a/maintainer-client/src/test/java/com/alibaba/nacos/maintainer/client/core/AbstractCoreMaintainerServiceTest.java b/maintainer-client/src/test/java/com/alibaba/nacos/maintainer/client/core/AbstractCoreMaintainerServiceTest.java index 487e844c14..a2add0a958 100644 --- a/maintainer-client/src/test/java/com/alibaba/nacos/maintainer/client/core/AbstractCoreMaintainerServiceTest.java +++ b/maintainer-client/src/test/java/com/alibaba/nacos/maintainer/client/core/AbstractCoreMaintainerServiceTest.java @@ -16,6 +16,7 @@ package com.alibaba.nacos.maintainer.client.core; +import com.alibaba.nacos.api.exception.NacosException; import com.alibaba.nacos.api.model.response.ConnectionInfo; import com.alibaba.nacos.api.model.response.IdGeneratorInfo; import com.alibaba.nacos.api.model.response.NacosMember; @@ -24,6 +25,7 @@ import com.alibaba.nacos.api.model.response.ServerLoaderMetrics; import com.alibaba.nacos.api.model.v2.Result; import com.alibaba.nacos.common.http.HttpRestResult; import com.alibaba.nacos.maintainer.client.remote.ClientHttpProxy; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -299,7 +301,6 @@ class AbstractCoreMaintainerServiceTest { @Test void testCreateNamespace() throws Exception { // Arrange - String namespaceId = "test-namespace-id"; String namespaceName = "test-namespace-name"; String namespaceDesc = "test-namespace-desc"; HttpRestResult mockHttpRestResult = new HttpRestResult<>(); @@ -308,7 +309,7 @@ class AbstractCoreMaintainerServiceTest { when(clientHttpProxy.executeSyncHttpRequest(any())).thenReturn(mockHttpRestResult); // Act - Boolean result = coreMaintainerService.createNamespace(namespaceId, namespaceName, namespaceDesc); + Boolean result = coreMaintainerService.createNamespace(namespaceName, namespaceDesc); // Assert assertTrue(result); @@ -384,4 +385,46 @@ class AbstractCoreMaintainerServiceTest { assertFalse(result); verify(clientHttpProxy, times(1)).executeSyncHttpRequest(any()); } + + @Test + void getServerState() throws JsonProcessingException, NacosException { + Map serverState = new HashMap<>(); + serverState.put("key", "value"); + HttpRestResult mockHttpRestResult = new HttpRestResult<>(); + mockHttpRestResult.setData(new ObjectMapper().writeValueAsString(new Result<>(serverState))); // 0表示不存在 + when(clientHttpProxy.executeSyncHttpRequest(any())).thenReturn(mockHttpRestResult); + + Map result = coreMaintainerService.getServerState(); + + assertEquals(1, result.size()); + assertEquals("value", result.get("key")); + } + + @Test + void liveness() throws NacosException { + HttpRestResult mockHttpRestResult = new HttpRestResult<>(); + mockHttpRestResult.setCode(200); + when(clientHttpProxy.executeSyncHttpRequest(any())).thenReturn(mockHttpRestResult); + + Boolean result = coreMaintainerService.liveness(); + assertTrue(result); + + mockHttpRestResult.setCode(500); + result = coreMaintainerService.liveness(); + assertFalse(result); + } + + @Test + void readiness() throws NacosException { + HttpRestResult mockHttpRestResult = new HttpRestResult<>(); + mockHttpRestResult.setCode(200); + when(clientHttpProxy.executeSyncHttpRequest(any())).thenReturn(mockHttpRestResult); + + Boolean result = coreMaintainerService.readiness(); + assertTrue(result); + + mockHttpRestResult.setCode(500); + result = coreMaintainerService.readiness(); + assertFalse(result); + } } \ No newline at end of file diff --git a/maintainer-client/src/test/java/com/alibaba/nacos/maintainer/client/naming/NacosNamingMaintainerServiceImplTest.java b/maintainer-client/src/test/java/com/alibaba/nacos/maintainer/client/naming/NacosNamingMaintainerServiceImplTest.java index 59a7549acd..69cc59d4bb 100644 --- a/maintainer-client/src/test/java/com/alibaba/nacos/maintainer/client/naming/NacosNamingMaintainerServiceImplTest.java +++ b/maintainer-client/src/test/java/com/alibaba/nacos/maintainer/client/naming/NacosNamingMaintainerServiceImplTest.java @@ -157,53 +157,55 @@ public class NacosNamingMaintainerServiceImplTest { @Test void testListServices() throws Exception { - List expected = new ArrayList<>(); - expected.add(new ServiceView()); - expected.get(0).setName("testService"); - expected.get(0).setGroupName("testGroup"); + Page expected = new Page<>(); + expected.getPageItems().add(new ServiceView()); + expected.getPageItems().get(0).setName("testService"); + expected.getPageItems().get(0).setGroupName("testGroup"); HttpRestResult mockHttpRestResult = new HttpRestResult<>(); mockHttpRestResult.setData(new ObjectMapper().writeValueAsString(new Result<>(expected))); when(clientHttpProxy.executeSyncHttpRequest(any())).thenReturn(mockHttpRestResult); // Act - List result = nacosNamingMaintainerService.listServices("testNamespace"); + Page result = nacosNamingMaintainerService.listServices("testNamespace"); // Assert assertNotNull(result); - assertEquals(1, result.size()); - assertEquals("testService", result.get(0).getName()); - assertEquals("testGroup", result.get(0).getGroupName()); + assertEquals(1, result.getPageItems().size()); + assertEquals("testService", result.getPageItems().get(0).getName()); + assertEquals("testGroup", result.getPageItems().get(0).getGroupName()); verify(clientHttpProxy, times(1)).executeSyncHttpRequest(any()); } @Test void testListServicesWithDetail() throws Exception { // Arrange - String namespaceId = "testNamespace"; - List expected = new ArrayList<>(); - expected.add(new ServiceDetailInfo()); - expected.get(0).setNamespaceId(namespaceId); - expected.get(0).setServiceName("testService"); - expected.get(0).setGroupName("testGroup"); - expected.get(0).setMetadata(Collections.singletonMap("key", "value")); - expected.get(0).setClusterMap(Collections.emptyMap()); + Page expected = new Page<>(); + List expectedItem = new ArrayList<>(); + expected.setPageItems(expectedItem); + expected.setTotalCount(1); + expectedItem.add(new ServiceDetailInfo()); + expectedItem.get(0).setNamespaceId("testNamespace"); + expectedItem.get(0).setServiceName("testService"); + expectedItem.get(0).setGroupName("testGroup"); + expectedItem.get(0).setMetadata(Collections.singletonMap("key", "value")); + expectedItem.get(0).setClusterMap(Collections.emptyMap()); HttpRestResult mockHttpRestResult = new HttpRestResult<>(); mockHttpRestResult.setData(new ObjectMapper().writeValueAsString(new Result<>(expected))); when(clientHttpProxy.executeSyncHttpRequest(any())).thenReturn(mockHttpRestResult); // Act - List result = nacosNamingMaintainerService.listServicesWithDetail(namespaceId); + Page result = nacosNamingMaintainerService.listServicesWithDetail("testNamespace"); // Assert assertNotNull(result); - assertEquals(1, result.size()); - assertEquals(namespaceId, result.get(0).getNamespaceId()); - assertEquals("testService", result.get(0).getServiceName()); - assertEquals("testGroup", result.get(0).getGroupName()); - assertEquals(Collections.singletonMap("key", "value"), result.get(0).getMetadata()); - assertEquals(Collections.emptyMap(), result.get(0).getClusterMap()); + assertEquals(1, result.getPageItems().size()); + assertEquals("testNamespace", result.getPageItems().get(0).getNamespaceId()); + assertEquals("testService", result.getPageItems().get(0).getServiceName()); + assertEquals("testGroup", result.getPageItems().get(0).getGroupName()); + assertEquals(Collections.singletonMap("key", "value"), result.getPageItems().get(0).getMetadata()); + assertEquals(Collections.emptyMap(), result.getPageItems().get(0).getClusterMap()); verify(clientHttpProxy, times(1)).executeSyncHttpRequest(any()); } diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java index e2df115f9b..a329f62632 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/CatalogController.java @@ -18,6 +18,7 @@ package com.alibaba.nacos.naming.controllers; import com.alibaba.nacos.api.common.Constants; import com.alibaba.nacos.api.exception.NacosException; +import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.api.naming.pojo.Instance; import com.alibaba.nacos.api.naming.pojo.maintainer.ServiceDetailInfo; import com.alibaba.nacos.api.naming.utils.NamingUtils; @@ -40,6 +41,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.util.LinkedList; import java.util.List; /** @@ -143,9 +145,13 @@ public class CatalogController { @RequestParam(required = false) boolean hasIpCount) throws NacosException { if (withInstances) { - ServiceDetailInfo serviceDetailInfo = (ServiceDetailInfo) judgeCatalogService().pageListServiceDetail( + Page serviceDetailInfo = judgeCatalogService().pageListServiceDetail( namespaceId, groupName, serviceName, pageNo, pageSize); - return com.alibaba.nacos.naming.pojo.ServiceDetailInfo.from(serviceDetailInfo); + List result = new LinkedList<>(); + for (ServiceDetailInfo each : serviceDetailInfo.getPageItems()) { + result.add(com.alibaba.nacos.naming.pojo.ServiceDetailInfo.from(each)); + } + return result; } return judgeCatalogService().pageListService(namespaceId, groupName, serviceName, pageNo, pageSize, containedInstance, hasIpCount); diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/v3/ServiceControllerV3.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/v3/ServiceControllerV3.java index 304653532e..d51e843014 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/v3/ServiceControllerV3.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/v3/ServiceControllerV3.java @@ -147,7 +147,7 @@ public class ServiceControllerV3 { * *
    *
  • - * if {@link ServiceListForm#isWithInstances()} is {@code true}, will return list {@link ServiceDetailInfo } + * if {@link ServiceListForm#isWithInstances()} is {@code true}, will return page {@link ServiceDetailInfo } *
  • *
  • * if {@link ServiceListForm#isWithInstances()} is {@code false}, will return list {@link ServiceView } diff --git a/naming/src/main/java/com/alibaba/nacos/naming/core/CatalogService.java b/naming/src/main/java/com/alibaba/nacos/naming/core/CatalogService.java index 4654cc2bd4..8c4d4e4b82 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/core/CatalogService.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/core/CatalogService.java @@ -17,6 +17,7 @@ package com.alibaba.nacos.naming.core; import com.alibaba.nacos.api.exception.NacosException; +import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.api.naming.pojo.Instance; import com.alibaba.nacos.api.naming.pojo.maintainer.ServiceDetailInfo; import com.alibaba.nacos.api.naming.pojo.maintainer.ServiceView; @@ -48,7 +49,7 @@ public interface CatalogService { * @param groupName group name of service * @param serviceName service name * @param clusterName cluster name of instances - * @return instances list + * @return instances page object * @throws NacosException exception in query */ List listInstances(String namespaceId, String groupName, String serviceName, String clusterName) @@ -90,11 +91,11 @@ public interface CatalogService { * @param serviceName service name * @param pageNo page number * @param pageSize page size - * @return service list + * @return service page object * @throws NacosException exception in query */ - Object pageListServiceDetail(String namespaceId, String groupName, String serviceName, int pageNo, int pageSize) - throws NacosException; + Page pageListServiceDetail(String namespaceId, String groupName, String serviceName, int pageNo, + int pageSize) throws NacosException; /** * List service by page. @@ -105,10 +106,10 @@ public interface CatalogService { * @param pageNo page number * @param pageSize page size * @param ignoreEmptyService whether ignore empty service - * @return service list + * @return service page object * @throws NacosException exception in query */ - List listService(String namespaceId, String groupName, String serviceName, int pageNo, int pageSize, + Page listService(String namespaceId, String groupName, String serviceName, int pageNo, int pageSize, boolean ignoreEmptyService) throws NacosException; } diff --git a/naming/src/main/java/com/alibaba/nacos/naming/core/CatalogServiceV2Impl.java b/naming/src/main/java/com/alibaba/nacos/naming/core/CatalogServiceV2Impl.java index 84252e1cfd..df43c287fb 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/core/CatalogServiceV2Impl.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/core/CatalogServiceV2Impl.java @@ -18,6 +18,7 @@ package com.alibaba.nacos.naming.core; import com.alibaba.nacos.api.common.Constants; import com.alibaba.nacos.api.exception.NacosException; +import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.api.naming.pojo.Instance; import com.alibaba.nacos.api.naming.pojo.ServiceInfo; import com.alibaba.nacos.api.naming.pojo.maintainer.ClusterInfo; @@ -37,7 +38,6 @@ import com.alibaba.nacos.naming.utils.ServiceUtil; import com.fasterxml.jackson.databind.node.ObjectNode; import org.springframework.stereotype.Component; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -161,15 +161,17 @@ public class CatalogServiceV2Impl implements CatalogService { } @Override - public List listService(String namespaceId, String groupName, String serviceName, int pageNo, + public Page listService(String namespaceId, String groupName, String serviceName, int pageNo, int pageSize, boolean ignoreEmptyService) throws NacosException { - List serviceViews = new LinkedList<>(); + Page serviceViews = new Page<>(); Collection services = patternServices(namespaceId, groupName, serviceName); if (ignoreEmptyService) { - services = services.stream().filter(each -> 0 != serviceStorage.getData(each).ipCount()) - .collect(Collectors.toList()); + services = services.stream().filter(each -> 0 != serviceStorage.getData(each).ipCount()).toList(); } - services = PageUtil.subPageList(services.stream().toList(), pageNo, pageSize); + Page page = PageUtil.subPage(services.stream().toList(), pageNo, pageSize); + serviceViews.setTotalCount(page.getTotalCount()); + serviceViews.setPageNumber(page.getPageNumber()); + serviceViews.setPagesAvailable(page.getPagesAvailable()); for (Service each : services) { ServiceMetadata serviceMetadata = metadataManager.getServiceMetadata(each).orElseGet(ServiceMetadata::new); ServiceView serviceView = new ServiceView(); @@ -179,7 +181,7 @@ public class CatalogServiceV2Impl implements CatalogService { serviceView.setIpCount(serviceStorage.getData(each).ipCount()); serviceView.setHealthyInstanceCount(countHealthyInstance(serviceStorage.getData(each))); serviceView.setTriggerFlag(isProtectThreshold(serviceView, serviceMetadata) ? "true" : "false"); - serviceViews.add(serviceView); + serviceViews.getPageItems().add(serviceView); } return serviceViews; } @@ -200,20 +202,25 @@ public class CatalogServiceV2Impl implements CatalogService { } @Override - public Object pageListServiceDetail(String namespaceId, String groupName, String serviceName, int pageNo, - int pageSize) throws NacosException { - List result = new ArrayList<>(); + public Page pageListServiceDetail(String namespaceId, String groupName, String serviceName, + int pageNo, int pageSize) throws NacosException { Collection services = patternServices(namespaceId, groupName, serviceName); - services = doPage(services, pageNo - 1, pageSize); - for (Service each : services) { + Page servicePage = PageUtil.subPage(services.stream().toList(), pageNo, pageSize); + Page result = new Page<>(); + result.setPagesAvailable(servicePage.getPagesAvailable()); + result.setPageNumber(servicePage.getPageNumber()); + result.setTotalCount(servicePage.getTotalCount()); + List pagedItem = new LinkedList<>(); + for (Service each : servicePage.getPageItems()) { ServiceDetailInfo serviceDetailInfo = new ServiceDetailInfo(); serviceDetailInfo.setServiceName(each.getName()); serviceDetailInfo.setGroupName(each.getGroup()); ServiceMetadata serviceMetadata = metadataManager.getServiceMetadata(each).orElseGet(ServiceMetadata::new); serviceDetailInfo.setMetadata(serviceMetadata.getExtendData()); serviceDetailInfo.setClusterMap(getClusterMap(each)); - result.add(serviceDetailInfo); + pagedItem.add(serviceDetailInfo); } + result.setPageItems(pagedItem); return result; } diff --git a/naming/src/main/resources/application.properties b/naming/src/main/resources/application.properties deleted file mode 100644 index dc6ee3155b..0000000000 --- a/naming/src/main/resources/application.properties +++ /dev/null @@ -1,36 +0,0 @@ -# -# Copyright 1999-2018 Alibaba Group Holding Ltd. -# -# Licensed 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. -# -server.port=8848 -server.servlet.context-path=/nacos -# Number of ms to wait before throwing an exception if no connection is available. -spring.datasource.max-wait=10000 -# Maximum number of active connections that can be allocated from this pool at the same time. -spring.datasource.max-active=15 -## Validate the connection before borrowing it from the pool. -#spring.datasource.test-on-borrow=true -management.metrics.export.elastic.enabled=false -#management.metrics.export.elastic.host=http://localhost:9200 -# metrics for influx -management.metrics.export.influx.enabled=false -#management.metrics.export.influx.db=springboot -#management.metrics.export.influx.uri=http://localhost:8086 -#management.metrics.export.influx.auto-create-db=true -#management.metrics.export.influx.consistency=one -#management.metrics.export.influx.compressed=true -server.tomcat.accesslog.enabled=true -server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D -# default current work dir -server.tomcat.basedir=file:. diff --git a/naming/src/test/java/com/alibaba/nacos/naming/controllers/CatalogControllerTest.java b/naming/src/test/java/com/alibaba/nacos/naming/controllers/CatalogControllerTest.java index d023218e52..f78d761bba 100644 --- a/naming/src/test/java/com/alibaba/nacos/naming/controllers/CatalogControllerTest.java +++ b/naming/src/test/java/com/alibaba/nacos/naming/controllers/CatalogControllerTest.java @@ -18,6 +18,7 @@ package com.alibaba.nacos.naming.controllers; import com.alibaba.nacos.api.common.Constants; import com.alibaba.nacos.api.exception.NacosException; +import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.api.naming.pojo.Instance; import com.alibaba.nacos.api.naming.pojo.maintainer.ServiceDetailInfo; import com.alibaba.nacos.naming.core.CatalogServiceV2Impl; @@ -30,7 +31,6 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -93,7 +93,7 @@ class CatalogControllerTest { void testListDetail() { try { when(catalogServiceV2.pageListServiceDetail(Constants.DEFAULT_NAMESPACE_ID, TEST_GROUP_NAME, - TEST_SERVICE_NAME, 1, 10)).thenReturn(Collections.emptyList()); + TEST_SERVICE_NAME, 1, 10)).thenReturn(new Page<>()); Object res = catalogController.listDetail(true, Constants.DEFAULT_NAMESPACE_ID, 1, 10, TEST_SERVICE_NAME, TEST_GROUP_NAME, null, true); assertTrue(res instanceof List); diff --git a/naming/src/test/java/com/alibaba/nacos/naming/controllers/v3/ServiceControllerV3Test.java b/naming/src/test/java/com/alibaba/nacos/naming/controllers/v3/ServiceControllerV3Test.java index 6518db5c9a..46e6c870c8 100644 --- a/naming/src/test/java/com/alibaba/nacos/naming/controllers/v3/ServiceControllerV3Test.java +++ b/naming/src/test/java/com/alibaba/nacos/naming/controllers/v3/ServiceControllerV3Test.java @@ -156,8 +156,8 @@ class ServiceControllerV3Test { @Test void testList() throws Exception { - List result = new LinkedList<>(); - result.add(new ServiceView()); + Page result = new Page<>(); + result.getPageItems().add(new ServiceView()); when(catalogServiceV2.listService(Constants.DEFAULT_NAMESPACE_ID, Constants.DEFAULT_GROUP, "serviceName", 1, 10, false)).thenReturn(result); ServiceListForm serviceListForm = new ServiceListForm(); diff --git a/naming/src/test/java/com/alibaba/nacos/naming/core/CatalogServiceV2ImplTest.java b/naming/src/test/java/com/alibaba/nacos/naming/core/CatalogServiceV2ImplTest.java index e3c48ec4f8..489efc559f 100644 --- a/naming/src/test/java/com/alibaba/nacos/naming/core/CatalogServiceV2ImplTest.java +++ b/naming/src/test/java/com/alibaba/nacos/naming/core/CatalogServiceV2ImplTest.java @@ -18,6 +18,7 @@ package com.alibaba.nacos.naming.core; import com.alibaba.nacos.api.exception.NacosException; +import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.api.naming.pojo.Instance; import com.alibaba.nacos.api.naming.pojo.ServiceInfo; import com.alibaba.nacos.api.naming.pojo.maintainer.ServiceDetailInfo; @@ -191,10 +192,9 @@ class CatalogServiceV2ImplTest { serviceInfo.setHosts(instances); Mockito.when(serviceStorage.getData(Mockito.any())).thenReturn(serviceInfo); - List result = (List) catalogServiceV2Impl.pageListServiceDetail("A", - "B", "C", 1, 10); + Page result = catalogServiceV2Impl.pageListServiceDetail("A", "B", "C", 1, 10); - assertEquals(1, result.size()); + assertEquals(1, result.getPageItems().size()); } catch (NacosException e) { e.printStackTrace(); fail(e.getMessage()); diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/authenticate/AbstractAuthenticationManager.java b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/authenticate/AbstractAuthenticationManager.java index dfbbee32dd..92644fce2b 100644 --- a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/authenticate/AbstractAuthenticationManager.java +++ b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/authenticate/AbstractAuthenticationManager.java @@ -22,13 +22,12 @@ import com.alibaba.nacos.core.utils.Loggers; import com.alibaba.nacos.plugin.auth.api.Permission; import com.alibaba.nacos.plugin.auth.exception.AccessException; import com.alibaba.nacos.plugin.auth.impl.constant.AuthConstants; -import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleService; import com.alibaba.nacos.plugin.auth.impl.token.TokenManagerDelegate; import com.alibaba.nacos.plugin.auth.impl.users.NacosUser; import com.alibaba.nacos.plugin.auth.impl.users.NacosUserDetails; -import com.alibaba.nacos.plugin.auth.impl.users.NacosUserDetailsServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.users.NacosUserService; import com.alibaba.nacos.plugin.auth.impl.utils.PasswordEncoderUtil; - import jakarta.servlet.http.HttpServletRequest; /** @@ -39,14 +38,14 @@ import jakarta.servlet.http.HttpServletRequest; */ public class AbstractAuthenticationManager implements IAuthenticationManager { - protected NacosUserDetailsServiceImpl userDetailsService; + protected NacosUserService userDetailsService; protected TokenManagerDelegate jwtTokenManager; - protected NacosRoleServiceImpl roleService; + protected NacosRoleService roleService; - public AbstractAuthenticationManager(NacosUserDetailsServiceImpl userDetailsService, - TokenManagerDelegate jwtTokenManager, NacosRoleServiceImpl roleService) { + public AbstractAuthenticationManager(NacosUserService userDetailsService, TokenManagerDelegate jwtTokenManager, + NacosRoleService roleService) { this.userDetailsService = userDetailsService; this.jwtTokenManager = jwtTokenManager; this.roleService = roleService; diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/authenticate/DefaultAuthenticationManager.java b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/authenticate/DefaultAuthenticationManager.java index 7d7a885073..4e2db9a8b1 100644 --- a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/authenticate/DefaultAuthenticationManager.java +++ b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/authenticate/DefaultAuthenticationManager.java @@ -16,9 +16,9 @@ package com.alibaba.nacos.plugin.auth.impl.authenticate; -import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleService; import com.alibaba.nacos.plugin.auth.impl.token.TokenManagerDelegate; -import com.alibaba.nacos.plugin.auth.impl.users.NacosUserDetailsServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.users.NacosUserService; /** * DefaultAuthenticationManager. @@ -28,8 +28,8 @@ import com.alibaba.nacos.plugin.auth.impl.users.NacosUserDetailsServiceImpl; */ public class DefaultAuthenticationManager extends AbstractAuthenticationManager { - public DefaultAuthenticationManager(NacosUserDetailsServiceImpl userDetailsService, - TokenManagerDelegate jwtTokenManager, NacosRoleServiceImpl roleService) { + public DefaultAuthenticationManager(NacosUserService userDetailsService, TokenManagerDelegate jwtTokenManager, + NacosRoleService roleService) { super(userDetailsService, jwtTokenManager, roleService); } } diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/authenticate/LdapAuthenticationManager.java b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/authenticate/LdapAuthenticationManager.java index 0c322f5859..6ad5b6e09b 100644 --- a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/authenticate/LdapAuthenticationManager.java +++ b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/authenticate/LdapAuthenticationManager.java @@ -21,11 +21,11 @@ import com.alibaba.nacos.core.utils.Loggers; import com.alibaba.nacos.plugin.auth.exception.AccessException; import com.alibaba.nacos.plugin.auth.impl.constant.AuthConstants; import com.alibaba.nacos.plugin.auth.impl.persistence.User; -import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleService; import com.alibaba.nacos.plugin.auth.impl.token.TokenManagerDelegate; import com.alibaba.nacos.plugin.auth.impl.users.NacosUser; import com.alibaba.nacos.plugin.auth.impl.users.NacosUserDetails; -import com.alibaba.nacos.plugin.auth.impl.users.NacosUserDetailsServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.users.NacosUserService; import org.springframework.ldap.core.LdapTemplate; import org.springframework.ldap.filter.EqualsFilter; import org.springframework.security.core.userdetails.UserDetails; @@ -45,8 +45,8 @@ public class LdapAuthenticationManager extends AbstractAuthenticationManager { private final LdapTemplate ldapTemplate; - public LdapAuthenticationManager(LdapTemplate ldapTemplate, NacosUserDetailsServiceImpl userDetailsService, - TokenManagerDelegate jwtTokenManager, NacosRoleServiceImpl roleService, String filterPrefix, + public LdapAuthenticationManager(LdapTemplate ldapTemplate, NacosUserService userDetailsService, + TokenManagerDelegate jwtTokenManager, NacosRoleService roleService, String filterPrefix, boolean caseSensitive) { super(userDetailsService, jwtTokenManager, roleService); this.ldapTemplate = ldapTemplate; @@ -80,7 +80,7 @@ public class LdapAuthenticationManager extends AbstractAuthenticationManager { userDetails = userDetailsService.loadUserByUsername(AuthConstants.LDAP_PREFIX + username); } catch (UsernameNotFoundException exception) { String ldapUsername = AuthConstants.LDAP_PREFIX + username; - userDetailsService.createUser(ldapUsername, AuthConstants.LDAP_DEFAULT_ENCODED_PASSWORD); + userDetailsService.createUser(ldapUsername, AuthConstants.LDAP_DEFAULT_ENCODED_PASSWORD, false); User user = new User(); user.setUsername(ldapUsername); user.setPassword(AuthConstants.LDAP_DEFAULT_ENCODED_PASSWORD); diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/configuration/NacosAuthPluginConfig.java b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/configuration/NacosAuthPluginConfig.java index 3eeea645de..105985c928 100644 --- a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/configuration/NacosAuthPluginConfig.java +++ b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/configuration/NacosAuthPluginConfig.java @@ -23,12 +23,12 @@ import com.alibaba.nacos.core.code.ControllerMethodsCache; import com.alibaba.nacos.plugin.auth.impl.authenticate.DefaultAuthenticationManager; import com.alibaba.nacos.plugin.auth.impl.authenticate.IAuthenticationManager; import com.alibaba.nacos.plugin.auth.impl.constant.AuthSystemTypes; -import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleService; import com.alibaba.nacos.plugin.auth.impl.token.TokenManager; import com.alibaba.nacos.plugin.auth.impl.token.TokenManagerDelegate; import com.alibaba.nacos.plugin.auth.impl.token.impl.CachedJwtTokenManager; import com.alibaba.nacos.plugin.auth.impl.token.impl.JwtTokenManager; -import com.alibaba.nacos.plugin.auth.impl.users.NacosUserDetailsServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.users.NacosUserService; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; @@ -48,11 +48,11 @@ import javax.annotation.PostConstruct; @Configuration public class NacosAuthPluginConfig { - private final NacosUserDetailsServiceImpl userDetailsService; + private final NacosUserService userDetailsService; private final ControllerMethodsCache methodsCache; - public NacosAuthPluginConfig(NacosUserDetailsServiceImpl userDetailsService, ControllerMethodsCache methodsCache) { + public NacosAuthPluginConfig(NacosUserService userDetailsService, ControllerMethodsCache methodsCache) { this.userDetailsService = userDetailsService; this.methodsCache = methodsCache; @@ -88,8 +88,8 @@ public class NacosAuthPluginConfig { @Bean @ConditionalOnMissingBean - public IAuthenticationManager defaultAuthenticationManager(NacosUserDetailsServiceImpl userDetailsService, - TokenManagerDelegate jwtTokenManager, NacosRoleServiceImpl roleService) { + public IAuthenticationManager defaultAuthenticationManager(NacosUserService userDetailsService, + TokenManagerDelegate jwtTokenManager, NacosRoleService roleService) { return new DefaultAuthenticationManager(userDetailsService, jwtTokenManager, roleService); } diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/constant/AuthConstants.java b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/constant/AuthConstants.java index dd86a4f509..bc664dbcc1 100644 --- a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/constant/AuthConstants.java +++ b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/constant/AuthConstants.java @@ -79,4 +79,13 @@ public class AuthConstants { public static final String LDAP_DEFAULT_ENCODED_PASSWORD = PasswordEncoderUtil.encode(System.getProperty("ldap.default.password", "nacos")); public static final String LDAP_PREFIX = "LDAP_"; + + /** + * Path for nacos plugin controller. + */ + public static final String USER_PATH = "/v3/auth/user"; + + public static final String ROLE_PATH = "/v3/auth/role"; + + public static final String PERMISSION_PATH = "/v3/auth/permission"; } diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/controller/PermissionController.java b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/controller/PermissionController.java index dfbe4fd56d..e530fe3d4e 100644 --- a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/controller/PermissionController.java +++ b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/controller/PermissionController.java @@ -16,17 +16,17 @@ package com.alibaba.nacos.plugin.auth.impl.controller; +import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.api.model.v2.Result; import com.alibaba.nacos.auth.annotation.Secured; import com.alibaba.nacos.common.model.RestResultUtils; import com.alibaba.nacos.common.utils.StringUtils; import com.alibaba.nacos.core.controller.compatibility.Compatibility; -import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.plugin.auth.constant.ActionTypes; import com.alibaba.nacos.plugin.auth.constant.ApiType; import com.alibaba.nacos.plugin.auth.impl.constant.AuthConstants; import com.alibaba.nacos.plugin.auth.impl.persistence.PermissionInfo; -import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -46,7 +46,7 @@ import org.springframework.web.bind.annotation.RestController; public class PermissionController { @Autowired - private NacosRoleServiceImpl nacosRoleService; + private NacosRoleService nacosRoleService; /** * Query permissions of a role. @@ -61,9 +61,9 @@ public class PermissionController { @Compatibility(apiType = ApiType.CONSOLE_API, alternatives = "GET ${contextPath:nacos}/v3/auth/permission/list") public Object getPermissions(@RequestParam int pageNo, @RequestParam int pageSize, @RequestParam(name = "role", defaultValue = StringUtils.EMPTY) String role) { - return nacosRoleService.getPermissionsFromDatabase(role, pageNo, pageSize); + return nacosRoleService.getPermissions(role, pageNo, pageSize); } - + /** * Fuzzy Query permissions of a role. * @@ -77,7 +77,7 @@ public class PermissionController { @Compatibility(apiType = ApiType.CONSOLE_API, alternatives = "GET ${contextPath:nacos}/v3/auth/permission/list") public Page fuzzySearchPermission(@RequestParam int pageNo, @RequestParam int pageSize, @RequestParam(name = "role", defaultValue = StringUtils.EMPTY) String role) { - return nacosRoleService.findPermissionsLike4Page(role, pageNo, pageSize); + return nacosRoleService.findPermissions(role, pageNo, pageSize); } /** @@ -112,7 +112,7 @@ public class PermissionController { nacosRoleService.deletePermission(role, resource, action); return RestResultUtils.success("delete permission ok!"); } - + /** * Judge whether a permission is duplicate. * @@ -124,7 +124,8 @@ public class PermissionController { @GetMapping @Secured(resource = AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX + "permissions", action = ActionTypes.READ) @Compatibility(apiType = ApiType.CONSOLE_API, alternatives = "GET ${contextPath:nacos}/v3/auth/permission") - public Result isDuplicatePermission(@RequestParam String role, @RequestParam String resource, @RequestParam String action) { + public Result isDuplicatePermission(@RequestParam String role, @RequestParam String resource, + @RequestParam String action) { return nacosRoleService.isDuplicatePermission(role, resource, action); } } diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/controller/RoleController.java b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/controller/RoleController.java index 168bdd3dfc..df55e417e1 100644 --- a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/controller/RoleController.java +++ b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/controller/RoleController.java @@ -16,16 +16,16 @@ package com.alibaba.nacos.plugin.auth.impl.controller; +import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.auth.annotation.Secured; import com.alibaba.nacos.common.model.RestResultUtils; import com.alibaba.nacos.common.utils.StringUtils; import com.alibaba.nacos.core.controller.compatibility.Compatibility; -import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.plugin.auth.constant.ActionTypes; import com.alibaba.nacos.plugin.auth.constant.ApiType; import com.alibaba.nacos.plugin.auth.impl.constant.AuthConstants; import com.alibaba.nacos.plugin.auth.impl.persistence.RoleInfo; -import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -47,7 +47,7 @@ import java.util.List; public class RoleController { @Autowired - private NacosRoleServiceImpl roleService; + private NacosRoleService roleService; /** * Get roles list. @@ -64,9 +64,9 @@ public class RoleController { public Object getRoles(@RequestParam int pageNo, @RequestParam int pageSize, @RequestParam(name = "username", defaultValue = "") String username, @RequestParam(name = "role", defaultValue = "") String role) { - return roleService.getRolesFromDatabase(username, role, pageNo, pageSize); + return roleService.getRoles(username, role, pageNo, pageSize); } - + /** * Fuzzy query role information. * @param pageNo number index of page @@ -81,7 +81,7 @@ public class RoleController { public Page fuzzySearchRole(@RequestParam int pageNo, @RequestParam int pageSize, @RequestParam(name = "username", defaultValue = "") String username, @RequestParam(name = "role", defaultValue = "") String role) { - return roleService.findRolesLike4Page(username, role, pageNo, pageSize); + return roleService.findRoles(username, role, pageNo, pageSize); } /** @@ -94,7 +94,7 @@ public class RoleController { @Secured(resource = AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX + "roles", action = ActionTypes.READ) @Compatibility(apiType = ApiType.CONSOLE_API, alternatives = "GET ${contextPath:nacos}/v3/auth/role/search") public List searchRoles(@RequestParam String role) { - return roleService.findRolesLikeRoleName(role); + return roleService.findRoleNames(role); } /** diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/controller/UserController.java b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/controller/UserController.java index 5456bf877a..ce87533b96 100644 --- a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/controller/UserController.java +++ b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/controller/UserController.java @@ -17,6 +17,7 @@ package com.alibaba.nacos.plugin.auth.impl.controller; import com.alibaba.nacos.api.common.Constants; +import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.auth.annotation.Secured; import com.alibaba.nacos.auth.config.AuthConfigs; import com.alibaba.nacos.common.model.RestResultUtils; @@ -24,7 +25,6 @@ import com.alibaba.nacos.common.utils.JacksonUtils; import com.alibaba.nacos.common.utils.StringUtils; import com.alibaba.nacos.core.context.RequestContextHolder; import com.alibaba.nacos.core.controller.compatibility.Compatibility; -import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.plugin.auth.api.IdentityContext; import com.alibaba.nacos.plugin.auth.constant.ActionTypes; import com.alibaba.nacos.plugin.auth.constant.ApiType; @@ -34,13 +34,14 @@ import com.alibaba.nacos.plugin.auth.impl.constant.AuthConstants; import com.alibaba.nacos.plugin.auth.impl.constant.AuthSystemTypes; import com.alibaba.nacos.plugin.auth.impl.persistence.RoleInfo; import com.alibaba.nacos.plugin.auth.impl.persistence.User; -import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleService; import com.alibaba.nacos.plugin.auth.impl.token.TokenManagerDelegate; import com.alibaba.nacos.plugin.auth.impl.users.NacosUser; -import com.alibaba.nacos.plugin.auth.impl.users.NacosUserDetailsServiceImpl; -import com.alibaba.nacos.plugin.auth.impl.utils.PasswordEncoderUtil; +import com.alibaba.nacos.plugin.auth.impl.users.NacosUserService; import com.alibaba.nacos.plugin.auth.impl.utils.PasswordGeneratorUtil; import com.fasterxml.jackson.databind.node.ObjectNode; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.security.authentication.AuthenticationManager; @@ -57,8 +58,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.List; @@ -80,10 +79,10 @@ public class UserController { private AuthenticationManager authenticationManager; @Autowired - private NacosUserDetailsServiceImpl userDetailsService; + private NacosUserService userDetailsService; @Autowired - private NacosRoleServiceImpl roleService; + private NacosRoleService roleService; @Autowired private AuthConfigs authConfigs; @@ -109,11 +108,11 @@ public class UserController { "User `nacos` is default admin user. Please use `/nacos/v1/auth/users/admin` API to init `nacos` users. " + "Detail see `https://nacos.io/docs/latest/manual/admin/auth/#31-%E8%AE%BE%E7%BD%AE%E7%AE%A1%E7%90%86%E5%91%98%E5%AF%86%E7%A0%81`"); } - User user = userDetailsService.getUserFromDatabase(username); + User user = userDetailsService.getUser(username); if (user != null) { throw new IllegalArgumentException("user '" + username + "' already exist!"); } - userDetailsService.createUser(username, PasswordEncoderUtil.encode(password)); + userDetailsService.createUser(username, password); return RestResultUtils.success("create user ok!"); } @@ -132,7 +131,7 @@ public class UserController { } String username = AuthConstants.DEFAULT_USER; - userDetailsService.createUser(username, PasswordEncoderUtil.encode(password)); + userDetailsService.createUser(username, password); roleService.addAdminRole(username); ObjectNode result = JacksonUtils.createEmptyJsonNode(); result.put(AuthConstants.PARAM_USERNAME, username); @@ -197,12 +196,12 @@ public class UserController { return null; } - User user = userDetailsService.getUserFromDatabase(username); + User user = userDetailsService.getUser(username); if (user == null) { throw new IllegalArgumentException("user " + username + " not exist!"); } - userDetailsService.updateUserPassword(username, PasswordEncoderUtil.encode(newPassword)); + userDetailsService.updateUserPassword(username, newPassword); return RestResultUtils.success("update user ok!"); } @@ -246,7 +245,7 @@ public class UserController { @Compatibility(apiType = ApiType.CONSOLE_API, alternatives = "GET ${contextPath:nacos}/v3/auth/user/list") public Page getUsers(@RequestParam int pageNo, @RequestParam int pageSize, @RequestParam(name = "username", required = false, defaultValue = "") String username) { - return userDetailsService.getUsersFromDatabase(pageNo, pageSize, username); + return userDetailsService.getUsers(pageNo, pageSize, username); } @GetMapping(params = "search=blur") @@ -254,7 +253,7 @@ public class UserController { @Compatibility(apiType = ApiType.CONSOLE_API, alternatives = "GET ${contextPath:nacos}/v3/auth/user/list") public Page fuzzySearchUser(@RequestParam int pageNo, @RequestParam int pageSize, @RequestParam(name = "username", required = false, defaultValue = "") String username) { - return userDetailsService.findUsersLike4Page(username, pageNo, pageSize); + return userDetailsService.findUsers(username, pageNo, pageSize); } /** @@ -318,6 +317,6 @@ public class UserController { @Secured(resource = AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX + "users", action = ActionTypes.WRITE) @Compatibility(apiType = ApiType.CONSOLE_API, alternatives = "GET ${contextPath:nacos}/v3/auth/user/search") public List searchUsersLikeUsername(@RequestParam String username) { - return userDetailsService.findUserLikeUsername(username); + return userDetailsService.findUserNames(username); } } diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/controller/v3/PermissionControllerV3.java b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/controller/v3/PermissionControllerV3.java index b072a1477f..0034d1195d 100644 --- a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/controller/v3/PermissionControllerV3.java +++ b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/controller/v3/PermissionControllerV3.java @@ -17,16 +17,16 @@ package com.alibaba.nacos.plugin.auth.impl.controller.v3; +import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.api.model.v2.Result; import com.alibaba.nacos.auth.annotation.Secured; import com.alibaba.nacos.common.utils.StringUtils; import com.alibaba.nacos.config.server.paramcheck.ConfigDefaultHttpParamExtractor; import com.alibaba.nacos.core.paramcheck.ExtractorManager; -import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.plugin.auth.constant.ActionTypes; import com.alibaba.nacos.plugin.auth.impl.constant.AuthConstants; import com.alibaba.nacos.plugin.auth.impl.persistence.PermissionInfo; -import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -41,11 +41,11 @@ import org.springframework.web.bind.annotation.RestController; * @author zhangyukun on:2024/8/16 */ @RestController -@RequestMapping("/v3/auth/permission") +@RequestMapping(AuthConstants.PERMISSION_PATH) @ExtractorManager.Extractor(httpExtractor = ConfigDefaultHttpParamExtractor.class) public class PermissionControllerV3 { - private final NacosRoleServiceImpl nacosRoleService; + private final NacosRoleService nacosRoleService; private static final String SEARCH_TYPE_BLUR = "blur"; @@ -55,7 +55,7 @@ public class PermissionControllerV3 { * @param nacosRoleService nacosRoleService instance */ @Autowired - public PermissionControllerV3(NacosRoleServiceImpl nacosRoleService) { + public PermissionControllerV3(NacosRoleService nacosRoleService) { this.nacosRoleService = nacosRoleService; } @@ -69,12 +69,12 @@ public class PermissionControllerV3 { */ @PostMapping @Secured(resource = AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX + "permissions", action = ActionTypes.WRITE) - public Result createPermission(@RequestParam String role, @RequestParam String resource, @RequestParam String action) { + public Result createPermission(@RequestParam String role, @RequestParam String resource, + @RequestParam String action) { nacosRoleService.addPermission(role, resource, action); return Result.success("add permission ok!"); } - /** * Delete a permission from a role. * @@ -107,9 +107,9 @@ public class PermissionControllerV3 { @RequestParam(name = "search", defaultValue = "accurate") String search) { Page permissionPage; if (SEARCH_TYPE_BLUR.equalsIgnoreCase(search)) { - permissionPage = nacosRoleService.findPermissionsLike4Page(role, pageNo, pageSize); + permissionPage = nacosRoleService.findPermissions(role, pageNo, pageSize); } else { - permissionPage = nacosRoleService.getPermissionsFromDatabase(role, pageNo, pageSize); + permissionPage = nacosRoleService.getPermissions(role, pageNo, pageSize); } return Result.success(permissionPage); } @@ -124,7 +124,8 @@ public class PermissionControllerV3 { */ @GetMapping @Secured(resource = AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX + "permissions", action = ActionTypes.READ) - public Result isDuplicatePermission(@RequestParam String role, @RequestParam String resource, @RequestParam String action) { + public Result isDuplicatePermission(@RequestParam String role, @RequestParam String resource, + @RequestParam String action) { return nacosRoleService.isDuplicatePermission(role, resource, action); } } \ No newline at end of file diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/controller/v3/RoleControllerV3.java b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/controller/v3/RoleControllerV3.java index e7e3add8da..d07419ebd0 100644 --- a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/controller/v3/RoleControllerV3.java +++ b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/controller/v3/RoleControllerV3.java @@ -17,16 +17,16 @@ package com.alibaba.nacos.plugin.auth.impl.controller.v3; +import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.api.model.v2.Result; import com.alibaba.nacos.auth.annotation.Secured; import com.alibaba.nacos.common.utils.StringUtils; import com.alibaba.nacos.config.server.paramcheck.ConfigDefaultHttpParamExtractor; import com.alibaba.nacos.core.paramcheck.ExtractorManager; -import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.plugin.auth.constant.ActionTypes; import com.alibaba.nacos.plugin.auth.impl.constant.AuthConstants; import com.alibaba.nacos.plugin.auth.impl.persistence.RoleInfo; -import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleService; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -42,15 +42,15 @@ import java.util.List; * @author zhangyukun on:2024/8/16 */ @RestController -@RequestMapping("/v3/auth/role") +@RequestMapping(AuthConstants.ROLE_PATH) @ExtractorManager.Extractor(httpExtractor = ConfigDefaultHttpParamExtractor.class) public class RoleControllerV3 { - private final NacosRoleServiceImpl roleService; + private final NacosRoleService roleService; private static final String SEARCH_TYPE_BLUR = "blur"; - public RoleControllerV3(NacosRoleServiceImpl roleService) { + public RoleControllerV3(NacosRoleService roleService) { this.roleService = roleService; } @@ -107,9 +107,9 @@ public class RoleControllerV3 { @RequestParam(name = "search", required = false, defaultValue = "accurate") String search) { Page rolePage; if (SEARCH_TYPE_BLUR.equalsIgnoreCase(search)) { - rolePage = roleService.findRolesLike4Page(username, role, pageNo, pageSize); + rolePage = roleService.findRoles(username, role, pageNo, pageSize); } else { - rolePage = roleService.getRolesFromDatabase(username, role, pageNo, pageSize); + rolePage = roleService.getRoles(username, role, pageNo, pageSize); } return Result.success(rolePage); } @@ -123,7 +123,7 @@ public class RoleControllerV3 { @GetMapping("/search") @Secured(resource = AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX + "roles", action = ActionTypes.READ) public Result> getRoleListByRoleName(@RequestParam String role) { - List roles = roleService.findRolesLikeRoleName(role); + List roles = roleService.findRoleNames(role); return Result.success(roles); } } diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/controller/v3/UserControllerV3.java b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/controller/v3/UserControllerV3.java index 1a42705384..c832b409b5 100644 --- a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/controller/v3/UserControllerV3.java +++ b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/controller/v3/UserControllerV3.java @@ -18,6 +18,7 @@ package com.alibaba.nacos.plugin.auth.impl.controller.v3; import com.alibaba.nacos.api.common.Constants; +import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.api.model.v2.ErrorCode; import com.alibaba.nacos.api.model.v2.Result; import com.alibaba.nacos.auth.annotation.Secured; @@ -26,7 +27,6 @@ import com.alibaba.nacos.common.utils.JacksonUtils; import com.alibaba.nacos.common.utils.StringUtils; import com.alibaba.nacos.config.server.paramcheck.ConfigDefaultHttpParamExtractor; import com.alibaba.nacos.core.paramcheck.ExtractorManager; -import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.plugin.auth.api.IdentityContext; import com.alibaba.nacos.plugin.auth.constant.ActionTypes; import com.alibaba.nacos.plugin.auth.exception.AccessException; @@ -35,11 +35,10 @@ import com.alibaba.nacos.plugin.auth.impl.constant.AuthConstants; import com.alibaba.nacos.plugin.auth.impl.constant.AuthSystemTypes; import com.alibaba.nacos.plugin.auth.impl.persistence.RoleInfo; import com.alibaba.nacos.plugin.auth.impl.persistence.User; -import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleService; import com.alibaba.nacos.plugin.auth.impl.token.TokenManagerDelegate; import com.alibaba.nacos.plugin.auth.impl.users.NacosUser; -import com.alibaba.nacos.plugin.auth.impl.users.NacosUserDetailsServiceImpl; -import com.alibaba.nacos.plugin.auth.impl.utils.PasswordEncoderUtil; +import com.alibaba.nacos.plugin.auth.impl.users.NacosUserService; import com.alibaba.nacos.plugin.auth.impl.utils.PasswordGeneratorUtil; import com.fasterxml.jackson.databind.node.ObjectNode; import jakarta.servlet.http.HttpServletRequest; @@ -63,13 +62,13 @@ import java.util.List; * @author zhangyukun on:2024/8/16 */ @RestController -@RequestMapping("/v3/auth/user") +@RequestMapping(AuthConstants.USER_PATH) @ExtractorManager.Extractor(httpExtractor = ConfigDefaultHttpParamExtractor.class) public class UserControllerV3 { - private final NacosUserDetailsServiceImpl userDetailsService; + private final NacosUserService userDetailsService; - private final NacosRoleServiceImpl roleService; + private final NacosRoleService roleService; private final AuthConfigs authConfigs; @@ -88,9 +87,8 @@ public class UserControllerV3 { * @param iAuthenticationManager the authentication manager interface * @param jwtTokenManager the JWT token manager */ - public UserControllerV3(NacosUserDetailsServiceImpl userDetailsService, NacosRoleServiceImpl roleService, - AuthConfigs authConfigs, IAuthenticationManager iAuthenticationManager, - TokenManagerDelegate jwtTokenManager) { + public UserControllerV3(NacosUserService userDetailsService, NacosRoleService roleService, AuthConfigs authConfigs, + IAuthenticationManager iAuthenticationManager, TokenManagerDelegate jwtTokenManager) { this.userDetailsService = userDetailsService; this.roleService = roleService; this.authConfigs = authConfigs; @@ -110,11 +108,11 @@ public class UserControllerV3 { @Secured(resource = AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX + "users", action = ActionTypes.WRITE) @PostMapping public Result createUser(@RequestParam String username, @RequestParam String password) { - User user = userDetailsService.getUserFromDatabase(username); + User user = userDetailsService.getUser(username); if (user != null) { throw new IllegalArgumentException("user '" + username + "' already exist!"); } - userDetailsService.createUser(username, PasswordEncoderUtil.encode(password)); + userDetailsService.createUser(username, password); return Result.success("create user ok!"); } @@ -133,7 +131,7 @@ public class UserControllerV3 { return Result.failure(HttpStatus.CONFLICT.value(), "have admin user cannot use it.", null); } String username = AuthConstants.DEFAULT_USER; - userDetailsService.createUser(username, PasswordEncoderUtil.encode(password)); + userDetailsService.createUser(username, password); roleService.addAdminRole(username); User result = new User(); result.setUsername(username); @@ -195,12 +193,12 @@ public class UserControllerV3 { return null; } - User user = userDetailsService.getUserFromDatabase(username); + User user = userDetailsService.getUser(username); if (user == null) { throw new IllegalArgumentException("user " + username + " not exist!"); } - userDetailsService.updateUserPassword(username, PasswordEncoderUtil.encode(newPassword)); + userDetailsService.updateUserPassword(username, newPassword); return Result.success("update user ok!"); } @@ -249,9 +247,9 @@ public class UserControllerV3 { @RequestParam(name = "search", required = false, defaultValue = "accurate") String search) { Page userPage; if (SEARCH_TYPE_BLUR.equalsIgnoreCase(search)) { - userPage = userDetailsService.findUsersLike4Page(username, pageNo, pageSize); + userPage = userDetailsService.findUsers(username, pageNo, pageSize); } else { - userPage = userDetailsService.getUsersFromDatabase(pageNo, pageSize, username); + userPage = userDetailsService.getUsers(pageNo, pageSize, username); } return Result.success(userPage); } @@ -265,7 +263,7 @@ public class UserControllerV3 { @GetMapping("/search") @Secured(resource = AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX + "users", action = ActionTypes.WRITE) public Result> getUserListByUsername(@RequestParam String username) { - List userList = userDetailsService.findUserLikeUsername(username); + List userList = userDetailsService.findUserNames(username); return Result.success(userList); } diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/ldap/LdapAuthPluginConfig.java b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/ldap/LdapAuthPluginConfig.java index 4797457331..cc94f558bc 100644 --- a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/ldap/LdapAuthPluginConfig.java +++ b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/ldap/LdapAuthPluginConfig.java @@ -20,9 +20,9 @@ import com.alibaba.nacos.plugin.auth.impl.authenticate.IAuthenticationManager; import com.alibaba.nacos.plugin.auth.impl.authenticate.LdapAuthenticationManager; import com.alibaba.nacos.plugin.auth.impl.configuration.ConditionOnLdapAuth; import com.alibaba.nacos.plugin.auth.impl.constant.AuthConstants; -import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleService; import com.alibaba.nacos.plugin.auth.impl.token.TokenManagerDelegate; -import com.alibaba.nacos.plugin.auth.impl.users.NacosUserDetailsServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.users.NacosUserService; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.ldap.LdapAutoConfiguration; @@ -85,15 +85,14 @@ public class LdapAuthPluginConfig { @Bean public LdapAuthenticationProvider ldapAuthenticationProvider(LdapTemplate ldapTemplate, - NacosUserDetailsServiceImpl userDetailsService, NacosRoleServiceImpl nacosRoleService) { + NacosUserService userDetailsService, NacosRoleService nacosRoleService) { return new LdapAuthenticationProvider(ldapTemplate, userDetailsService, nacosRoleService, filterPrefix, caseSensitive); } @Bean public IAuthenticationManager ldapAuthenticatoinManager(LdapTemplate ldapTemplate, - NacosUserDetailsServiceImpl userDetailsService, TokenManagerDelegate jwtTokenManager, - NacosRoleServiceImpl roleService) { + NacosUserService userDetailsService, TokenManagerDelegate jwtTokenManager, NacosRoleService roleService) { return new LdapAuthenticationManager(ldapTemplate, userDetailsService, jwtTokenManager, roleService, filterPrefix, caseSensitive); } diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/ldap/LdapAuthenticationProvider.java b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/ldap/LdapAuthenticationProvider.java index f55e6ba163..493f890e9c 100644 --- a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/ldap/LdapAuthenticationProvider.java +++ b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/ldap/LdapAuthenticationProvider.java @@ -21,9 +21,9 @@ import com.alibaba.nacos.core.utils.Loggers; import com.alibaba.nacos.plugin.auth.impl.constant.AuthConstants; import com.alibaba.nacos.plugin.auth.impl.persistence.RoleInfo; import com.alibaba.nacos.plugin.auth.impl.persistence.User; -import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleService; import com.alibaba.nacos.plugin.auth.impl.users.NacosUserDetails; -import com.alibaba.nacos.plugin.auth.impl.users.NacosUserDetailsServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.users.NacosUserService; import com.alibaba.nacos.plugin.auth.impl.utils.PasswordEncoderUtil; import org.apache.commons.lang.StringUtils; import org.springframework.ldap.core.LdapTemplate; @@ -44,9 +44,9 @@ import java.util.List; @Deprecated public class LdapAuthenticationProvider implements AuthenticationProvider { - private final NacosUserDetailsServiceImpl userDetailsService; + private final NacosUserService userDetailsService; - private final NacosRoleServiceImpl nacosRoleService; + private final NacosRoleService nacosRoleService; private final LdapTemplate ldapTemplate; @@ -54,8 +54,8 @@ public class LdapAuthenticationProvider implements AuthenticationProvider { private final boolean caseSensitive; - public LdapAuthenticationProvider(LdapTemplate ldapTemplate, NacosUserDetailsServiceImpl userDetailsService, - NacosRoleServiceImpl nacosRoleService, String filterPrefix, boolean caseSensitive) { + public LdapAuthenticationProvider(LdapTemplate ldapTemplate, NacosUserService userDetailsService, + NacosRoleService nacosRoleService, String filterPrefix, boolean caseSensitive) { this.ldapTemplate = ldapTemplate; this.nacosRoleService = nacosRoleService; this.userDetailsService = userDetailsService; @@ -94,7 +94,8 @@ public class LdapAuthenticationProvider implements AuthenticationProvider { try { userDetails = userDetailsService.loadUserByUsername(AuthConstants.LDAP_PREFIX + username); } catch (UsernameNotFoundException exception) { - userDetailsService.createUser(AuthConstants.LDAP_PREFIX + username, AuthConstants.LDAP_DEFAULT_ENCODED_PASSWORD); + userDetailsService.createUser(AuthConstants.LDAP_PREFIX + username, + AuthConstants.LDAP_DEFAULT_ENCODED_PASSWORD, false); User user = new User(); user.setUsername(AuthConstants.LDAP_PREFIX + username); user.setPassword(AuthConstants.LDAP_DEFAULT_ENCODED_PASSWORD); diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/roles/AbstractCachedRoleService.java b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/roles/AbstractCachedRoleService.java new file mode 100644 index 0000000000..9d243b739c --- /dev/null +++ b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/roles/AbstractCachedRoleService.java @@ -0,0 +1,89 @@ +/* + * Copyright 1999-2025 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.nacos.plugin.auth.impl.roles; + +import com.alibaba.nacos.api.model.Page; +import com.alibaba.nacos.common.utils.ConcurrentHashSet; +import com.alibaba.nacos.core.utils.Loggers; +import com.alibaba.nacos.plugin.auth.impl.persistence.PermissionInfo; +import com.alibaba.nacos.plugin.auth.impl.persistence.RoleInfo; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +/** + * Nacos abstract cached role service. + * + * @author xiweng.yy + */ +@Service +public abstract class AbstractCachedRoleService implements NacosRoleService { + + protected static final int DEFAULT_PAGE_NO = 1; + + private volatile Set roleSet = new ConcurrentHashSet<>(); + + private volatile Map> roleInfoMap = new ConcurrentHashMap<>(); + + private volatile Map> permissionInfoMap = new ConcurrentHashMap<>(); + + protected Set getCachedRoleSet() { + return roleSet; + } + + protected Map> getCachedRoleInfoMap() { + return roleInfoMap; + } + + protected Map> getCachedPermissionInfoMap() { + return permissionInfoMap; + } + + @Scheduled(initialDelay = 5000, fixedDelay = 15000) + protected void reload() { + try { + List roleInfoPage = getAllRoles(); + Set tmpRoleSet = new HashSet<>(16); + Map> tmpRoleInfoMap = new ConcurrentHashMap<>(16); + for (RoleInfo roleInfo : roleInfoPage) { + if (!tmpRoleInfoMap.containsKey(roleInfo.getUsername())) { + tmpRoleInfoMap.put(roleInfo.getUsername(), new ArrayList<>()); + } + tmpRoleInfoMap.get(roleInfo.getUsername()).add(roleInfo); + tmpRoleSet.add(roleInfo.getRole()); + } + + Map> tmpPermissionInfoMap = new ConcurrentHashMap<>(16); + for (String role : tmpRoleSet) { + Page permissionInfoPage = getPermissions(role, DEFAULT_PAGE_NO, Integer.MAX_VALUE); + tmpPermissionInfoMap.put(role, permissionInfoPage.getPageItems()); + } + + roleSet = tmpRoleSet; + roleInfoMap = tmpRoleInfoMap; + permissionInfoMap = tmpPermissionInfoMap; + } catch (Exception e) { + Loggers.AUTH.warn("[LOAD-ROLES] load failed", e); + } + } +} diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/roles/AbstractCheckedRoleService.java b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/roles/AbstractCheckedRoleService.java new file mode 100644 index 0000000000..63695de778 --- /dev/null +++ b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/roles/AbstractCheckedRoleService.java @@ -0,0 +1,165 @@ +/* + * Copyright 1999-2025 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.nacos.plugin.auth.impl.roles; + +import com.alibaba.nacos.api.model.v2.Result; +import com.alibaba.nacos.auth.config.AuthConfigs; +import com.alibaba.nacos.common.utils.CollectionUtils; +import com.alibaba.nacos.common.utils.StringUtils; +import com.alibaba.nacos.plugin.auth.api.Permission; +import com.alibaba.nacos.plugin.auth.api.Resource; +import com.alibaba.nacos.plugin.auth.constant.Constants; +import com.alibaba.nacos.plugin.auth.constant.SignType; +import com.alibaba.nacos.plugin.auth.impl.constant.AuthConstants; +import com.alibaba.nacos.plugin.auth.impl.persistence.PermissionInfo; +import com.alibaba.nacos.plugin.auth.impl.persistence.RoleInfo; +import com.alibaba.nacos.plugin.auth.impl.users.NacosUser; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Properties; +import java.util.regex.Pattern; + +import static com.alibaba.nacos.api.common.Constants.DEFAULT_NAMESPACE_ID; + +/** + * Nacos abstract cached role service. + * + * @author xiweng.yy + */ +@Service +public abstract class AbstractCheckedRoleService extends AbstractCachedRoleService implements NacosRoleService { + + private final AuthConfigs authConfigs; + + protected AbstractCheckedRoleService(AuthConfigs authConfigs) { + this.authConfigs = authConfigs; + } + + @Override + public boolean hasPermission(NacosUser nacosUser, Permission permission) { + if (isUpdatePasswordPermission(permission)) { + return true; + } + + List roleInfoList = getRoles(nacosUser.getUserName()); + if (CollectionUtils.isEmpty(roleInfoList)) { + return false; + } + + // Global admin pass: + for (RoleInfo roleInfo : roleInfoList) { + if (AuthConstants.GLOBAL_ADMIN_ROLE.equals(roleInfo.getRole())) { + nacosUser.setGlobalAdmin(true); + return true; + } + } + + // Old global admin can pass resource 'console/': + if (permission.getResource().getName().startsWith(AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX)) { + return false; + } + + // For other roles, use a pattern match to decide if pass or not. + for (RoleInfo roleInfo : roleInfoList) { + List permissionInfoList = getPermissions(roleInfo.getRole()); + if (CollectionUtils.isEmpty(permissionInfoList)) { + continue; + } + for (PermissionInfo permissionInfo : permissionInfoList) { + String permissionResource = permissionInfo.getResource().replaceAll("\\*", ".*"); + String permissionAction = permissionInfo.getAction(); + if (permissionAction.contains(permission.getAction()) && Pattern.matches(permissionResource, + joinResource(permission.getResource()))) { + return true; + } + } + } + return false; + } + + @Override + public Result isDuplicatePermission(String role, String resource, String action) { + List permissionInfos = getPermissions(role); + if (CollectionUtils.isEmpty(permissionInfos)) { + return Result.success(Boolean.FALSE); + } + for (PermissionInfo permissionInfo : permissionInfos) { + boolean resourceMatch = StringUtils.equals(resource, permissionInfo.getResource()); + boolean actionMatch = + StringUtils.equals(action, permissionInfo.getAction()) || "rw".equals(permissionInfo.getAction()); + if (resourceMatch && actionMatch) { + return Result.success(Boolean.TRUE); + } + } + return Result.success(Boolean.FALSE); + } + + @Override + public boolean hasGlobalAdminRole(String userName) { + List roles = getRoles(userName); + return roles.stream().anyMatch(roleInfo -> AuthConstants.GLOBAL_ADMIN_ROLE.equals(roleInfo.getRole())); + } + + @Override + public boolean hasGlobalAdminRole() { + if (authConfigs.isHasGlobalAdminRole()) { + return true; + } + List roles = getAllRoles(); + boolean hasGlobalAdminRole = CollectionUtils.isNotEmpty(roles) && roles.stream() + .anyMatch(roleInfo -> AuthConstants.GLOBAL_ADMIN_ROLE.equals(roleInfo.getRole())); + authConfigs.setHasGlobalAdminRole(hasGlobalAdminRole); + return hasGlobalAdminRole; + } + + /** + * If API is update user password, don't do permission check, because there is permission check in API logic. + */ + private boolean isUpdatePasswordPermission(Permission permission) { + Properties properties = permission.getResource().getProperties(); + return null != properties && properties.contains(AuthConstants.UPDATE_PASSWORD_ENTRY_POINT); + } + + private String joinResource(Resource resource) { + if (SignType.SPECIFIED.equals(resource.getType())) { + return resource.getName(); + } + StringBuilder result = new StringBuilder(); + String namespaceId = resource.getNamespaceId(); + if (StringUtils.isNotBlank(namespaceId)) { + // https://github.com/alibaba/nacos/issues/10347 + if (!DEFAULT_NAMESPACE_ID.equals(namespaceId)) { + result.append(namespaceId); + } + } + String group = resource.getGroup(); + if (StringUtils.isBlank(group)) { + result.append(Constants.Resource.SPLITTER).append('*'); + } else { + result.append(Constants.Resource.SPLITTER).append(group); + } + String resourceName = resource.getName(); + if (StringUtils.isBlank(resourceName)) { + result.append(Constants.Resource.SPLITTER).append(resource.getType().toLowerCase()).append("/*"); + } else { + result.append(Constants.Resource.SPLITTER).append(resource.getType().toLowerCase()).append('/') + .append(resourceName); + } + return result.toString(); + } +} diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/roles/NacosRoleService.java b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/roles/NacosRoleService.java new file mode 100644 index 0000000000..504e7a523c --- /dev/null +++ b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/roles/NacosRoleService.java @@ -0,0 +1,192 @@ +/* + * Copyright 1999-2025 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.nacos.plugin.auth.impl.roles; + +import com.alibaba.nacos.api.model.Page; +import com.alibaba.nacos.api.model.v2.Result; +import com.alibaba.nacos.plugin.auth.api.Permission; +import com.alibaba.nacos.plugin.auth.impl.persistence.PermissionInfo; +import com.alibaba.nacos.plugin.auth.impl.persistence.RoleInfo; +import com.alibaba.nacos.plugin.auth.impl.users.NacosUser; + +import java.util.List; + +/** + * Nacos auth plugin role service interface. + * + * @author xiweng.yy + */ +public interface NacosRoleService { + + /** + * Determine if the user has permission of the resource. + * + *

    Note if the user has many roles, this method returns true if any one role of the user has the desired + * permission. + * + * @param nacosUser user info + * @param permission permission to auth + * @return true if granted, false otherwise + */ + boolean hasPermission(NacosUser nacosUser, Permission permission); + + /** + * Add permission to tole. + * + * @param role role name + * @param resource resource + * @param action action + */ + void addPermission(String role, String resource, String action); + + /** + * Delete permission from role. + * + * @param role role name + * @param resource resource + * @param action action + */ + void deletePermission(String role, String resource, String action); + + /** + * Get all permissions of the role. + * + * @param role role name + * @return List of {@link PermissionInfo} for the role + */ + List getPermissions(String role); + + /** + * Accurate search permissions by role name pattern. + * + * @param role role name pattern + * @param pageNo page number + * @param pageSize page size + * @return List of {@link RoleInfo} match role name pattern + */ + Page getPermissions(String role, int pageNo, int pageSize); + + /** + * Blur search permissions by role name pattern. + * + * @param role role name pattern + * @param pageNo page number + * @param pageSize page size + * @return List of {@link RoleInfo} match role name pattern + */ + Page findPermissions(String role, int pageNo, int pageSize); + + /** + * Judge whether the permission is duplicate. + * + * @param role role name + * @param resource resource + * @param action action + * @return true if duplicate, false otherwise + */ + Result isDuplicatePermission(String role, String resource, String action); + + /** + * Get All roles for target user. + * + * @param username username of target user + * @return List of {@link RoleInfo} for target user + */ + List getRoles(String username); + + /** + * Accurate search roles by role name pattern. + * + * @param username username of target user + * @param role role name + * @param pageNo page number + * @param pageSize page size + * @return List of {@link RoleInfo} match role name pattern + */ + Page getRoles(String username, String role, int pageNo, int pageSize); + + /** + * Blur search roles by role name pattern. + * + * @param username username of target user + * @param role role name pattern + * @param pageNo page number + * @param pageSize page size + * @return List of {@link RoleInfo} match role name pattern + */ + Page findRoles(String username, String role, int pageNo, int pageSize); + + /** + * Blur search role names by role name pattern. + * + * @param role role name pattern + * @return List of {@link RoleInfo} match role name pattern + */ + List findRoleNames(String role); + + /** + * Get All roles in Nacos. + * + * @return List of {@link RoleInfo} in Nacos + */ + List getAllRoles(); + + /** + * Add role to user. + * + * @param role role name + * @param username user name + */ + void addRole(String role, String username); + + /** + * Delete Role from user. + * + * @param role role + * @param userName userName + */ + void deleteRole(String role, String userName); + + /** + * Delete Role from Nacos. + * + * @param role role + */ + void deleteRole(String role); + + /** + * Add role. + * + * @param username user name + */ + void addAdminRole(String username); + + /** + * Check if user has admin role. + * + * @param userName user name + * @return true if user has admin role. + */ + boolean hasGlobalAdminRole(String userName); + + /** + * Check if all user has at least one admin role. + * + * @return true if all user has at least one admin role. + */ + boolean hasGlobalAdminRole(); +} diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/roles/NacosRoleServiceDirectImpl.java b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/roles/NacosRoleServiceDirectImpl.java new file mode 100644 index 0000000000..82c60d3d0f --- /dev/null +++ b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/roles/NacosRoleServiceDirectImpl.java @@ -0,0 +1,201 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.nacos.plugin.auth.impl.roles; + +import com.alibaba.nacos.api.model.Page; +import com.alibaba.nacos.auth.config.AuthConfigs; +import com.alibaba.nacos.common.utils.CollectionUtils; +import com.alibaba.nacos.common.utils.StringUtils; +import com.alibaba.nacos.plugin.auth.impl.constant.AuthConstants; +import com.alibaba.nacos.plugin.auth.impl.persistence.PermissionInfo; +import com.alibaba.nacos.plugin.auth.impl.persistence.PermissionPersistService; +import com.alibaba.nacos.plugin.auth.impl.persistence.RoleInfo; +import com.alibaba.nacos.plugin.auth.impl.persistence.RolePersistService; +import com.alibaba.nacos.plugin.auth.impl.users.NacosUserService; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Nacos builtin role service, implemented by directly access to database. + * + * @author nkorange + * @since 1.2.0 + */ +@Service +public class NacosRoleServiceDirectImpl extends AbstractCheckedRoleService implements NacosRoleService { + + private static final int DEFAULT_PAGE_NO = 1; + + private final AuthConfigs authConfigs; + + private final RolePersistService rolePersistService; + + private final NacosUserService userDetailsService; + + private final PermissionPersistService permissionPersistService; + + public NacosRoleServiceDirectImpl(AuthConfigs authConfigs, RolePersistService rolePersistService, + NacosUserService userDetailsService, PermissionPersistService permissionPersistService) { + super(authConfigs); + this.authConfigs = authConfigs; + this.rolePersistService = rolePersistService; + this.userDetailsService = userDetailsService; + this.permissionPersistService = permissionPersistService; + } + + @Override + public List getRoles(String username) { + List roleInfoList = getCachedRoleInfoMap().get(username); + if (!authConfigs.isCachingEnabled() || roleInfoList == null) { + Page roleInfoPage = getRoles(username, StringUtils.EMPTY, DEFAULT_PAGE_NO, Integer.MAX_VALUE); + if (roleInfoPage != null) { + roleInfoList = roleInfoPage.getPageItems(); + if (!CollectionUtils.isEmpty(roleInfoList)) { + getCachedRoleInfoMap().put(username, roleInfoList); + } + } + } + return roleInfoList; + } + + @Override + public Page getRoles(String username, String role, int pageNo, int pageSize) { + Page roles = rolePersistService.getRolesByUserNameAndRoleName(username, role, pageNo, pageSize); + if (roles == null) { + return new Page<>(); + } + return roles; + } + + @Override + public List getAllRoles() { + Page roleInfoPage = rolePersistService.getRolesByUserNameAndRoleName(StringUtils.EMPTY, + StringUtils.EMPTY, DEFAULT_PAGE_NO, Integer.MAX_VALUE); + if (roleInfoPage == null) { + return null; + } + return roleInfoPage.getPageItems(); + } + + @Override + public List getPermissions(String role) { + List permissionInfoList = getCachedPermissionInfoMap().get(role); + if (!authConfigs.isCachingEnabled() || permissionInfoList == null) { + Page permissionInfoPage = getPermissions(role, DEFAULT_PAGE_NO, Integer.MAX_VALUE); + if (permissionInfoPage != null) { + permissionInfoList = permissionInfoPage.getPageItems(); + if (!CollectionUtils.isEmpty(permissionInfoList)) { + getCachedPermissionInfoMap().put(role, permissionInfoList); + } + } + } + return permissionInfoList; + } + + @Override + public Page getPermissions(String role, int pageNo, int pageSize) { + Page pageInfo = permissionPersistService.getPermissions(role, pageNo, pageSize); + if (pageInfo == null) { + return new Page<>(); + } + return pageInfo; + } + + @Override + public void addRole(String role, String username) { + if (userDetailsService.getUser(username) == null) { + throw new IllegalArgumentException("user '" + username + "' not found!"); + } + + if (AuthConstants.GLOBAL_ADMIN_ROLE.equals(role)) { + throw new IllegalArgumentException( + "role '" + AuthConstants.GLOBAL_ADMIN_ROLE + "' is not permitted to create!"); + } + + if (isUserBoundToRole(role, username)) { + throw new IllegalArgumentException("user '" + username + "' already bound to the role '" + role + "'!"); + } + + rolePersistService.addRole(role, username); + getCachedRoleSet().add(role); + } + + @Override + public void addAdminRole(String username) { + if (userDetailsService.getUser(username) == null) { + throw new IllegalArgumentException("user '" + username + "' not found!"); + } + if (hasGlobalAdminRole()) { + throw new IllegalArgumentException("role '" + AuthConstants.GLOBAL_ADMIN_ROLE + "' already exist !"); + } + + rolePersistService.addRole(AuthConstants.GLOBAL_ADMIN_ROLE, username); + getCachedRoleSet().add(AuthConstants.GLOBAL_ADMIN_ROLE); + authConfigs.setHasGlobalAdminRole(true); + } + + @Override + public void deleteRole(String role, String userName) { + rolePersistService.deleteRole(role, userName); + } + + @Override + public void deleteRole(String role) { + rolePersistService.deleteRole(role); + getCachedRoleInfoMap().remove(role); + } + + @Override + public void addPermission(String role, String resource, String action) { + if (!getCachedRoleSet().contains(role)) { + throw new IllegalArgumentException("role " + role + " not found!"); + } + permissionPersistService.addPermission(role, resource, action); + } + + @Override + public void deletePermission(String role, String resource, String action) { + permissionPersistService.deletePermission(role, resource, action); + } + + @Override + public Page findRoles(String username, String role, int pageNo, int pageSize) { + return rolePersistService.findRolesLike4Page(username, role, pageNo, pageSize); + } + + @Override + public List findRoleNames(String role) { + return rolePersistService.findRolesLikeRoleName(role); + } + + @Override + public Page findPermissions(String role, int pageNo, int pageSize) { + return permissionPersistService.findPermissionsLike4Page(role, pageNo, pageSize); + } + + boolean isUserBoundToRole(String role, String username) { + Page roleInfoPage = rolePersistService.getRolesByUserNameAndRoleName(username, role, DEFAULT_PAGE_NO, + 1); + if (roleInfoPage == null) { + return false; + } + List roleInfos = roleInfoPage.getPageItems(); + return CollectionUtils.isNotEmpty(roleInfos) && roleInfos.stream() + .anyMatch(roleInfo -> role.equals(roleInfo.getRole())); + } +} diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/roles/NacosRoleServiceImpl.java b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/roles/NacosRoleServiceImpl.java deleted file mode 100644 index b81786a728..0000000000 --- a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/roles/NacosRoleServiceImpl.java +++ /dev/null @@ -1,422 +0,0 @@ -/* - * Copyright 1999-2018 Alibaba Group Holding Ltd. - * - * Licensed 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 com.alibaba.nacos.plugin.auth.impl.roles; - -import com.alibaba.nacos.api.model.v2.Result; -import com.alibaba.nacos.auth.config.AuthConfigs; -import com.alibaba.nacos.common.utils.CollectionUtils; -import com.alibaba.nacos.common.utils.ConcurrentHashSet; -import com.alibaba.nacos.common.utils.StringUtils; -import com.alibaba.nacos.api.model.Page; -import com.alibaba.nacos.core.utils.Loggers; -import com.alibaba.nacos.plugin.auth.api.Permission; -import com.alibaba.nacos.plugin.auth.api.Resource; -import com.alibaba.nacos.plugin.auth.constant.Constants; -import com.alibaba.nacos.plugin.auth.constant.SignType; -import com.alibaba.nacos.plugin.auth.impl.constant.AuthConstants; -import com.alibaba.nacos.plugin.auth.impl.persistence.PermissionInfo; -import com.alibaba.nacos.plugin.auth.impl.persistence.PermissionPersistService; -import com.alibaba.nacos.plugin.auth.impl.persistence.RoleInfo; -import com.alibaba.nacos.plugin.auth.impl.persistence.RolePersistService; -import com.alibaba.nacos.plugin.auth.impl.users.NacosUser; -import com.alibaba.nacos.plugin.auth.impl.users.NacosUserDetailsServiceImpl; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.regex.Pattern; - -import static com.alibaba.nacos.api.common.Constants.DEFAULT_NAMESPACE_ID; - -/** - * Nacos builtin role service. - * - * @author nkorange - * @since 1.2.0 - */ -@Service -public class NacosRoleServiceImpl { - - private static final int DEFAULT_PAGE_NO = 1; - - @Autowired - private AuthConfigs authConfigs; - - @Autowired - private RolePersistService rolePersistService; - - @Autowired - private NacosUserDetailsServiceImpl userDetailsService; - - @Autowired - private PermissionPersistService permissionPersistService; - - private volatile Set roleSet = new ConcurrentHashSet<>(); - - private volatile Map> roleInfoMap = new ConcurrentHashMap<>(); - - private volatile Map> permissionInfoMap = new ConcurrentHashMap<>(); - - @Scheduled(initialDelay = 5000, fixedDelay = 15000) - private void reload() { - try { - Page roleInfoPage = rolePersistService.getRolesByUserNameAndRoleName(StringUtils.EMPTY, - StringUtils.EMPTY, DEFAULT_PAGE_NO, Integer.MAX_VALUE); - if (roleInfoPage == null) { - return; - } - Set tmpRoleSet = new HashSet<>(16); - Map> tmpRoleInfoMap = new ConcurrentHashMap<>(16); - for (RoleInfo roleInfo : roleInfoPage.getPageItems()) { - if (!tmpRoleInfoMap.containsKey(roleInfo.getUsername())) { - tmpRoleInfoMap.put(roleInfo.getUsername(), new ArrayList<>()); - } - tmpRoleInfoMap.get(roleInfo.getUsername()).add(roleInfo); - tmpRoleSet.add(roleInfo.getRole()); - } - - Map> tmpPermissionInfoMap = new ConcurrentHashMap<>(16); - for (String role : tmpRoleSet) { - Page permissionInfoPage = permissionPersistService.getPermissions(role, DEFAULT_PAGE_NO, - Integer.MAX_VALUE); - tmpPermissionInfoMap.put(role, permissionInfoPage.getPageItems()); - } - - roleSet = tmpRoleSet; - roleInfoMap = tmpRoleInfoMap; - permissionInfoMap = tmpPermissionInfoMap; - } catch (Exception e) { - Loggers.AUTH.warn("[LOAD-ROLES] load failed", e); - } - } - - /** - * Determine if the user has permission of the resource. - * - *

    Note if the user has many roles, this method returns true if any one role of the user has the desired - * permission. - * - * @param nacosUser user info - * @param permission permission to auth - * @return true if granted, false otherwise - */ - public boolean hasPermission(NacosUser nacosUser, Permission permission) { - if (isUpdatePasswordPermission(permission)) { - return true; - } - - List roleInfoList = getRoles(nacosUser.getUserName()); - if (CollectionUtils.isEmpty(roleInfoList)) { - return false; - } - - // Global admin pass: - for (RoleInfo roleInfo : roleInfoList) { - if (AuthConstants.GLOBAL_ADMIN_ROLE.equals(roleInfo.getRole())) { - nacosUser.setGlobalAdmin(true); - return true; - } - } - - // Old global admin can pass resource 'console/': - if (permission.getResource().getName().startsWith(AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX)) { - return false; - } - - // For other roles, use a pattern match to decide if pass or not. - for (RoleInfo roleInfo : roleInfoList) { - List permissionInfoList = getPermissions(roleInfo.getRole()); - if (CollectionUtils.isEmpty(permissionInfoList)) { - continue; - } - for (PermissionInfo permissionInfo : permissionInfoList) { - String permissionResource = permissionInfo.getResource().replaceAll("\\*", ".*"); - String permissionAction = permissionInfo.getAction(); - if (permissionAction.contains(permission.getAction()) && Pattern.matches(permissionResource, - joinResource(permission.getResource()))) { - return true; - } - } - } - return false; - } - - /** - * If API is update user password, don't do permission check, because there is permission check in API logic. - */ - private boolean isUpdatePasswordPermission(Permission permission) { - Properties properties = permission.getResource().getProperties(); - return null != properties && properties.contains(AuthConstants.UPDATE_PASSWORD_ENTRY_POINT); - } - - public List getRoles(String username) { - List roleInfoList = roleInfoMap.get(username); - if (!authConfigs.isCachingEnabled() || roleInfoList == null) { - Page roleInfoPage = getRolesFromDatabase(username, StringUtils.EMPTY, DEFAULT_PAGE_NO, - Integer.MAX_VALUE); - if (roleInfoPage != null) { - roleInfoList = roleInfoPage.getPageItems(); - if (!CollectionUtils.isEmpty(roleInfoList)) { - roleInfoMap.put(username, roleInfoList); - } - } - } - return roleInfoList; - } - - public List getAllRoles() { - Page roleInfoPage = rolePersistService.getRolesByUserNameAndRoleName(StringUtils.EMPTY, - StringUtils.EMPTY, DEFAULT_PAGE_NO, Integer.MAX_VALUE); - if (roleInfoPage == null) { - return null; - } - return roleInfoPage.getPageItems(); - } - - public Page getRolesFromDatabase(String userName, String role, int pageNo, int pageSize) { - Page roles = rolePersistService.getRolesByUserNameAndRoleName(userName, role, pageNo, pageSize); - if (roles == null) { - return new Page<>(); - } - return roles; - } - - public List getPermissions(String role) { - List permissionInfoList = permissionInfoMap.get(role); - if (!authConfigs.isCachingEnabled() || permissionInfoList == null) { - Page permissionInfoPage = getPermissionsFromDatabase(role, DEFAULT_PAGE_NO, - Integer.MAX_VALUE); - if (permissionInfoPage != null) { - permissionInfoList = permissionInfoPage.getPageItems(); - if (!CollectionUtils.isEmpty(permissionInfoList)) { - permissionInfoMap.put(role, permissionInfoList); - } - } - } - return permissionInfoList; - } - - public Page getPermissionsByRoleFromDatabase(String role, int pageNo, int pageSize) { - return permissionPersistService.getPermissions(role, pageNo, pageSize); - } - - /** - * Add role. - * - * @param role role name - * @param username user name - */ - public void addRole(String role, String username) { - if (userDetailsService.getUserFromDatabase(username) == null) { - throw new IllegalArgumentException("user '" + username + "' not found!"); - } - - if (AuthConstants.GLOBAL_ADMIN_ROLE.equals(role)) { - throw new IllegalArgumentException( - "role '" + AuthConstants.GLOBAL_ADMIN_ROLE + "' is not permitted to create!"); - } - - if (isUserBoundToRole(role, username)) { - throw new IllegalArgumentException( - "user '" + username + "' already bound to the role '" + role + "'!"); - } - - rolePersistService.addRole(role, username); - roleSet.add(role); - } - - /** - * Add role. - * - * @param username user name - */ - public void addAdminRole(String username) { - if (userDetailsService.getUserFromDatabase(username) == null) { - throw new IllegalArgumentException("user '" + username + "' not found!"); - } - if (hasGlobalAdminRole()) { - throw new IllegalArgumentException("role '" + AuthConstants.GLOBAL_ADMIN_ROLE + "' already exist !"); - } - - rolePersistService.addRole(AuthConstants.GLOBAL_ADMIN_ROLE, username); - roleSet.add(AuthConstants.GLOBAL_ADMIN_ROLE); - authConfigs.setHasGlobalAdminRole(true); - } - - /** - * delete user Role. - * - * @param role role - * @param userName userName - */ - public void deleteRole(String role, String userName) { - rolePersistService.deleteRole(role, userName); - } - - /** - * deleteRole. - * - * @param role role - */ - public void deleteRole(String role) { - rolePersistService.deleteRole(role); - roleSet.remove(role); - } - - public Page getPermissionsFromDatabase(String role, int pageNo, int pageSize) { - Page pageInfo = permissionPersistService.getPermissions(role, pageNo, pageSize); - if (pageInfo == null) { - return new Page<>(); - } - return pageInfo; - } - - /** - * Add permission. - * - * @param role role name - * @param resource resource - * @param action action - */ - public void addPermission(String role, String resource, String action) { - if (!roleSet.contains(role)) { - throw new IllegalArgumentException("role " + role + " not found!"); - } - permissionPersistService.addPermission(role, resource, action); - } - - public void deletePermission(String role, String resource, String action) { - permissionPersistService.deletePermission(role, resource, action); - } - - public List findRolesLikeRoleName(String role) { - return rolePersistService.findRolesLikeRoleName(role); - } - - private String joinResource(Resource resource) { - if (SignType.SPECIFIED.equals(resource.getType())) { - return resource.getName(); - } - StringBuilder result = new StringBuilder(); - String namespaceId = resource.getNamespaceId(); - if (StringUtils.isNotBlank(namespaceId)) { - // https://github.com/alibaba/nacos/issues/10347 - if (!DEFAULT_NAMESPACE_ID.equals(namespaceId)) { - result.append(namespaceId); - } - } - String group = resource.getGroup(); - if (StringUtils.isBlank(group)) { - result.append(Constants.Resource.SPLITTER).append('*'); - } else { - result.append(Constants.Resource.SPLITTER).append(group); - } - String resourceName = resource.getName(); - if (StringUtils.isBlank(resourceName)) { - result.append(Constants.Resource.SPLITTER).append(resource.getType().toLowerCase()).append("/*"); - } else { - result.append(Constants.Resource.SPLITTER).append(resource.getType().toLowerCase()).append('/') - .append(resourceName); - } - return result.toString(); - } - - public Page findRolesLike4Page(String username, String role, int pageNo, int pageSize) { - return rolePersistService.findRolesLike4Page(username, role, pageNo, pageSize); - } - - public Page findPermissionsLike4Page(String role, int pageNo, int pageSize) { - return permissionPersistService.findPermissionsLike4Page(role, pageNo, pageSize); - } - - /** - * check if user has admin role. - * - * @param userName user name - * @return true if user has admin role. - */ - public boolean hasGlobalAdminRole(String userName) { - List roles = getRoles(userName); - - return roles.stream().anyMatch(roleInfo -> AuthConstants.GLOBAL_ADMIN_ROLE.equals(roleInfo.getRole())); - } - - /** - * check if all user has at least one admin role. - * - * @return true if all user has at least one admin role. - */ - public boolean hasGlobalAdminRole() { - if (authConfigs.isHasGlobalAdminRole()) { - return true; - } - List roles = getAllRoles(); - boolean hasGlobalAdminRole = CollectionUtils.isNotEmpty(roles) && roles.stream() - .anyMatch(roleInfo -> AuthConstants.GLOBAL_ADMIN_ROLE.equals(roleInfo.getRole())); - authConfigs.setHasGlobalAdminRole(hasGlobalAdminRole); - return hasGlobalAdminRole; - } - - /** - * judge whether the permission is duplicate. - * - * @param role role name - * @param resource resource - * @param action action - * @return true if duplicate, false otherwise - */ - public Result isDuplicatePermission(String role, String resource, String action) { - List permissionInfos = getPermissions(role); - if (CollectionUtils.isEmpty(permissionInfos)) { - return Result.success(Boolean.FALSE); - } - for (PermissionInfo permissionInfo : permissionInfos) { - boolean resourceMatch = StringUtils.equals(resource, permissionInfo.getResource()); - boolean actionMatch = StringUtils.equals(action, permissionInfo.getAction()) || "rw".equals(permissionInfo.getAction()); - if (resourceMatch && actionMatch) { - return Result.success(Boolean.TRUE); - } - } - return Result.success(Boolean.FALSE); - } - - /** - * judge whether the user is already bound to the role. - * - * @param role role name - * @param username user name - * @return true if the user is already bound to the role. - */ - public boolean isUserBoundToRole(String role, String username) { - Page roleInfoPage = rolePersistService.getRolesByUserNameAndRoleName(username, - role, DEFAULT_PAGE_NO, 1); - if (roleInfoPage == null) { - return false; - } - List roleInfos = roleInfoPage.getPageItems(); - return CollectionUtils.isNotEmpty(roleInfos) && roleInfos.stream() - .anyMatch(roleInfo -> role.equals(roleInfo.getRole())); - } - -} diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/roles/NacosRoleServiceRemoteImpl.java b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/roles/NacosRoleServiceRemoteImpl.java new file mode 100644 index 0000000000..7709beb2a0 --- /dev/null +++ b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/roles/NacosRoleServiceRemoteImpl.java @@ -0,0 +1,261 @@ +/* + * Copyright 1999-2025 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.nacos.plugin.auth.impl.roles; + +import com.alibaba.nacos.api.exception.NacosException; +import com.alibaba.nacos.api.exception.runtime.NacosRuntimeException; +import com.alibaba.nacos.api.model.Page; +import com.alibaba.nacos.api.model.v2.Result; +import com.alibaba.nacos.auth.config.AuthConfigs; +import com.alibaba.nacos.common.constant.RequestUrlConstants; +import com.alibaba.nacos.common.http.DefaultHttpClientFactory; +import com.alibaba.nacos.common.http.HttpRestResult; +import com.alibaba.nacos.common.http.client.NacosRestTemplate; +import com.alibaba.nacos.common.http.param.Query; +import com.alibaba.nacos.common.utils.JacksonUtils; +import com.alibaba.nacos.common.utils.StringUtils; +import com.alibaba.nacos.plugin.auth.impl.constant.AuthConstants; +import com.alibaba.nacos.plugin.auth.impl.persistence.PermissionInfo; +import com.alibaba.nacos.plugin.auth.impl.persistence.RoleInfo; +import com.alibaba.nacos.plugin.auth.impl.utils.RemoteServerUtil; +import com.fasterxml.jackson.core.type.TypeReference; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.List; +import java.util.Map; + +/** + * Nacos builtin role service, implemented by remote request to nacos server. + * + * @author xiweng.yy + */ +public class NacosRoleServiceRemoteImpl extends AbstractCheckedRoleService implements NacosRoleService { + + private static final Logger LOGGER = LoggerFactory.getLogger(NacosRoleServiceRemoteImpl.class); + + private final NacosRestTemplate nacosRestTemplate; + + private final AuthConfigs authConfigs; + + public NacosRoleServiceRemoteImpl(AuthConfigs authConfigs) { + super(authConfigs); + this.authConfigs = authConfigs; + this.nacosRestTemplate = new DefaultHttpClientFactory(LOGGER).createNacosRestTemplate(); + } + + @Override + public void addPermission(String role, String resource, String action) { + Map body = Map.of("role", role, "resource", resource, "action", action); + try { + HttpRestResult result = nacosRestTemplate.postForm( + buildRemotePermissionUrlPath(AuthConstants.PERMISSION_PATH), + RemoteServerUtil.buildServerRemoteHeader(authConfigs), null, body, String.class); + RemoteServerUtil.singleCheckResult(result); + } catch (NacosException e) { + throw new NacosRuntimeException(e.getErrCode(), e.getErrMsg()); + } catch (Exception unpectedException) { + throw new NacosRuntimeException(NacosException.SERVER_ERROR, unpectedException.getMessage()); + } + } + + @Override + public void deletePermission(String role, String resource, String action) { + Query query = Query.newInstance().addParam("role", role).addParam("resource", resource) + .addParam("action", action); + try { + HttpRestResult result = nacosRestTemplate.delete( + buildRemotePermissionUrlPath(AuthConstants.PERMISSION_PATH), + RemoteServerUtil.buildServerRemoteHeader(authConfigs), query, String.class); + RemoteServerUtil.singleCheckResult(result); + } catch (NacosException e) { + throw new NacosRuntimeException(e.getErrCode(), e.getErrMsg()); + } catch (Exception unpectedException) { + throw new NacosRuntimeException(NacosException.SERVER_ERROR, unpectedException.getMessage()); + } + } + + @Override + public List getPermissions(String role) { + if (getCachedPermissionInfoMap().containsKey(role)) { + return getCachedPermissionInfoMap().get(role); + } + reload(); + return getCachedPermissionInfoMap().get(role); + } + + @Override + public Page getPermissions(String role, int pageNo, int pageSize) { + Query query = Query.newInstance().addParam("role", role).addParam("pageNo", pageNo) + .addParam("pageSize", pageSize).addParam("search", "accurate"); + return getPermissionInfoPageFromRemote(query); + } + + @Override + public Page findPermissions(String role, int pageNo, int pageSize) { + Query query = Query.newInstance().addParam("role", role).addParam("pageNo", pageNo) + .addParam("pageSize", pageSize).addParam("search", "blur"); + return getPermissionInfoPageFromRemote(query); + } + + @Override + public List getRoles(String username) { + if (getCachedRoleInfoMap().containsKey(username)) { + return getCachedRoleInfoMap().get(username); + } + reload(); + return getCachedRoleInfoMap().get(username); + } + + @Override + public Page getRoles(String username, String role, int pageNo, int pageSize) { + Query query = Query.newInstance().addParam("username", username).addParam("role", role) + .addParam("pageNo", pageNo).addParam("pageSize", pageSize).addParam("search", "accurate"); + return getRoleInfoPageFromRemote(query); + } + + @Override + public Page findRoles(String username, String role, int pageNo, int pageSize) { + Query query = Query.newInstance().addParam("username", username).addParam("role", role) + .addParam("pageNo", pageNo).addParam("pageSize", pageSize).addParam("search", "blur"); + return getRoleInfoPageFromRemote(query); + } + + @Override + public List findRoleNames(String role) { + Query query = Query.newInstance().addParam("role", role); + try { + HttpRestResult httpResult = nacosRestTemplate.get( + buildRemoteRoleUrlPath(AuthConstants.ROLE_PATH + "/search"), + RemoteServerUtil.buildServerRemoteHeader(authConfigs), query, String.class); + RemoteServerUtil.singleCheckResult(httpResult); + Result> result = JacksonUtils.toObj(httpResult.getData(), new TypeReference<>() { + }); + return result.getData(); + } catch (NacosException e) { + throw new NacosRuntimeException(e.getErrCode(), e.getErrMsg()); + } catch (Exception unpectedException) { + throw new NacosRuntimeException(NacosException.SERVER_ERROR, unpectedException.getMessage()); + } + } + + @Override + public List getAllRoles() { + return getRoles(StringUtils.EMPTY, StringUtils.EMPTY, DEFAULT_PAGE_NO, Integer.MAX_VALUE).getPageItems(); + } + + @Override + public void addRole(String role, String username) { + if (AuthConstants.GLOBAL_ADMIN_ROLE.equals(role)) { + throw new IllegalArgumentException( + "role '" + AuthConstants.GLOBAL_ADMIN_ROLE + "' is not permitted to create!"); + } + Map body = Map.of("role", role, "username", username); + try { + HttpRestResult httpResult = nacosRestTemplate.postForm( + buildRemoteRoleUrlPath(AuthConstants.ROLE_PATH), + RemoteServerUtil.buildServerRemoteHeader(authConfigs), body, String.class); + RemoteServerUtil.singleCheckResult(httpResult); + getCachedRoleSet().add(role); + } catch (NacosException e) { + throw new NacosRuntimeException(e.getErrCode(), e.getErrMsg()); + } catch (Exception unpectedException) { + throw new NacosRuntimeException(NacosException.SERVER_ERROR, unpectedException.getMessage()); + } + } + + @Override + public void deleteRole(String role, String userName) { + Query query = Query.newInstance().addParam("role", role).addParam("userName", userName); + try { + HttpRestResult result = nacosRestTemplate.delete(buildRemoteRoleUrlPath(AuthConstants.ROLE_PATH), + RemoteServerUtil.buildServerRemoteHeader(authConfigs), query, String.class); + RemoteServerUtil.singleCheckResult(result); + } catch (NacosException e) { + throw new NacosRuntimeException(e.getErrCode(), e.getErrMsg()); + } catch (Exception unpectedException) { + throw new NacosRuntimeException(NacosException.SERVER_ERROR, unpectedException.getMessage()); + } + } + + @Override + public void deleteRole(String role) { + Query query = Query.newInstance().addParam("role", role); + try { + HttpRestResult result = nacosRestTemplate.delete(buildRemoteRoleUrlPath(AuthConstants.ROLE_PATH), + RemoteServerUtil.buildServerRemoteHeader(authConfigs), query, String.class); + RemoteServerUtil.singleCheckResult(result); + getCachedRoleSet().remove(role); + } catch (NacosException e) { + throw new NacosRuntimeException(e.getErrCode(), e.getErrMsg()); + } catch (Exception unpectedException) { + throw new NacosRuntimeException(NacosException.SERVER_ERROR, unpectedException.getMessage()); + } + } + + @Override + public void addAdminRole(String username) { + if (hasGlobalAdminRole()) { + throw new IllegalArgumentException("role '" + AuthConstants.GLOBAL_ADMIN_ROLE + "' already exist !"); + } + addRole(AuthConstants.GLOBAL_ADMIN_ROLE, username); + getCachedRoleSet().add(AuthConstants.GLOBAL_ADMIN_ROLE); + authConfigs.setHasGlobalAdminRole(true); + } + + private String buildRemotePermissionUrlPath(String apiPath) { + return RequestUrlConstants.HTTP_PREFIX + RemoteServerUtil.getOneNacosServerAddress() + + RemoteServerUtil.getRemoteServerContextPath() + apiPath; + } + + private Page getPermissionInfoPageFromRemote(Query query) { + try { + HttpRestResult httpResult = nacosRestTemplate.get( + buildRemotePermissionUrlPath(AuthConstants.PERMISSION_PATH + "/list"), + RemoteServerUtil.buildServerRemoteHeader(authConfigs), query, String.class); + RemoteServerUtil.singleCheckResult(httpResult); + Result> result = JacksonUtils.toObj(httpResult.getData(), new TypeReference<>() { + }); + return result.getData(); + } catch (NacosException e) { + throw new NacosRuntimeException(e.getErrCode(), e.getErrMsg()); + } catch (Exception unpectedException) { + throw new NacosRuntimeException(NacosException.SERVER_ERROR, unpectedException.getMessage()); + } + } + + private String buildRemoteRoleUrlPath(String apiPath) { + return RequestUrlConstants.HTTP_PREFIX + RemoteServerUtil.getOneNacosServerAddress() + + RemoteServerUtil.getRemoteServerContextPath() + apiPath; + } + + private Page getRoleInfoPageFromRemote(Query query) { + try { + HttpRestResult httpResult = nacosRestTemplate.get( + buildRemoteRoleUrlPath(AuthConstants.ROLE_PATH + "/list"), + RemoteServerUtil.buildServerRemoteHeader(authConfigs), query, String.class); + RemoteServerUtil.singleCheckResult(httpResult); + Result> result = JacksonUtils.toObj(httpResult.getData(), new TypeReference<>() { + }); + return result.getData(); + } catch (NacosException e) { + throw new NacosRuntimeException(e.getErrCode(), e.getErrMsg()); + } catch (Exception unpectedException) { + throw new NacosRuntimeException(NacosException.SERVER_ERROR, unpectedException.getMessage()); + } + } +} diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/users/AbstractCachedUserService.java b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/users/AbstractCachedUserService.java new file mode 100644 index 0000000000..3f5b89f065 --- /dev/null +++ b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/users/AbstractCachedUserService.java @@ -0,0 +1,63 @@ +/* + * Copyright 1999-2025 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.nacos.plugin.auth.impl.users; + +import com.alibaba.nacos.api.model.Page; +import com.alibaba.nacos.common.utils.StringUtils; +import com.alibaba.nacos.core.utils.Loggers; +import com.alibaba.nacos.plugin.auth.impl.persistence.User; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * Nacos abstract cached user service. + * + * @author xiweng.yy + */ +@Service +public abstract class AbstractCachedUserService implements NacosUserService { + + private Map userMap = new ConcurrentHashMap<>(); + + protected AbstractCachedUserService() { + } + + protected Map getCachedUserMap() { + return userMap; + } + + @Scheduled(initialDelay = 5000, fixedDelay = 15000) + protected void reload() { + try { + Page users = getUsers(1, Integer.MAX_VALUE, StringUtils.EMPTY); + if (users == null) { + return; + } + + Map map = new ConcurrentHashMap<>(16); + for (User user : users.getPageItems()) { + map.put(user.getUsername(), user); + } + userMap = map; + } catch (Exception e) { + Loggers.AUTH.warn("[LOAD-USERS] load failed", e); + } + } +} diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/users/NacosUserService.java b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/users/NacosUserService.java new file mode 100644 index 0000000000..1d0a32d8be --- /dev/null +++ b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/users/NacosUserService.java @@ -0,0 +1,101 @@ +/* + * Copyright 1999-2025 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.nacos.plugin.auth.impl.users; + +import com.alibaba.nacos.api.model.Page; +import com.alibaba.nacos.plugin.auth.impl.persistence.User; +import org.springframework.security.core.userdetails.UserDetailsService; + +import java.util.List; + +/** + * Nacos auth plugin user service interface. + * + * @author xiweng.yy + */ +public interface NacosUserService extends UserDetailsService { + + /** + * Update user password. + * + * @param username username to be updated password + * @param password new password + */ + void updateUserPassword(String username, String password); + + /** + * Get users by paged. + * + * @param pageNo page number + * @param pageSize page size + * @param username username + * @return user list + */ + Page getUsers(int pageNo, int pageSize, String username); + + /** + * Find users with blur search by paged. + * + * @param username username + * @param pageNo page number + * @param pageSize page size + * @return user list + */ + Page findUsers(String username, int pageNo, int pageSize); + + /** + * Get User info by username. + * + * @param username username + * @return {@link User} information + */ + User getUser(String username); + + /** + * Find usernames with blur search. + * + * @param username username + * @return usernames + */ + List findUserNames(String username); + + /** + * Create user. + * + * @param username username + * @param password password + */ + default void createUser(String username, String password) { + createUser(username, password, true); + } + + /** + * Create user. + * + * @param username username + * @param password password + * @param encode {@code true} will encode password, {@code false} will not encode password + */ + void createUser(String username, String password, boolean encode); + + /** + * Delete user. + * + * @param username username + */ + void deleteUser(String username); +} diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/users/NacosUserDetailsServiceImpl.java b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/users/NacosUserServiceDirectImpl.java similarity index 51% rename from plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/users/NacosUserDetailsServiceImpl.java rename to plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/users/NacosUserServiceDirectImpl.java index 89bdb63bbf..84f733e818 100644 --- a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/users/NacosUserDetailsServiceImpl.java +++ b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/users/NacosUserServiceDirectImpl.java @@ -16,109 +16,83 @@ package com.alibaba.nacos.plugin.auth.impl.users; -import com.alibaba.nacos.auth.config.AuthConfigs; -import com.alibaba.nacos.common.utils.StringUtils; - -import com.alibaba.nacos.plugin.auth.impl.persistence.UserPersistService; import com.alibaba.nacos.api.model.Page; +import com.alibaba.nacos.auth.config.AuthConfigs; import com.alibaba.nacos.plugin.auth.impl.persistence.User; -import com.alibaba.nacos.core.utils.Loggers; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Scheduled; +import com.alibaba.nacos.plugin.auth.impl.persistence.UserPersistService; +import com.alibaba.nacos.plugin.auth.impl.utils.PasswordEncoderUtil; import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.stereotype.Service; import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; /** - * Custom user service. + * Custom user service, implemented by directly access to database. * * @author wfnuser * @author nkorange */ @Service -public class NacosUserDetailsServiceImpl implements UserDetailsService { +public class NacosUserServiceDirectImpl extends AbstractCachedUserService implements NacosUserService { - private Map userMap = new ConcurrentHashMap<>(); + private final UserPersistService userPersistService; - @Autowired - private UserPersistService userPersistService; + private final AuthConfigs authConfigs; - @Autowired - private AuthConfigs authConfigs; - - @Scheduled(initialDelay = 5000, fixedDelay = 15000) - private void reload() { - try { - Page users = getUsersFromDatabase(1, Integer.MAX_VALUE, StringUtils.EMPTY); - if (users == null) { - return; - } - - Map map = new ConcurrentHashMap<>(16); - for (User user : users.getPageItems()) { - map.put(user.getUsername(), user); - } - userMap = map; - } catch (Exception e) { - Loggers.AUTH.warn("[LOAD-USERS] load failed", e); - } + public NacosUserServiceDirectImpl(AuthConfigs authConfigs, UserPersistService userPersistService) { + super(); + this.userPersistService = userPersistService; + this.authConfigs = authConfigs; } @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { - - User user = userMap.get(username); + User user = getCachedUserMap().get(username); if (!authConfigs.isCachingEnabled()) { - user = userPersistService.findUserByUsername(username); + user = getUser(username); } - if (user == null) { throw new UsernameNotFoundException(String.format("User %s not found", username)); } return new NacosUserDetails(user); } + @Override public void updateUserPassword(String username, String password) { - userPersistService.updateUserPassword(username, password); + userPersistService.updateUserPassword(username, PasswordEncoderUtil.encode(password)); } - public Page getUsersFromDatabase(int pageNo, int pageSize, String username) { + @Override + public Page getUsers(int pageNo, int pageSize, String username) { return userPersistService.getUsers(pageNo, pageSize, username); } + @Override public User getUser(String username) { - User user = userMap.get(username); - if (!authConfigs.isCachingEnabled() || user == null) { - user = getUserFromDatabase(username); - if (user != null) { - userMap.put(username, user); - } - } - return user; - } - - public User getUserFromDatabase(String username) { return userPersistService.findUserByUsername(username); } - public List findUserLikeUsername(String username) { + @Override + public List findUserNames(String username) { return userPersistService.findUserLikeUsername(username); } - public void createUser(String username, String password) { + @Override + public void createUser(String username, String password, boolean encode) { + if (encode) { + password = PasswordEncoderUtil.encode(password); + } userPersistService.createUser(username, password); } + @Override public void deleteUser(String username) { userPersistService.deleteUser(username); } - public Page findUsersLike4Page(String username, int pageNo, int pageSize) { + @Override + public Page findUsers(String username, int pageNo, int pageSize) { return userPersistService.findUsersLike4Page(username, pageNo, pageSize); } } diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/users/NacosUserServiceRemoteImpl.java b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/users/NacosUserServiceRemoteImpl.java new file mode 100644 index 0000000000..e2949f72df --- /dev/null +++ b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/users/NacosUserServiceRemoteImpl.java @@ -0,0 +1,176 @@ +/* + * Copyright 1999-2025 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.nacos.plugin.auth.impl.users; + +import com.alibaba.nacos.api.exception.NacosException; +import com.alibaba.nacos.api.exception.runtime.NacosRuntimeException; +import com.alibaba.nacos.api.model.Page; +import com.alibaba.nacos.api.model.v2.Result; +import com.alibaba.nacos.auth.config.AuthConfigs; +import com.alibaba.nacos.common.constant.RequestUrlConstants; +import com.alibaba.nacos.common.http.DefaultHttpClientFactory; +import com.alibaba.nacos.common.http.HttpRestResult; +import com.alibaba.nacos.common.http.client.NacosRestTemplate; +import com.alibaba.nacos.common.http.param.Query; +import com.alibaba.nacos.common.utils.JacksonUtils; +import com.alibaba.nacos.plugin.auth.impl.constant.AuthConstants; +import com.alibaba.nacos.plugin.auth.impl.persistence.User; +import com.alibaba.nacos.plugin.auth.impl.utils.RemoteServerUtil; +import com.fasterxml.jackson.core.type.TypeReference; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UsernameNotFoundException; + +import java.util.List; +import java.util.Map; + +/** + * Custom user service, implemented by remote request to nacos server. + * + * @author xiweng.yy + */ +public class NacosUserServiceRemoteImpl extends AbstractCachedUserService implements NacosUserService { + + private static final Logger LOGGER = LoggerFactory.getLogger(NacosUserServiceRemoteImpl.class); + + private final NacosRestTemplate nacosRestTemplate; + + private final AuthConfigs authConfigs; + + public NacosUserServiceRemoteImpl(AuthConfigs authConfigs) { + super(); + this.authConfigs = authConfigs; + this.nacosRestTemplate = new DefaultHttpClientFactory(LOGGER).createNacosRestTemplate(); + } + + @Override + public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { + User user = getUser(username); + if (null == user) { + throw new UsernameNotFoundException(String.format("User %s not found", username)); + } + return new NacosUserDetails(user); + } + + @Override + public void updateUserPassword(String username, String password) { + Query query = Query.newInstance().addParam("username", username); + Map body = Map.of("newPassword", password); + try { + HttpRestResult result = nacosRestTemplate.putForm(buildRemoteUserUrlPath(AuthConstants.USER_PATH), + RemoteServerUtil.buildServerRemoteHeader(authConfigs), query, body, String.class); + RemoteServerUtil.singleCheckResult(result); + } catch (NacosException e) { + throw new NacosRuntimeException(e.getErrCode(), e.getErrMsg()); + } catch (Exception unpectedException) { + throw new NacosRuntimeException(NacosException.SERVER_ERROR, unpectedException.getMessage()); + } + } + + @Override + public Page getUsers(int pageNo, int pageSize, String username) { + Query query = Query.newInstance().addParam("username", username).addParam("pageNo", pageNo) + .addParam("pageSize", pageSize).addParam("search", "accurate"); + return getUserPageFromRemote(query); + } + + @Override + public Page findUsers(String username, int pageNo, int pageSize) { + Query query = Query.newInstance().addParam("username", username).addParam("pageNo", pageNo) + .addParam("pageSize", pageSize).addParam("search", "blur"); + return getUserPageFromRemote(query); + } + + @Override + public User getUser(String username) { + if (getCachedUserMap().containsKey(username)) { + return getCachedUserMap().get(username); + } + reload(); + return getCachedUserMap().get(username); + } + + @Override + public List findUserNames(String username) { + Query query = Query.newInstance().addParam("username", username); + try { + HttpRestResult httpResult = nacosRestTemplate.get( + buildRemoteUserUrlPath(AuthConstants.USER_PATH + "/search"), + RemoteServerUtil.buildServerRemoteHeader(authConfigs), query, String.class); + RemoteServerUtil.singleCheckResult(httpResult); + Result> result = JacksonUtils.toObj(httpResult.getData(), new TypeReference<>() { + }); + return result.getData(); + } catch (NacosException e) { + throw new NacosRuntimeException(e.getErrCode(), e.getErrMsg()); + } catch (Exception unpectedException) { + throw new NacosRuntimeException(NacosException.SERVER_ERROR, unpectedException.getMessage()); + } + } + + @Override + public void createUser(String username, String password, boolean encode) { + // ignore encode = true, let nacos server do encode + Query query = Query.newInstance().addParam("username", username); + Map body = Map.of("password", password); + try { + HttpRestResult result = nacosRestTemplate.postForm(buildRemoteUserUrlPath(AuthConstants.USER_PATH), + RemoteServerUtil.buildServerRemoteHeader(authConfigs), query, body, String.class); + RemoteServerUtil.singleCheckResult(result); + } catch (NacosException e) { + throw new NacosRuntimeException(e.getErrCode(), e.getErrMsg()); + } catch (Exception unpectedException) { + throw new NacosRuntimeException(NacosException.SERVER_ERROR, unpectedException.getMessage()); + } + } + + @Override + public void deleteUser(String username) { + Query query = Query.newInstance().addParam("username", username); + try { + HttpRestResult result = nacosRestTemplate.delete(buildRemoteUserUrlPath(AuthConstants.USER_PATH), + RemoteServerUtil.buildServerRemoteHeader(authConfigs), query, String.class); + RemoteServerUtil.singleCheckResult(result); + } catch (NacosException e) { + throw new NacosRuntimeException(e.getErrCode(), e.getErrMsg()); + } catch (Exception unpectedException) { + throw new NacosRuntimeException(NacosException.SERVER_ERROR, unpectedException.getMessage()); + } + } + + private String buildRemoteUserUrlPath(String apiPath) { + return RequestUrlConstants.HTTP_PREFIX + RemoteServerUtil.getOneNacosServerAddress() + + RemoteServerUtil.getRemoteServerContextPath() + apiPath; + } + + private Page getUserPageFromRemote(Query query) { + try { + HttpRestResult httpResult = nacosRestTemplate.get( + buildRemoteUserUrlPath(AuthConstants.USER_PATH + "/list"), + RemoteServerUtil.buildServerRemoteHeader(authConfigs), query, String.class); + RemoteServerUtil.singleCheckResult(httpResult); + Result> result = JacksonUtils.toObj(httpResult.getData(), new TypeReference<>() { + }); + return result.getData(); + } catch (NacosException e) { + throw new NacosRuntimeException(e.getErrCode(), e.getErrMsg()); + } catch (Exception unpectedException) { + throw new NacosRuntimeException(NacosException.SERVER_ERROR, unpectedException.getMessage()); + } + } +} diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/utils/RemoteServerUtil.java b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/utils/RemoteServerUtil.java new file mode 100644 index 0000000000..1a001c67d4 --- /dev/null +++ b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/utils/RemoteServerUtil.java @@ -0,0 +1,124 @@ +/* + * Copyright 1999-2025 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.nacos.plugin.auth.impl.utils; + +import com.alibaba.nacos.api.exception.NacosException; +import com.alibaba.nacos.auth.config.AuthConfigs; +import com.alibaba.nacos.common.http.HttpRestResult; +import com.alibaba.nacos.common.http.param.Header; +import com.alibaba.nacos.common.utils.StringUtils; +import com.alibaba.nacos.sys.env.EnvUtil; +import com.alibaba.nacos.sys.file.FileChangeEvent; +import com.alibaba.nacos.sys.file.FileWatcher; +import com.alibaba.nacos.sys.file.WatchFileCenter; + +import java.io.IOException; +import java.util.LinkedList; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * Nacos auth plugin remote nacos server util. + * + * @author xiweng.yy + */ +public class RemoteServerUtil { + + private static List serverAddresses = new LinkedList<>(); + + private static AtomicInteger index = new AtomicInteger(); + + private static String remoteServerContextPath = "/nacos"; + + static { + readRemoteServerAddress(); + registerWatcher(); + initRemoteServerContextPath(); + } + + private static void initRemoteServerContextPath() { + remoteServerContextPath = EnvUtil.getProperty("nacos.console.remote.server.context-path", "/nacos"); + } + + private static void registerWatcher() { + try { + WatchFileCenter.registerWatcher(EnvUtil.getClusterConfFilePath(), new FileWatcher() { + + @Override + public void onChange(FileChangeEvent event) { + readRemoteServerAddress(); + } + + @Override + public boolean interest(String context) { + return true; + } + }); + } catch (Exception ignored) { + } + } + + /** + * Read nacos server address from cluster.conf. + */ + public static void readRemoteServerAddress() { + try { + serverAddresses = EnvUtil.readClusterConf(); + } catch (IOException ignored) { + } + } + + public static List getServerAddresses() { + return new LinkedList<>(serverAddresses); + } + + public static String getOneNacosServerAddress() { + int actual = index.getAndUpdate(operand -> (operand + 1) % serverAddresses.size()); + return serverAddresses.get(actual); + } + + public static String getRemoteServerContextPath() { + return remoteServerContextPath; + } + + /** + * Single check http result, if not success, wrapper result as Nacos exception. + * + * @param result http execute result + * @throws NacosException wrapper result as NacosException + */ + public static void singleCheckResult(HttpRestResult result) throws NacosException { + if (result.ok()) { + return; + } + throw new NacosException(result.getCode(), result.getMessage()); + } + + /** + * According input {@link AuthConfigs} to build remote server identity header. + * + * @param authConfigs authConfigs + * @return remote server identity header + */ + public static Header buildServerRemoteHeader(AuthConfigs authConfigs) { + Header header = Header.newInstance(); + if (StringUtils.isNotBlank(authConfigs.getServerIdentityKey())) { + header.addParam(authConfigs.getServerIdentityKey(), authConfigs.getServerIdentityValue()); + } + return header; + } +} diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/authenticate/AbstractAuthenticationManagerTest.java b/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/authenticate/AbstractAuthenticationManagerTest.java index 69df77d91a..bcd079d7b2 100644 --- a/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/authenticate/AbstractAuthenticationManagerTest.java +++ b/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/authenticate/AbstractAuthenticationManagerTest.java @@ -21,11 +21,11 @@ import com.alibaba.nacos.plugin.auth.api.Permission; import com.alibaba.nacos.plugin.auth.exception.AccessException; import com.alibaba.nacos.plugin.auth.impl.constant.AuthConstants; import com.alibaba.nacos.plugin.auth.impl.persistence.User; -import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleService; import com.alibaba.nacos.plugin.auth.impl.token.TokenManagerDelegate; import com.alibaba.nacos.plugin.auth.impl.users.NacosUser; import com.alibaba.nacos.plugin.auth.impl.users.NacosUserDetails; -import com.alibaba.nacos.plugin.auth.impl.users.NacosUserDetailsServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.users.NacosUserService; import com.alibaba.nacos.plugin.auth.impl.utils.PasswordEncoderUtil; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -48,13 +48,13 @@ public class AbstractAuthenticationManagerTest { private AbstractAuthenticationManager abstractAuthenticationManager; @Mock - private NacosUserDetailsServiceImpl userDetailsService; + private NacosUserService userDetailsService; @Mock private TokenManagerDelegate jwtTokenManager; @Mock - private NacosRoleServiceImpl roleService; + private NacosRoleService roleService; private User user; diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/authenticate/LdapAuthenticationManagerTest.java b/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/authenticate/LdapAuthenticationManagerTest.java index 242283db16..2156442871 100644 --- a/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/authenticate/LdapAuthenticationManagerTest.java +++ b/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/authenticate/LdapAuthenticationManagerTest.java @@ -18,11 +18,11 @@ package com.alibaba.nacos.plugin.auth.impl.authenticate; import com.alibaba.nacos.plugin.auth.exception.AccessException; import com.alibaba.nacos.plugin.auth.impl.persistence.User; -import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleService; import com.alibaba.nacos.plugin.auth.impl.token.TokenManagerDelegate; import com.alibaba.nacos.plugin.auth.impl.users.NacosUser; import com.alibaba.nacos.plugin.auth.impl.users.NacosUserDetails; -import com.alibaba.nacos.plugin.auth.impl.users.NacosUserDetailsServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.users.NacosUserService; import com.alibaba.nacos.plugin.auth.impl.utils.PasswordEncoderUtil; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -39,13 +39,13 @@ import static org.mockito.Mockito.when; public class LdapAuthenticationManagerTest { @Mock - private NacosUserDetailsServiceImpl userDetailsService; + private NacosUserService userDetailsService; @Mock private TokenManagerDelegate jwtTokenManager; @Mock - private NacosRoleServiceImpl roleService; + private NacosRoleService roleService; @Mock private LdapTemplate ldapTemplate; diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/controller/PermissionControllerTest.java b/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/controller/PermissionControllerTest.java index a00305c2b4..78e453ef3b 100644 --- a/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/controller/PermissionControllerTest.java +++ b/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/controller/PermissionControllerTest.java @@ -16,11 +16,11 @@ package com.alibaba.nacos.plugin.auth.impl.controller; +import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.api.model.v2.Result; import com.alibaba.nacos.common.model.RestResult; -import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.plugin.auth.impl.persistence.PermissionInfo; -import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleService; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -42,7 +42,7 @@ public class PermissionControllerTest { private PermissionController permissionController; @Mock - private NacosRoleServiceImpl nacosRoleService; + private NacosRoleService nacosRoleService; @BeforeEach void setUp() throws Exception { @@ -53,8 +53,7 @@ public class PermissionControllerTest { void testGetPermissions() { Page permissionInfoPage = new Page(); - when(nacosRoleService.getPermissionsFromDatabase(anyString(), anyInt(), anyInt())).thenReturn( - permissionInfoPage); + when(nacosRoleService.getPermissions(anyString(), anyInt(), anyInt())).thenReturn(permissionInfoPage); Object permissions = permissionController.getPermissions(1, 10, "admin"); assertEquals(permissionInfoPage, permissions); @@ -64,7 +63,7 @@ public class PermissionControllerTest { void testFuzzySearchPermission() { Page permissionInfoPage = new Page(); - when(nacosRoleService.findPermissionsLike4Page(anyString(), anyInt(), anyInt())).thenReturn(permissionInfoPage); + when(nacosRoleService.findPermissions(anyString(), anyInt(), anyInt())).thenReturn(permissionInfoPage); Page permissions = permissionController.fuzzySearchPermission(1, 10, "admin"); assertEquals(permissionInfoPage, permissions); diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/controller/RoleControllerTest.java b/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/controller/RoleControllerTest.java index b11637216e..7ee421366d 100644 --- a/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/controller/RoleControllerTest.java +++ b/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/controller/RoleControllerTest.java @@ -16,10 +16,10 @@ package com.alibaba.nacos.plugin.auth.impl.controller; -import com.alibaba.nacos.common.model.RestResult; import com.alibaba.nacos.api.model.Page; +import com.alibaba.nacos.common.model.RestResult; import com.alibaba.nacos.plugin.auth.impl.persistence.RoleInfo; -import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleService; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -41,7 +41,7 @@ import static org.mockito.Mockito.when; public class RoleControllerTest { @Mock - private NacosRoleServiceImpl roleService; + private NacosRoleService roleService; @InjectMocks private RoleController roleController; @@ -55,7 +55,7 @@ public class RoleControllerTest { void testGetRoles() { Page rolesTest = new Page(); - when(roleService.getRolesFromDatabase(anyString(), anyString(), anyInt(), anyInt())).thenReturn(rolesTest); + when(roleService.getRoles(anyString(), anyString(), anyInt(), anyInt())).thenReturn(rolesTest); Object roles = roleController.getRoles(1, 10, "nacos", "test"); assertEquals(rolesTest, roles); @@ -66,7 +66,7 @@ public class RoleControllerTest { Page rolesTest = new Page(); - when(roleService.findRolesLike4Page(anyString(), anyString(), anyInt(), anyInt())).thenReturn(rolesTest); + when(roleService.findRoles(anyString(), anyString(), anyInt(), anyInt())).thenReturn(rolesTest); Page roleInfoPage = roleController.fuzzySearchRole(1, 10, "nacos", "test"); @@ -77,7 +77,7 @@ public class RoleControllerTest { void testSearchRoles() { List test = new ArrayList<>(); - when(roleService.findRolesLikeRoleName(anyString())).thenReturn(test); + when(roleService.findRoleNames(anyString())).thenReturn(test); List list = roleController.searchRoles("test"); assertEquals(test, list); diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/controller/UserControllerTest.java b/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/controller/UserControllerTest.java index 0c36c5c0c5..13cefa1163 100644 --- a/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/controller/UserControllerTest.java +++ b/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/controller/UserControllerTest.java @@ -16,10 +16,10 @@ package com.alibaba.nacos.plugin.auth.impl.controller; +import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.auth.config.AuthConfigs; import com.alibaba.nacos.common.model.RestResult; import com.alibaba.nacos.core.context.RequestContextHolder; -import com.alibaba.nacos.api.model.Page; import com.alibaba.nacos.plugin.auth.api.IdentityContext; import com.alibaba.nacos.plugin.auth.exception.AccessException; import com.alibaba.nacos.plugin.auth.impl.authenticate.IAuthenticationManager; @@ -27,13 +27,15 @@ import com.alibaba.nacos.plugin.auth.impl.constant.AuthConstants; import com.alibaba.nacos.plugin.auth.impl.constant.AuthSystemTypes; import com.alibaba.nacos.plugin.auth.impl.persistence.RoleInfo; import com.alibaba.nacos.plugin.auth.impl.persistence.User; -import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleService; import com.alibaba.nacos.plugin.auth.impl.token.TokenManagerDelegate; import com.alibaba.nacos.plugin.auth.impl.users.NacosUser; -import com.alibaba.nacos.plugin.auth.impl.users.NacosUserDetailsServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.users.NacosUserService; import com.alibaba.nacos.sys.env.EnvUtil; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -46,8 +48,6 @@ import org.springframework.mock.env.MockEnvironment; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -82,10 +82,10 @@ class UserControllerTest { private TokenManagerDelegate tokenManagerDelegate; @Mock - private NacosUserDetailsServiceImpl userDetailsService; + private NacosUserService userDetailsService; @Mock - private NacosRoleServiceImpl roleService; + private NacosRoleService roleService; @InjectMocks private UserController userController; @@ -131,7 +131,7 @@ class UserControllerTest { @Test void testCreateUser1() { - when(userDetailsService.getUserFromDatabase("test")).thenReturn(null); + when(userDetailsService.getUser("test")).thenReturn(null); RestResult result = (RestResult) userController.createUser("test", "test"); assertEquals(200, result.getCode()); @@ -139,7 +139,7 @@ class UserControllerTest { @Test void testCreateUser2() { - when(userDetailsService.getUserFromDatabase("test")).thenReturn(new User()); + when(userDetailsService.getUser("test")).thenReturn(new User()); assertThrows(IllegalArgumentException.class, () -> { userController.createUser("test", "test"); }); @@ -211,7 +211,7 @@ class UserControllerTest { void testUpdateUser1() throws IOException { when(authConfigs.isAuthEnabled()).thenReturn(false); - when(userDetailsService.getUserFromDatabase(anyString())).thenReturn(new User()); + when(userDetailsService.getUser(anyString())).thenReturn(new User()); MockHttpServletRequest mockHttpServletRequest = new MockHttpServletRequest(); MockHttpServletResponse mockHttpServletResponse = new MockHttpServletResponse(); RestResult result = (RestResult) userController.updateUser("nacos", "test", @@ -224,7 +224,7 @@ class UserControllerTest { void testUpdateUser2() { when(authConfigs.isAuthEnabled()).thenReturn(false); - when(userDetailsService.getUserFromDatabase(anyString())).thenReturn(null); + when(userDetailsService.getUser(anyString())).thenReturn(null); MockHttpServletRequest mockHttpServletRequest = new MockHttpServletRequest(); MockHttpServletResponse mockHttpServletResponse = new MockHttpServletResponse(); @@ -251,7 +251,7 @@ class UserControllerTest { RequestContextHolder.getContext().getAuthContext().getIdentityContext() .setParameter(AuthConstants.NACOS_USER_KEY, user); when(authConfigs.isAuthEnabled()).thenReturn(true); - when(userDetailsService.getUserFromDatabase(anyString())).thenReturn(new User()); + when(userDetailsService.getUser(anyString())).thenReturn(new User()); MockHttpServletRequest mockHttpServletRequest = new MockHttpServletRequest(); MockHttpServletResponse mockHttpServletResponse = new MockHttpServletResponse(); RestResult result = (RestResult) userController.updateUser("nacos", "test", @@ -265,7 +265,7 @@ class UserControllerTest { RequestContextHolder.getContext().getAuthContext().getIdentityContext() .setParameter(AuthConstants.NACOS_USER_KEY, null); when(authConfigs.isAuthEnabled()).thenReturn(true); - when(userDetailsService.getUserFromDatabase(anyString())).thenReturn(new User()); + when(userDetailsService.getUser(anyString())).thenReturn(new User()); when(authenticationManager.authenticate(any(MockHttpServletRequest.class))).thenReturn(user); MockHttpServletRequest mockHttpServletRequest = new MockHttpServletRequest(); @@ -313,7 +313,7 @@ class UserControllerTest { void testGetUsers() { Page userPage = new Page<>(); - when(userDetailsService.getUsersFromDatabase(anyInt(), anyInt(), anyString())).thenReturn(userPage); + when(userDetailsService.getUsers(anyInt(), anyInt(), anyString())).thenReturn(userPage); Page nacos = userController.getUsers(1, 10, "nacos"); assertEquals(userPage, nacos); @@ -323,7 +323,7 @@ class UserControllerTest { void testFuzzySearchUser() { Page userPage = new Page<>(); - when(userDetailsService.findUsersLike4Page(anyString(), anyInt(), anyInt())).thenReturn(userPage); + when(userDetailsService.findUsers(anyString(), anyInt(), anyInt())).thenReturn(userPage); Page nacos = userController.fuzzySearchUser(1, 10, "nacos"); assertEquals(userPage, nacos); @@ -333,7 +333,7 @@ class UserControllerTest { void testSearchUsersLikeUsername() { List test = new ArrayList<>(1); - when(userDetailsService.findUserLikeUsername(anyString())).thenReturn(test); + when(userDetailsService.findUserNames(anyString())).thenReturn(test); List list = userController.searchUsersLikeUsername("nacos"); assertEquals(test, list); diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/controller/v3/PermissionControllerV3Test.java b/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/controller/v3/PermissionControllerV3Test.java index 9f5d8138b5..df07274cd4 100644 --- a/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/controller/v3/PermissionControllerV3Test.java +++ b/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/controller/v3/PermissionControllerV3Test.java @@ -17,10 +17,10 @@ package com.alibaba.nacos.plugin.auth.impl.controller.v3; -import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleServiceImpl; -import com.alibaba.nacos.api.model.v2.Result; import com.alibaba.nacos.api.model.Page; +import com.alibaba.nacos.api.model.v2.Result; import com.alibaba.nacos.plugin.auth.impl.persistence.PermissionInfo; +import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleService; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -49,7 +49,7 @@ public class PermissionControllerV3Test { private PermissionControllerV3 permissionController; @Mock - private NacosRoleServiceImpl nacosRoleService; + private NacosRoleService nacosRoleService; private MockMvc mockMvc; @@ -61,24 +61,23 @@ public class PermissionControllerV3Test { @Test void testGetPermissionListAccurateSearch() { Page permissionInfoPage = new Page<>(); - when(nacosRoleService.getPermissionsFromDatabase(anyString(), anyInt(), anyInt())).thenReturn( - permissionInfoPage); + when(nacosRoleService.getPermissions(anyString(), anyInt(), anyInt())).thenReturn(permissionInfoPage); Result> result = permissionController.getPermissionList(1, 10, "admin", "accurate"); assertEquals(permissionInfoPage, result.getData()); - verify(nacosRoleService, times(1)).getPermissionsFromDatabase("admin", 1, 10); + verify(nacosRoleService, times(1)).getPermissions("admin", 1, 10); } @Test void testGetPermissionListBlurSearch() { Page permissionInfoPage = new Page<>(); - when(nacosRoleService.findPermissionsLike4Page(anyString(), anyInt(), anyInt())).thenReturn(permissionInfoPage); + when(nacosRoleService.findPermissions(anyString(), anyInt(), anyInt())).thenReturn(permissionInfoPage); Result> result = permissionController.getPermissionList(1, 10, "admin", "blur"); assertEquals(permissionInfoPage, result.getData()); - verify(nacosRoleService, times(1)).findPermissionsLike4Page("admin", 1, 10); + verify(nacosRoleService, times(1)).findPermissions("admin", 1, 10); } @Test diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/controller/v3/RoleControllerV3Test.java b/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/controller/v3/RoleControllerV3Test.java index a18425e8e3..07fa119916 100644 --- a/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/controller/v3/RoleControllerV3Test.java +++ b/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/controller/v3/RoleControllerV3Test.java @@ -17,10 +17,10 @@ package com.alibaba.nacos.plugin.auth.impl.controller.v3; -import com.alibaba.nacos.api.model.v2.Result; import com.alibaba.nacos.api.model.Page; +import com.alibaba.nacos.api.model.v2.Result; import com.alibaba.nacos.plugin.auth.impl.persistence.RoleInfo; -import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleService; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -49,7 +49,7 @@ import static org.mockito.Mockito.when; public class RoleControllerV3Test { @Mock - private NacosRoleServiceImpl roleService; + private NacosRoleService roleService; @InjectMocks private RoleControllerV3 roleControllerV3; @@ -92,7 +92,7 @@ public class RoleControllerV3Test { void testGetRoleListAccurateSearch() { Page rolesTest = new Page(); - when(roleService.getRolesFromDatabase(anyString(), anyString(), anyInt(), anyInt())).thenReturn(rolesTest); + when(roleService.getRoles(anyString(), anyString(), anyInt(), anyInt())).thenReturn(rolesTest); Result> result = roleControllerV3.getRoleList(1, 10, "nacos", "test", "accurate"); @@ -103,7 +103,7 @@ public class RoleControllerV3Test { void testGetRoleListFuzzySearch() { Page rolesTest = new Page(); - when(roleService.findRolesLike4Page(anyString(), anyString(), anyInt(), anyInt())).thenReturn(rolesTest); + when(roleService.findRoles(anyString(), anyString(), anyInt(), anyInt())).thenReturn(rolesTest); Result> result = roleControllerV3.getRoleList(1, 10, "nacos", "test", "blur"); @@ -114,7 +114,7 @@ public class RoleControllerV3Test { void testGetRoleListByRoleName() { List rolesTest = new ArrayList<>(); - when(roleService.findRolesLikeRoleName(anyString())).thenReturn(rolesTest); + when(roleService.findRoleNames(anyString())).thenReturn(rolesTest); Result> result = roleControllerV3.getRoleListByRoleName("test"); diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/controller/v3/UserControllerV3Test.java b/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/controller/v3/UserControllerV3Test.java index fa33e222d0..0898df8704 100644 --- a/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/controller/v3/UserControllerV3Test.java +++ b/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/controller/v3/UserControllerV3Test.java @@ -25,10 +25,10 @@ import com.alibaba.nacos.plugin.auth.impl.constant.AuthConstants; import com.alibaba.nacos.plugin.auth.impl.constant.AuthSystemTypes; import com.alibaba.nacos.plugin.auth.impl.persistence.RoleInfo; import com.alibaba.nacos.plugin.auth.impl.persistence.User; -import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleService; import com.alibaba.nacos.plugin.auth.impl.token.TokenManagerDelegate; import com.alibaba.nacos.plugin.auth.impl.users.NacosUser; -import com.alibaba.nacos.plugin.auth.impl.users.NacosUserDetailsServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.users.NacosUserService; import com.fasterxml.jackson.databind.node.ObjectNode; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -63,10 +63,10 @@ import static org.mockito.Mockito.when; class UserControllerV3Test { @Mock - private NacosUserDetailsServiceImpl userDetailsService; + private NacosUserService userDetailsService; @Mock - private NacosRoleServiceImpl roleService; + private NacosRoleService roleService; @Mock private AuthConfigs authConfigs; @@ -92,7 +92,7 @@ class UserControllerV3Test { @Test void testCreateUserSuccess() { - when(userDetailsService.getUserFromDatabase("test")).thenReturn(null); + when(userDetailsService.getUser("test")).thenReturn(null); ArgumentCaptor passwordCaptor = ArgumentCaptor.forClass(String.class); @@ -107,7 +107,7 @@ class UserControllerV3Test { @Test void testCreateUserUserAlreadyExists() { - when(userDetailsService.getUserFromDatabase("test")).thenReturn(new User()); + when(userDetailsService.getUser("test")).thenReturn(new User()); IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> { userControllerV3.createUser("test", "testPass"); @@ -147,7 +147,7 @@ class UserControllerV3Test { MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); - when(userDetailsService.getUserFromDatabase("nacos")).thenReturn(new User()); + when(userDetailsService.getUser("nacos")).thenReturn(new User()); ArgumentCaptor passwordCaptor = ArgumentCaptor.forClass(String.class); diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/ldap/LdapAuthenticationProviderTest.java b/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/ldap/LdapAuthenticationProviderTest.java index aec447ce83..fc7c45eb01 100644 --- a/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/ldap/LdapAuthenticationProviderTest.java +++ b/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/ldap/LdapAuthenticationProviderTest.java @@ -19,9 +19,9 @@ package com.alibaba.nacos.plugin.auth.impl.ldap; import com.alibaba.nacos.plugin.auth.impl.constant.AuthConstants; import com.alibaba.nacos.plugin.auth.impl.persistence.RoleInfo; import com.alibaba.nacos.plugin.auth.impl.persistence.User; -import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.roles.NacosRoleService; import com.alibaba.nacos.plugin.auth.impl.users.NacosUserDetails; -import com.alibaba.nacos.plugin.auth.impl.users.NacosUserDetailsServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.users.NacosUserService; import org.apache.commons.lang.StringUtils; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -67,10 +67,10 @@ class LdapAuthenticationProviderTest { Method ldapLogin; @Mock - private NacosUserDetailsServiceImpl userDetailsService; + private NacosUserService userDetailsService; @Mock - private NacosRoleServiceImpl nacosRoleService; + private NacosRoleService nacosRoleService; @Mock private LdapTemplate ldapTemplate; diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/roles/NacosRoleServiceImplTest.java b/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/roles/NacosRoleServiceDirectImplTest.java similarity index 86% rename from plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/roles/NacosRoleServiceImplTest.java rename to plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/roles/NacosRoleServiceDirectImplTest.java index 63b22ee066..462164a064 100644 --- a/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/roles/NacosRoleServiceImplTest.java +++ b/plugin-default-impl/nacos-default-auth-plugin/src/test/java/com/alibaba/nacos/plugin/auth/impl/roles/NacosRoleServiceDirectImplTest.java @@ -16,8 +16,8 @@ package com.alibaba.nacos.plugin.auth.impl.roles; -import com.alibaba.nacos.auth.config.AuthConfigs; import com.alibaba.nacos.api.model.Page; +import com.alibaba.nacos.auth.config.AuthConfigs; import com.alibaba.nacos.plugin.auth.api.Permission; import com.alibaba.nacos.plugin.auth.api.Resource; import com.alibaba.nacos.plugin.auth.impl.constant.AuthConstants; @@ -27,7 +27,7 @@ import com.alibaba.nacos.plugin.auth.impl.persistence.RoleInfo; import com.alibaba.nacos.plugin.auth.impl.persistence.RolePersistService; import com.alibaba.nacos.plugin.auth.impl.persistence.User; import com.alibaba.nacos.plugin.auth.impl.users.NacosUser; -import com.alibaba.nacos.plugin.auth.impl.users.NacosUserDetailsServiceImpl; +import com.alibaba.nacos.plugin.auth.impl.users.NacosUserService; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -58,9 +58,9 @@ import static org.mockito.Mockito.when; * @Description: TODO */ @ExtendWith(MockitoExtension.class) -class NacosRoleServiceImplTest { +class NacosRoleServiceDirectImplTest { - Class nacosRoleServiceClass; + Class nacosRoleServiceClass; @Mock private AuthConfigs authConfigs; @@ -69,18 +69,18 @@ class NacosRoleServiceImplTest { private RolePersistService rolePersistService; @Mock - private NacosUserDetailsServiceImpl userDetailsService; + private NacosUserService userDetailsService; @Mock private PermissionPersistService permissionPersistService; @Mock - private NacosRoleServiceImpl nacosRoleService; + private NacosRoleServiceDirectImpl nacosRoleService; @BeforeEach void setup() throws Exception { - nacosRoleService = new NacosRoleServiceImpl(); - nacosRoleServiceClass = NacosRoleServiceImpl.class; + nacosRoleService = new NacosRoleServiceDirectImpl(authConfigs, rolePersistService, userDetailsService, permissionPersistService); + nacosRoleServiceClass = NacosRoleServiceDirectImpl.class; Field authConfigsFile = nacosRoleServiceClass.getDeclaredField("authConfigs"); authConfigsFile.setAccessible(true); authConfigsFile.set(nacosRoleService, authConfigs); @@ -122,7 +122,8 @@ class NacosRoleServiceImplTest { permission2.setResource(resource); boolean res2 = nacosRoleService.hasPermission(nacosUser, permission2); assertFalse(res2); - resource.getProperties().put(AuthConstants.UPDATE_PASSWORD_ENTRY_POINT, AuthConstants.UPDATE_PASSWORD_ENTRY_POINT); + resource.getProperties() + .put(AuthConstants.UPDATE_PASSWORD_ENTRY_POINT, AuthConstants.UPDATE_PASSWORD_ENTRY_POINT); boolean res3 = nacosRoleService.hasPermission(nacosUser, permission2); assertTrue(res3); } @@ -134,9 +135,8 @@ class NacosRoleServiceImplTest { } @Test - void getRolesFromDatabase() { - Page roleInfoPage = nacosRoleService.getRolesFromDatabase("nacos", "ROLE_ADMIN", 1, - Integer.MAX_VALUE); + void getRolesPage() { + Page roleInfoPage = nacosRoleService.getRoles("nacos", "ROLE_ADMIN", 1, Integer.MAX_VALUE); assertEquals(0, roleInfoPage.getTotalCount()); } @@ -148,17 +148,10 @@ class NacosRoleServiceImplTest { assertEquals(permissions, Collections.emptyList()); } - @Test - void getPermissionsByRoleFromDatabase() { - Page permissionsByRoleFromDatabase = nacosRoleService.getPermissionsByRoleFromDatabase( - "role-admin", 1, Integer.MAX_VALUE); - assertNull(permissionsByRoleFromDatabase); - } - @Test void addRole() { String username = "nacos"; - User userFromDatabase = userDetailsService.getUserFromDatabase(username); + User userFromDatabase = userDetailsService.getUser(username); assertNull(userFromDatabase); try { nacosRoleService.addRole("role-admin", "nacos"); @@ -177,8 +170,8 @@ class NacosRoleServiceImplTest { } @Test - void getPermissionsFromDatabase() { - Page permissionsFromDatabase = nacosRoleService.getPermissionsFromDatabase("role-admin", 1, + void getPermissionsPage() { + Page permissionsFromDatabase = nacosRoleService.getPermissions("role-admin", 1, Integer.MAX_VALUE); assertEquals(0, permissionsFromDatabase.getTotalCount()); } @@ -214,11 +207,11 @@ class NacosRoleServiceImplTest { permissionInfo.setAction("rw"); permissionInfo.setResource("test"); permissionInfos.add(permissionInfo); - NacosRoleServiceImpl spy = spy(nacosRoleService); + NacosRoleServiceDirectImpl spy = spy(nacosRoleService); when(spy.getPermissions("admin")).thenReturn(permissionInfos); spy.isDuplicatePermission("admin", "test", "r"); } - + @Test void isUserBoundToRole() { String role = "TEST"; diff --git a/server/src/main/resources/nacos-server.properties b/server/src/main/resources/nacos-server.properties index f9cc852885..444058ecfe 100644 --- a/server/src/main/resources/nacos-server.properties +++ b/server/src/main/resources/nacos-server.properties @@ -15,6 +15,6 @@ # ### nacos console port: -server.port=${nacos.server.main.port:8080} +server.port=${nacos.server.main.port:8848} server.servlet.contextPath=${nacos.server.contextPath:/nacos} spring.sql.init.mode=never \ No newline at end of file diff --git a/sys/src/main/resources/META-INF/nacos-default.properties b/sys/src/main/resources/META-INF/nacos-default.properties index 6e081a98e8..02f4890232 100644 --- a/sys/src/main/resources/META-INF/nacos-default.properties +++ b/sys/src/main/resources/META-INF/nacos-default.properties @@ -20,9 +20,11 @@ nacos.version=${project.version} ## Web Server server.servlet.contextPath=/nacos -server.port=8848 +nacos.server.main.port=8848 server.tomcat.uri-encoding=UTF-8 +nacos.console.port=8080 + ## HTTP Encoding spring.http.encoding.force=true spring.http.encoding.enabled=true