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


##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/PluginNamespaceController.java:
##########
@@ -0,0 +1,239 @@
+/*
+ * 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.PluginMapper;
+import org.apache.shenyu.admin.mapper.PluginNsRelMapper;
+import org.apache.shenyu.admin.model.dto.BatchCommonDTO;
+import org.apache.shenyu.admin.model.dto.BatchNamespaceCommonDTO;
+import org.apache.shenyu.admin.model.dto.PluginNamespaceDTO;
+import org.apache.shenyu.admin.model.page.CommonPager;
+import org.apache.shenyu.admin.model.page.PageParameter;
+import org.apache.shenyu.admin.model.query.PluginNamespaceQuery;
+import org.apache.shenyu.admin.model.query.PluginNamespaceQueryCondition;
+import org.apache.shenyu.admin.model.result.ShenyuAdminResult;
+import org.apache.shenyu.admin.model.vo.PluginNamespaceVO;
+import org.apache.shenyu.admin.service.PageService;
+import org.apache.shenyu.admin.service.PluginNamespaceService;
+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 plugin controller.
+ */
+@RestApi("/pluginNamespace")
+public class PluginNamespaceController implements 
PagedController<PluginNamespaceQueryCondition, PluginNamespaceVO> {
+
+    private final PluginNamespaceService pluginNamespaceService;
+
+    private final SyncDataService syncDataService;
+
+    public PluginNamespaceController(final PluginNamespaceService 
pluginNamespaceService, final SyncDataService syncDataService) {
+        this.pluginNamespaceService = pluginNamespaceService;
+        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<PluginNamespaceVO> commonPager = 
pluginNamespaceService.listByPage(new PluginNamespaceQuery(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 = 
pluginNamespaceService.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 = PluginNsRelMapper.class) final String id) {
+        PluginNamespaceVO pluginNamespaceVO = 
pluginNamespaceService.findById(id, namespaceId);
+        return ShenyuAdminResult.success(ShenyuResultMessage.DETAIL_SUCCESS, 
pluginNamespaceVO);
+    }
+
+//    /**
+//     * create plugin.
+//     *
+//     * @param pluginDTO plugin.
+//     * @return {@linkplain ShenyuAdminResult}
+//     */
+//    @PostMapping("")
+//    @RequiresPermissions("system:plugin:add")

Review Comment:
   ok



-- 
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