moremind commented on code in PR #5584:
URL: https://github.com/apache/shenyu/pull/5584#discussion_r1676770949


##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/NamespacePluginController.java:
##########
@@ -0,0 +1,240 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.controller;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shenyu.admin.aspect.annotation.RestApi;
+import org.apache.shenyu.admin.mapper.NamespaceMapper;
+import org.apache.shenyu.admin.mapper.NamespacePluginRelMapper;
+import org.apache.shenyu.admin.mapper.PluginMapper;
+import org.apache.shenyu.admin.model.dto.BatchCommonDTO;
+import org.apache.shenyu.admin.model.dto.BatchNamespaceCommonDTO;
+import org.apache.shenyu.admin.model.dto.NamespacePluginDTO;
+import org.apache.shenyu.admin.model.page.CommonPager;
+import org.apache.shenyu.admin.model.page.PageParameter;
+import org.apache.shenyu.admin.model.query.NamespacePluginQuery;
+import org.apache.shenyu.admin.model.query.NamespacePluginQueryCondition;
+import org.apache.shenyu.admin.model.result.ShenyuAdminResult;
+import org.apache.shenyu.admin.model.vo.NamespacePluginVO;
+import org.apache.shenyu.admin.service.NamespacePluginService;
+import org.apache.shenyu.admin.service.PageService;
+import org.apache.shenyu.admin.service.SyncDataService;
+import org.apache.shenyu.admin.utils.ShenyuResultMessage;
+import org.apache.shenyu.admin.validation.annotation.Existed;
+import org.apache.shenyu.common.dto.PluginData;
+import org.apache.shenyu.common.enums.DataEventTypeEnum;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
+/**
+ * this is namespace plugin controller.
+ */
+@RestApi("/namespacePlugin")
+public class NamespacePluginController implements 
PagedController<NamespacePluginQueryCondition, NamespacePluginVO> {
+
+    private final NamespacePluginService namespacePluginService;
+
+    private final SyncDataService syncDataService;
+
+    public NamespacePluginController(final NamespacePluginService 
namespacePluginService, final SyncDataService syncDataService) {
+        this.namespacePluginService = namespacePluginService;
+        this.syncDataService = syncDataService;
+    }
+
+    /**
+     * query plugins.

Review Comment:
   modify the comment to query plugins of namespace



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/NamespacePluginController.java:
##########
@@ -0,0 +1,240 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.controller;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shenyu.admin.aspect.annotation.RestApi;
+import org.apache.shenyu.admin.mapper.NamespaceMapper;
+import org.apache.shenyu.admin.mapper.NamespacePluginRelMapper;
+import org.apache.shenyu.admin.mapper.PluginMapper;
+import org.apache.shenyu.admin.model.dto.BatchCommonDTO;
+import org.apache.shenyu.admin.model.dto.BatchNamespaceCommonDTO;
+import org.apache.shenyu.admin.model.dto.NamespacePluginDTO;
+import org.apache.shenyu.admin.model.page.CommonPager;
+import org.apache.shenyu.admin.model.page.PageParameter;
+import org.apache.shenyu.admin.model.query.NamespacePluginQuery;
+import org.apache.shenyu.admin.model.query.NamespacePluginQueryCondition;
+import org.apache.shenyu.admin.model.result.ShenyuAdminResult;
+import org.apache.shenyu.admin.model.vo.NamespacePluginVO;
+import org.apache.shenyu.admin.service.NamespacePluginService;
+import org.apache.shenyu.admin.service.PageService;
+import org.apache.shenyu.admin.service.SyncDataService;
+import org.apache.shenyu.admin.utils.ShenyuResultMessage;
+import org.apache.shenyu.admin.validation.annotation.Existed;
+import org.apache.shenyu.common.dto.PluginData;
+import org.apache.shenyu.common.enums.DataEventTypeEnum;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
+/**
+ * this is namespace plugin controller.
+ */
+@RestApi("/namespacePlugin")
+public class NamespacePluginController implements 
PagedController<NamespacePluginQueryCondition, NamespacePluginVO> {
+
+    private final NamespacePluginService namespacePluginService;
+
+    private final SyncDataService syncDataService;
+
+    public NamespacePluginController(final NamespacePluginService 
namespacePluginService, final SyncDataService syncDataService) {
+        this.namespacePluginService = namespacePluginService;
+        this.syncDataService = syncDataService;
+    }
+
+    /**
+     * query plugins.
+     *
+     * @param name        plugin name.
+     * @param enabled     plugin enabled.
+     * @param namespaceId namespace id.
+     * @param currentPage current page.
+     * @param pageSize    page size.
+     * @return {@linkplain ShenyuAdminResult}
+     */
+    @GetMapping("")
+    public ShenyuAdminResult queryPlugins(final String name, final Integer 
enabled,
+                                          @Existed(message = "namespace is not 
existed",
+                                                  provider = 
NamespaceMapper.class) final String namespaceId,
+                                          @NotNull final Integer currentPage,
+                                          @NotNull final Integer pageSize) {
+        CommonPager<NamespacePluginVO> commonPager = 
namespacePluginService.listByPage(new NamespacePluginQuery(name, enabled, new 
PageParameter(currentPage, pageSize), namespaceId));
+        return ShenyuAdminResult.success(ShenyuResultMessage.QUERY_SUCCESS, 
commonPager);
+    }
+
+    /**
+     * query All plugins.
+     *
+     * @param namespaceId namespace id.
+     * @return {@linkplain ShenyuAdminResult}
+     */
+    @GetMapping("/all/{namespaceId}")
+    public ShenyuAdminResult queryAllPlugins(
+            @PathVariable("namespaceId")
+            @Existed(message = "namespace is not existed", provider = 
NamespaceMapper.class) final String namespaceId) {
+        List<PluginData> pluginDataList = 
namespacePluginService.listAll(namespaceId);
+        return ShenyuAdminResult.success(ShenyuResultMessage.QUERY_SUCCESS, 
pluginDataList);
+    }
+
+    /**
+     * detail plugin.
+     *
+     * @param namespaceId namespace id.
+     * @param id          id.
+     * @return {@linkplain ShenyuAdminResult}
+     */
+    @GetMapping("/id={id}&namespaceId={namespaceId}")
+    @RequiresPermissions("system:plugin:edit")
+    public ShenyuAdminResult detailPlugin(
+            @PathVariable("namespaceId")

Review Comment:
   format the code style



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/BatchNamespaceCommonDTO.java:
##########
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.model.dto;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * The type Batch common dto.
+ */
+public class BatchNamespaceCommonDTO implements Serializable {
+
+    private static final long serialVersionUID = 7154784370528669046L;
+
+    @NotEmpty

Review Comment:
   remove



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/NamespaceDTO.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.model.dto;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * NamespaceVO.
+ */
+public class NamespaceDTO implements Serializable {
+
+    private String id;
+
+    /**
+     * name.
+     */
+    private String namespaceId;

Review Comment:
   add NotEmpty validation



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/PluginDTO.java:
##########
@@ -81,6 +81,11 @@ public class PluginDTO implements Serializable {
      */
     private List<PluginHandleDTO> pluginHandleList;
 
+    /**
+     * namespace id.
+     */

Review Comment:
   add NotEmpty validation



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/utils/ShenyuResultMessage.java:
##########
@@ -86,6 +86,10 @@ public final class ShenyuResultMessage {
     
     public static final String PASSWORD_USED_FOR_LONG_TIME = "If the password 
has not been changed for a long time, "
             + "please use it after changing it to ensure the security of the 
super administrator account";
+
+    public static final String NAMESPACE_ID_NOT_NULL = "namespace is not null";

Review Comment:
   modify namespace id is not null.



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/NamespaceController.java:
##########
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.controller;
+
+import org.apache.shenyu.admin.aspect.annotation.RestApi;
+import org.apache.shenyu.admin.mapper.NamespaceMapper;
+import org.apache.shenyu.admin.model.dto.NamespaceDTO;
+import org.apache.shenyu.admin.model.page.CommonPager;
+import org.apache.shenyu.admin.model.page.PageParameter;
+import org.apache.shenyu.admin.model.query.NamespaceQuery;
+import org.apache.shenyu.admin.model.result.ShenyuAdminResult;
+import org.apache.shenyu.admin.model.vo.NamespaceVO;
+import org.apache.shenyu.admin.service.NamespaceService;
+import org.apache.shenyu.admin.utils.ShenyuResultMessage;
+import org.apache.shenyu.admin.validation.annotation.Existed;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
+@RestApi("/namespace")
+public class NamespaceController {
+
+    private final NamespaceService namespaceService;
+
+    public NamespaceController(final NamespaceService namespaceService) {
+        this.namespaceService = namespaceService;
+    }
+
+    /**
+     * Find namespace page by query.
+     *
+     * @param namespaceId the namespace id
+     * @param name        name
+     * @param currentPage current page of list
+     * @param pageSize    page size of query
+     * @return the shenyu result
+     */
+    @GetMapping("/findPageByQuery")
+    @RequiresPermissions("system:namespace:list")
+    public ShenyuAdminResult findPageByQuery(final String namespaceId, final 
String name,
+                                             @RequestParam @NotNull(message = 
"currentPage not null") final Integer currentPage,
+                                             @RequestParam @NotNull(message = 
"pageSize not null") final Integer pageSize) {
+        NamespaceQuery query = new NamespaceQuery();
+        query.setNamespaceId(namespaceId);
+        query.setName(name);
+        query.setPageParameter(new PageParameter(currentPage, pageSize));
+        CommonPager<NamespaceVO> commonPager = 
namespaceService.listByPage(query);
+        return ShenyuAdminResult.success(ShenyuResultMessage.QUERY_SUCCESS, 
commonPager);
+    }
+
+    /**
+     * Find namespace list.
+     *
+     * @param name name
+     * @return the shenyu result
+     */
+    @GetMapping("/list")
+    @RequiresPermissions("system:namespace:list")
+    public ShenyuAdminResult list(final String name) {
+        return ShenyuAdminResult.success(ShenyuResultMessage.QUERY_SUCCESS, 
namespaceService.list(name));
+    }
+
+
+    /**
+     * Insert or update namespace.
+     *
+     * @param namespaceDTO {@link NamespaceDTO}
+     * @return {@linkplain ShenyuAdminResult}
+     */
+    @PostMapping("/insertOrUpdate")
+    public ShenyuAdminResult createOrUpdate(@Valid @RequestBody final 
NamespaceDTO namespaceDTO) {
+        return ShenyuAdminResult.success(ShenyuResultMessage.SUCCESS, 
namespaceService.createOrUpdate(namespaceDTO));
+    }
+
+    /**
+     * delete by namespaceId.
+     *
+     * @param ids ids
+     * @return {@linkplain ShenyuAdminResult}
+     */
+    @DeleteMapping("/batch")
+    public ShenyuAdminResult delete(@RequestBody @NotEmpty final 
List<@NotBlank String> ids) {

Review Comment:
   remove NotEmpty



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/NamespacePluginController.java:
##########
@@ -0,0 +1,240 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.controller;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shenyu.admin.aspect.annotation.RestApi;
+import org.apache.shenyu.admin.mapper.NamespaceMapper;
+import org.apache.shenyu.admin.mapper.NamespacePluginRelMapper;
+import org.apache.shenyu.admin.mapper.PluginMapper;
+import org.apache.shenyu.admin.model.dto.BatchCommonDTO;
+import org.apache.shenyu.admin.model.dto.BatchNamespaceCommonDTO;
+import org.apache.shenyu.admin.model.dto.NamespacePluginDTO;
+import org.apache.shenyu.admin.model.page.CommonPager;
+import org.apache.shenyu.admin.model.page.PageParameter;
+import org.apache.shenyu.admin.model.query.NamespacePluginQuery;
+import org.apache.shenyu.admin.model.query.NamespacePluginQueryCondition;
+import org.apache.shenyu.admin.model.result.ShenyuAdminResult;
+import org.apache.shenyu.admin.model.vo.NamespacePluginVO;
+import org.apache.shenyu.admin.service.NamespacePluginService;
+import org.apache.shenyu.admin.service.PageService;
+import org.apache.shenyu.admin.service.SyncDataService;
+import org.apache.shenyu.admin.utils.ShenyuResultMessage;
+import org.apache.shenyu.admin.validation.annotation.Existed;
+import org.apache.shenyu.common.dto.PluginData;
+import org.apache.shenyu.common.enums.DataEventTypeEnum;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
+/**
+ * this is namespace plugin controller.
+ */
+@RestApi("/namespacePlugin")
+public class NamespacePluginController implements 
PagedController<NamespacePluginQueryCondition, NamespacePluginVO> {
+
+    private final NamespacePluginService namespacePluginService;
+
+    private final SyncDataService syncDataService;
+
+    public NamespacePluginController(final NamespacePluginService 
namespacePluginService, final SyncDataService syncDataService) {
+        this.namespacePluginService = namespacePluginService;
+        this.syncDataService = syncDataService;
+    }
+
+    /**
+     * query plugins.
+     *
+     * @param name        plugin name.
+     * @param enabled     plugin enabled.
+     * @param namespaceId namespace id.
+     * @param currentPage current page.
+     * @param pageSize    page size.
+     * @return {@linkplain ShenyuAdminResult}
+     */
+    @GetMapping("")
+    public ShenyuAdminResult queryPlugins(final String name, final Integer 
enabled,
+                                          @Existed(message = "namespace is not 
existed",
+                                                  provider = 
NamespaceMapper.class) final String namespaceId,
+                                          @NotNull final Integer currentPage,
+                                          @NotNull final Integer pageSize) {
+        CommonPager<NamespacePluginVO> commonPager = 
namespacePluginService.listByPage(new NamespacePluginQuery(name, enabled, new 
PageParameter(currentPage, pageSize), namespaceId));
+        return ShenyuAdminResult.success(ShenyuResultMessage.QUERY_SUCCESS, 
commonPager);
+    }
+
+    /**
+     * query All plugins.
+     *
+     * @param namespaceId namespace id.
+     * @return {@linkplain ShenyuAdminResult}
+     */
+    @GetMapping("/all/{namespaceId}")
+    public ShenyuAdminResult queryAllPlugins(
+            @PathVariable("namespaceId")
+            @Existed(message = "namespace is not existed", provider = 
NamespaceMapper.class) final String namespaceId) {
+        List<PluginData> pluginDataList = 
namespacePluginService.listAll(namespaceId);
+        return ShenyuAdminResult.success(ShenyuResultMessage.QUERY_SUCCESS, 
pluginDataList);
+    }
+
+    /**
+     * detail plugin.
+     *
+     * @param namespaceId namespace id.
+     * @param id          id.
+     * @return {@linkplain ShenyuAdminResult}
+     */
+    @GetMapping("/id={id}&namespaceId={namespaceId}")
+    @RequiresPermissions("system:plugin:edit")
+    public ShenyuAdminResult detailPlugin(
+            @PathVariable("namespaceId")
+            @Existed(message = "namespace is not existed", provider = 
NamespaceMapper.class) final String namespaceId,
+            @PathVariable("id")
+            @Existed(message = "id is not existed",
+                    provider = NamespacePluginRelMapper.class) final String 
id) {
+        NamespacePluginVO namespacePluginVO = 
namespacePluginService.findById(id, namespaceId);
+        return ShenyuAdminResult.success(ShenyuResultMessage.DETAIL_SUCCESS, 
namespacePluginVO);
+    }
+
+//    /**
+//     * create plugin.
+//     *
+//     * @param pluginDTO plugin.
+//     * @return {@linkplain ShenyuAdminResult}
+//     */
+//    @PostMapping("")
+//    @RequiresPermissions("system:plugin:add")
+//    public ShenyuAdminResult createPlugin(@Valid @ModelAttribute final 
PluginDTO pluginDTO) {
+//        return 
ShenyuAdminResult.success(pluginService.createOrUpdate(pluginDTO));
+//    }
+
+
+    /**
+     * update plugin.
+     *
+     * @param namespaceId        namespace id.
+     * @param pluginId           primary key.
+     * @param namespacePluginDTO plugin namespace.
+     * @return {@linkplain ShenyuAdminResult}
+     */
+    @PutMapping("/pluginId={pluginId}&namespaceId={namespaceId}")
+    @RequiresPermissions("system:plugin:edit")
+    public ShenyuAdminResult updatePlugin(
+            @PathVariable("namespaceId")

Review Comment:
   format code style



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/NamespacePluginController.java:
##########
@@ -0,0 +1,240 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.controller;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shenyu.admin.aspect.annotation.RestApi;
+import org.apache.shenyu.admin.mapper.NamespaceMapper;
+import org.apache.shenyu.admin.mapper.NamespacePluginRelMapper;
+import org.apache.shenyu.admin.mapper.PluginMapper;
+import org.apache.shenyu.admin.model.dto.BatchCommonDTO;
+import org.apache.shenyu.admin.model.dto.BatchNamespaceCommonDTO;
+import org.apache.shenyu.admin.model.dto.NamespacePluginDTO;
+import org.apache.shenyu.admin.model.page.CommonPager;
+import org.apache.shenyu.admin.model.page.PageParameter;
+import org.apache.shenyu.admin.model.query.NamespacePluginQuery;
+import org.apache.shenyu.admin.model.query.NamespacePluginQueryCondition;
+import org.apache.shenyu.admin.model.result.ShenyuAdminResult;
+import org.apache.shenyu.admin.model.vo.NamespacePluginVO;
+import org.apache.shenyu.admin.service.NamespacePluginService;
+import org.apache.shenyu.admin.service.PageService;
+import org.apache.shenyu.admin.service.SyncDataService;
+import org.apache.shenyu.admin.utils.ShenyuResultMessage;
+import org.apache.shenyu.admin.validation.annotation.Existed;
+import org.apache.shenyu.common.dto.PluginData;
+import org.apache.shenyu.common.enums.DataEventTypeEnum;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
+/**
+ * this is namespace plugin controller.
+ */
+@RestApi("/namespacePlugin")
+public class NamespacePluginController implements 
PagedController<NamespacePluginQueryCondition, NamespacePluginVO> {
+
+    private final NamespacePluginService namespacePluginService;
+
+    private final SyncDataService syncDataService;
+
+    public NamespacePluginController(final NamespacePluginService 
namespacePluginService, final SyncDataService syncDataService) {
+        this.namespacePluginService = namespacePluginService;
+        this.syncDataService = syncDataService;
+    }
+
+    /**
+     * query plugins.
+     *
+     * @param name        plugin name.
+     * @param enabled     plugin enabled.
+     * @param namespaceId namespace id.
+     * @param currentPage current page.
+     * @param pageSize    page size.
+     * @return {@linkplain ShenyuAdminResult}
+     */
+    @GetMapping("")
+    public ShenyuAdminResult queryPlugins(final String name, final Integer 
enabled,
+                                          @Existed(message = "namespace is not 
existed",
+                                                  provider = 
NamespaceMapper.class) final String namespaceId,
+                                          @NotNull final Integer currentPage,
+                                          @NotNull final Integer pageSize) {
+        CommonPager<NamespacePluginVO> commonPager = 
namespacePluginService.listByPage(new NamespacePluginQuery(name, enabled, new 
PageParameter(currentPage, pageSize), namespaceId));
+        return ShenyuAdminResult.success(ShenyuResultMessage.QUERY_SUCCESS, 
commonPager);
+    }
+
+    /**
+     * query All plugins.
+     *
+     * @param namespaceId namespace id.
+     * @return {@linkplain ShenyuAdminResult}
+     */
+    @GetMapping("/all/{namespaceId}")
+    public ShenyuAdminResult queryAllPlugins(
+            @PathVariable("namespaceId")

Review Comment:
   format the code



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/NamespaceDTO.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.model.dto;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * NamespaceVO.
+ */
+public class NamespaceDTO implements Serializable {
+
+    private String id;
+
+    /**

Review Comment:
   modify the comment



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/BatchNamespaceCommonDTO.java:
##########
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.model.dto;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * The type Batch common dto.
+ */
+public class BatchNamespaceCommonDTO implements Serializable {
+
+    private static final long serialVersionUID = 7154784370528669046L;
+
+    @NotEmpty
+    @NotNull
+    private List<@NotBlank String> ids;
+
+    private Boolean enabled;
+
+    @NotNull

Review Comment:
   use NotEmpty for String



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/NamespaceDTO.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.model.dto;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * NamespaceVO.
+ */
+public class NamespaceDTO implements Serializable {
+
+    private String id;
+
+    /**
+     * name.
+     */
+    private String namespaceId;
+
+    /**
+     * discovery type.
+     */
+    @NotNull(message = "name not null")
+    private String name;
+
+    /**
+     * handler.

Review Comment:
   modify the comment



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/NamespaceDTO.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.model.dto;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * NamespaceVO.
+ */
+public class NamespaceDTO implements Serializable {
+
+    private String id;
+
+    /**
+     * name.
+     */
+    private String namespaceId;
+
+    /**
+     * discovery type.
+     */
+    @NotNull(message = "name not null")

Review Comment:
   modify the message to namespace name not null.



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/NamespaceDTO.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.model.dto;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * NamespaceVO.
+ */
+public class NamespaceDTO implements Serializable {
+
+    private String id;
+
+    /**
+     * name.
+     */
+    private String namespaceId;
+
+    /**
+     * discovery type.

Review Comment:
   modify the comment



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/NamespacePluginDTO.java:
##########
@@ -0,0 +1,229 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.model.dto;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shenyu.admin.mapper.PluginMapper;
+import org.apache.shenyu.admin.validation.annotation.Existed;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * this is plugin from by web front.
+ */
+public class NamespacePluginDTO implements Serializable {
+
+    /**
+     * primary key.
+     */
+    @Existed(provider = PluginMapper.class, nullOfIgnore = true, message = 
"the plugin is not exited")
+    private String pluginId;
+
+
+    /**
+     * plugin name.
+     */
+    @NotBlank
+    private String name;
+
+    /**
+     * plugin config.
+     */
+    private String config;
+
+
+    /**
+     * plugin sort.
+     */
+    @NotNull
+    @Min(0)
+    private Integer sort;
+
+    /**
+     * whether enabled.
+     */
+    @NotNull
+    private Boolean enabled;
+
+
+    /**
+     * plugin Handle List.
+     */
+    private List<PluginHandleDTO> pluginHandleList;
+
+    /**
+     * namespace id.
+     */

Review Comment:
   add NotEmpty validation



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/transfer/PluginTransfer.java:
##########
@@ -73,4 +74,25 @@ public PluginData mapDataTOVO(final PluginVO pluginVO) {
                         .build())
                 .orElse(null);
     }
+
+    /**
+     * Map to data plugin data.
+     *
+     * @param namespacePluginVO the namespacePlugin vo
+     * @return the plugin data
+     */
+    public PluginData mapToData(final NamespacePluginVO namespacePluginVO) {
+        return Optional.ofNullable(namespacePluginVO)
+                .map(v -> PluginData.builder()

Review Comment:
   not use v, use item or element



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/NamespacePluginVO.java:
##########
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.model.vo;
+
+import org.apache.shiro.codec.Base64;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * this is plugin view to web front.
+ */
+public class NamespacePluginVO extends PluginVO implements Serializable {

Review Comment:
   add serial id



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/model/vo/NamespaceVO.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.model.vo;
+
+import java.io.Serializable;
+
+/**
+ * NamespaceVO.
+ */
+public class NamespaceVO implements Serializable {
+

Review Comment:
   add serial id



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/NamespaceServiceImpl.java:
##########
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.service.impl;
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shenyu.admin.mapper.NamespaceMapper;
+import org.apache.shenyu.admin.mapper.NamespacePluginRelMapper;
+import org.apache.shenyu.admin.model.dto.NamespaceDTO;
+import org.apache.shenyu.admin.model.entity.NamespaceDO;
+import org.apache.shenyu.admin.model.entity.NamespacePluginRelDO;
+import org.apache.shenyu.admin.model.page.CommonPager;
+import org.apache.shenyu.admin.model.page.PageResultUtils;
+import org.apache.shenyu.admin.model.query.NamespaceQuery;
+import org.apache.shenyu.admin.model.vo.NamespaceVO;
+import org.apache.shenyu.admin.service.NamespaceService;
+import org.apache.shenyu.admin.service.PluginService;
+import org.apache.shenyu.admin.transfer.NamespaceTransfer;
+import org.apache.shenyu.admin.utils.ShenyuResultMessage;
+import org.apache.shenyu.common.constant.AdminConstants;
+import org.apache.shenyu.common.dto.PluginData;
+import org.apache.shenyu.common.utils.NamespaceIDUtils;
+import org.apache.shenyu.common.utils.UUIDUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.sql.Timestamp;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+@Service
+public class NamespaceServiceImpl implements NamespaceService {
+
+    private NamespaceMapper namespaceMapper;
+
+    private NamespacePluginRelMapper namespacePluginRelMapper;
+
+    private PluginService pluginService;
+
+    public NamespaceServiceImpl(final NamespaceMapper namespaceMapper,
+                                final NamespacePluginRelMapper 
namespacePluginRelMapper,
+                                final PluginService pluginService) {
+        this.namespaceMapper = namespaceMapper;
+        this.namespacePluginRelMapper = namespacePluginRelMapper;
+        this.pluginService = pluginService;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public NamespaceVO createOrUpdate(final NamespaceDTO namespaceDTO) {
+        return StringUtils.isBlank(namespaceDTO.getId())
+                && StringUtils.isBlank(namespaceDTO.getNamespaceId())
+                ? this.create(namespaceDTO) : this.update(namespaceDTO);
+    }
+
+    @Override
+    public CommonPager<NamespaceVO> listByPage(final NamespaceQuery 
namespaceQuery) {
+        return PageResultUtils.result(namespaceQuery.getPageParameter(), () -> 
namespaceMapper.countByQuery(namespaceQuery), () -> 
namespaceMapper.selectByQuery(namespaceQuery)
+                .stream()
+                .map(NamespaceTransfer.INSTANCE::mapToVo)
+                .collect(Collectors.toList()));
+    }
+
+    @Override
+    public String delete(final List<String> ids) {
+        if (ids.contains(AdminConstants.SYS_DEFAULT_NAMESPACE_ID)) {
+            return AdminConstants.SYS_DEFAULT_NAMESPACE_ID_DELETE;
+        }
+        List<NamespaceDO> namespaceDOS = namespaceMapper.selectByIds(ids);
+        if (CollectionUtils.isEmpty(namespaceDOS)) {
+            return AdminConstants.SYS_NAMESPACE_ID_NOT_EXIST;
+        }
+        namespaceMapper.deleteByIds(ids);
+        return ShenyuResultMessage.DELETE_SUCCESS;
+    }
+
+    @Override
+    public NamespaceVO findById(final String namespaceId) {
+        return 
NamespaceTransfer.INSTANCE.mapToVo(namespaceMapper.selectById(namespaceId));
+    }
+
+    @Override
+    public List<NamespaceVO> list(final String name) {
+        List<NamespaceDO> namespaceDOS = namespaceMapper.selectAll(name);
+        return 
namespaceDOS.stream().map(NamespaceTransfer.INSTANCE::mapToVo).collect(Collectors.toList());
+    }
+
+    private NamespaceVO create(final NamespaceDTO namespaceDTO) {
+        if (namespaceDTO == null) {
+            return null;
+        }
+        Timestamp currentTime = new Timestamp(System.currentTimeMillis());
+        String id = UUIDUtils.getInstance().generateShortUuid();
+        String namespaceId = 
NamespaceIDUtils.getInstance().generateNamespaceID();
+        NamespaceDO namespaceDO = NamespaceDO.builder()
+                .id(id)
+                .namespaceId(namespaceId)
+                .name(namespaceDTO.getName())
+                .description(namespaceDTO.getDescription())
+                .dateCreated(currentTime)
+                .dateUpdated(currentTime)
+                .build();
+        List<PluginData> pluginData = pluginService.listAll();
+        //创建新命名空间下的默认插件组配置

Review Comment:
   remove the comment



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/NamespaceServiceImpl.java:
##########
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.service.impl;
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shenyu.admin.mapper.NamespaceMapper;
+import org.apache.shenyu.admin.mapper.NamespacePluginRelMapper;
+import org.apache.shenyu.admin.model.dto.NamespaceDTO;
+import org.apache.shenyu.admin.model.entity.NamespaceDO;
+import org.apache.shenyu.admin.model.entity.NamespacePluginRelDO;
+import org.apache.shenyu.admin.model.page.CommonPager;
+import org.apache.shenyu.admin.model.page.PageResultUtils;
+import org.apache.shenyu.admin.model.query.NamespaceQuery;
+import org.apache.shenyu.admin.model.vo.NamespaceVO;
+import org.apache.shenyu.admin.service.NamespaceService;
+import org.apache.shenyu.admin.service.PluginService;
+import org.apache.shenyu.admin.transfer.NamespaceTransfer;
+import org.apache.shenyu.admin.utils.ShenyuResultMessage;
+import org.apache.shenyu.common.constant.AdminConstants;
+import org.apache.shenyu.common.dto.PluginData;
+import org.apache.shenyu.common.utils.NamespaceIDUtils;
+import org.apache.shenyu.common.utils.UUIDUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.sql.Timestamp;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+@Service
+public class NamespaceServiceImpl implements NamespaceService {
+
+    private NamespaceMapper namespaceMapper;
+
+    private NamespacePluginRelMapper namespacePluginRelMapper;
+
+    private PluginService pluginService;
+
+    public NamespaceServiceImpl(final NamespaceMapper namespaceMapper,
+                                final NamespacePluginRelMapper 
namespacePluginRelMapper,
+                                final PluginService pluginService) {
+        this.namespaceMapper = namespaceMapper;
+        this.namespacePluginRelMapper = namespacePluginRelMapper;
+        this.pluginService = pluginService;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public NamespaceVO createOrUpdate(final NamespaceDTO namespaceDTO) {
+        return StringUtils.isBlank(namespaceDTO.getId())
+                && StringUtils.isBlank(namespaceDTO.getNamespaceId())
+                ? this.create(namespaceDTO) : this.update(namespaceDTO);
+    }
+
+    @Override
+    public CommonPager<NamespaceVO> listByPage(final NamespaceQuery 
namespaceQuery) {
+        return PageResultUtils.result(namespaceQuery.getPageParameter(), () -> 
namespaceMapper.countByQuery(namespaceQuery), () -> 
namespaceMapper.selectByQuery(namespaceQuery)
+                .stream()
+                .map(NamespaceTransfer.INSTANCE::mapToVo)
+                .collect(Collectors.toList()));
+    }
+
+    @Override
+    public String delete(final List<String> ids) {
+        if (ids.contains(AdminConstants.SYS_DEFAULT_NAMESPACE_ID)) {
+            return AdminConstants.SYS_DEFAULT_NAMESPACE_ID_DELETE;
+        }
+        List<NamespaceDO> namespaceDOS = namespaceMapper.selectByIds(ids);
+        if (CollectionUtils.isEmpty(namespaceDOS)) {
+            return AdminConstants.SYS_NAMESPACE_ID_NOT_EXIST;
+        }
+        namespaceMapper.deleteByIds(ids);
+        return ShenyuResultMessage.DELETE_SUCCESS;
+    }
+
+    @Override
+    public NamespaceVO findById(final String namespaceId) {
+        return 
NamespaceTransfer.INSTANCE.mapToVo(namespaceMapper.selectById(namespaceId));
+    }
+
+    @Override
+    public List<NamespaceVO> list(final String name) {
+        List<NamespaceDO> namespaceDOS = namespaceMapper.selectAll(name);
+        return 
namespaceDOS.stream().map(NamespaceTransfer.INSTANCE::mapToVo).collect(Collectors.toList());
+    }
+
+    private NamespaceVO create(final NamespaceDTO namespaceDTO) {
+        if (namespaceDTO == null) {

Review Comment:
   why?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to