From d4edd011e64835ad327bde2aa6d07df28ed7edff Mon Sep 17 00:00:00 2001 From: chenhao26 <35129699+Chaos-coder@users.noreply.github.com> Date: Fri, 8 Apr 2022 10:15:02 +0800 Subject: [PATCH] clean NamespaceController code (#8097) --- .../controller/NamespaceController.java | 29 +++++-------------- 1 file changed, 8 insertions(+), 21 deletions(-) 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 96d4b43fd..9ce7325c9 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 @@ -36,8 +36,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import java.util.ArrayList; import java.util.List; import java.util.UUID; @@ -76,17 +74,15 @@ public class NamespaceController { /** * Get namespace list. * - * @param request request - * @param response response * @return namespace list */ @GetMapping - public RestResult> getNamespaces(HttpServletRequest request, HttpServletResponse response) { + public RestResult> getNamespaces() { // TODO 获取用kp List tenantInfos = persistService.findTenantByKp(DEFAULT_KP); Namespace namespace0 = new Namespace("", DEFAULT_NAMESPACE, DEFAULT_QUOTA, persistService.configInfoCount(DEFAULT_TENANT), NamespaceTypeEnum.GLOBAL.getType()); - List namespaces = new ArrayList(); + List namespaces = new ArrayList<>(); namespaces.add(namespace0); for (TenantInfo tenantInfo : tenantInfos) { int configCount = persistService.configInfoCount(tenantInfo.getTenantId()); @@ -100,14 +96,11 @@ public class NamespaceController { /** * get namespace all info by namespace id. * - * @param request request - * @param response response * @param namespaceId namespaceId * @return namespace all info */ @GetMapping(params = "show=all") - public NamespaceAllInfo getNamespace(HttpServletRequest request, HttpServletResponse response, - @RequestParam("namespaceId") String namespaceId) { + public NamespaceAllInfo getNamespace(@RequestParam("namespaceId") String namespaceId) { // TODO 获取用kp if (StringUtils.isBlank(namespaceId)) { return new NamespaceAllInfo(namespaceId, DEFAULT_NAMESPACE_SHOW_NAME, DEFAULT_QUOTA, @@ -124,16 +117,14 @@ public class NamespaceController { /** * create namespace. * - * @param request request - * @param response response * @param namespaceName namespace Name * @param namespaceDesc namespace Desc * @return whether create ok */ @PostMapping @Secured(resource = AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX + "namespaces", action = ActionTypes.WRITE) - public Boolean createNamespace(HttpServletRequest request, HttpServletResponse response, - @RequestParam("customNamespaceId") String namespaceId, @RequestParam("namespaceName") String namespaceName, + public Boolean createNamespace(@RequestParam("customNamespaceId") String namespaceId, + @RequestParam("namespaceName") String namespaceName, @RequestParam(value = "namespaceDesc", required = false) String namespaceDesc) { // TODO 获取用kp if (StringUtils.isBlank(namespaceId)) { @@ -150,9 +141,8 @@ public class NamespaceController { return false; } } - persistService - .insertTenantInfoAtomic(DEFAULT_KP, namespaceId, namespaceName, namespaceDesc, DEFAULT_CREATE_SOURCE, - System.currentTimeMillis()); + persistService.insertTenantInfoAtomic(DEFAULT_KP, namespaceId, namespaceName, namespaceDesc, + DEFAULT_CREATE_SOURCE, System.currentTimeMillis()); return true; } @@ -191,15 +181,12 @@ public class NamespaceController { /** * del namespace by id. * - * @param request request - * @param response response * @param namespaceId namespace Id * @return whether del ok */ @DeleteMapping @Secured(resource = AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX + "namespaces", action = ActionTypes.WRITE) - public Boolean deleteConfig(HttpServletRequest request, HttpServletResponse response, - @RequestParam("namespaceId") String namespaceId) { + public Boolean deleteConfig(@RequestParam("namespaceId") String namespaceId) { persistService.removeTenantInfoAtomic(DEFAULT_KP, namespaceId); return true; }