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


##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/NamespacePluginController.java:
##########
@@ -0,0 +1,232 @@
+/*
+ * 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 of namespace.
+     *
+     * @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 of namespace.

Review Comment:
   query all plugins of namespace



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/plugin/NamespacePluginChangedEvent.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * 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.event.plugin;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shenyu.admin.model.enums.EventTypeEnum;
+import org.apache.shenyu.admin.model.event.AdminDataModelChangedEvent;
+import org.apache.shenyu.admin.model.vo.NamespacePluginVO;
+
+import java.util.Objects;
+
+/**
+ * AdminDataModelChangedEvent.
+ */
+public class NamespacePluginChangedEvent extends AdminDataModelChangedEvent {
+
+
+    /**
+     * Create a new {@code PluginChangedEvent}.operator is unknown.
+     *
+     * @param source   Current plugin state
+     * @param before   Before the change plugiin state
+     * @param type     event type
+     * @param operator operator
+     */
+    public NamespacePluginChangedEvent(final NamespacePluginVO source, final 
NamespacePluginVO before, final EventTypeEnum type, final String operator) {
+        super(source, before, type, operator);
+    }
+    
+    @Override
+    public String buildContext() {
+        final NamespacePluginVO after = (NamespacePluginVO) getAfter();
+        if (Objects.isNull(getBefore())) {
+            return String.format("the namespace [%s] plugin [%s] is %s", 
after.getNamespaceId(), after.getName(), 
StringUtils.lowerCase(getType().getType().toString()));
+        }
+        return String.format("the namespace [%s] plugin [%s] is %s : %s", 
after.getNamespaceId(), after.getName(), 
StringUtils.lowerCase(getType().getType().toString()), contrast());
+        
+    }
+    
+    private String contrast() {
+        final NamespacePluginVO before = (NamespacePluginVO) getBefore();
+        Objects.requireNonNull(before);
+        final NamespacePluginVO after = (NamespacePluginVO) getAfter();
+        Objects.requireNonNull(after);
+        if (Objects.equals(before, after)) {
+            return "it no change";

Review Comment:
   what means it?



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