Skip to content

Commit

Permalink
Joint commissioning
Browse files Browse the repository at this point in the history
  • Loading branch information
‘xcsnx’ committed Jun 30, 2024
1 parent 33b99de commit 1525206
Show file tree
Hide file tree
Showing 19 changed files with 313 additions and 78 deletions.
27 changes: 26 additions & 1 deletion db/upgrade/2.6.1-upgrade-2.7.0-mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,29 @@ INSERT INTO `shenyu`.`plugin_ns_rel` (`id`,`namespace_id`,`plugin_id`, `config`,
INSERT INTO `shenyu`.`plugin_ns_rel` (`id`,`namespace_id`,`plugin_id`, `config`, `sort`, `enabled`, `date_created`, `date_updated`) VALUES ('1801816010882822183','649330b6c2d74edcbe8e8a54df9eb385','5', '{\"multiSelectorHandle\":\"1\",\"multiRuleHandle\":\"0\"}', 200, 1, '2022-05-25 18:02:53.000', '2022-05-25 18:02:53.000');
INSERT INTO `shenyu`.`plugin_ns_rel` (`id`,`namespace_id`,`plugin_id`, `config`, `sort`, `enabled`, `date_created`, `date_updated`) VALUES ('1801816010882822184','649330b6c2d74edcbe8e8a54df9eb385','6', '{\"register\":\"zookeeper://localhost:2181\",\"multiSelectorHandle\":\"1\",\"threadpool\":\"shared\",\"corethreads\":0,\"threads\":2147483647,\"queues\":0}', 310, 0, '2022-05-25 18:02:53.000', '2022-05-25 18:02:53.000');
INSERT INTO `shenyu`.`plugin_ns_rel` (`id`,`namespace_id`,`plugin_id`, `config`, `sort`, `enabled`, `date_created`, `date_updated`) VALUES ('1801816010882822185','649330b6c2d74edcbe8e8a54df9eb385','8', NULL, 200, 0, '2022-05-25 18:02:53.000', '2022-05-25 18:02:53.000');
INSERT INTO `shenyu`.`plugin_ns_rel` (`id`,`namespace_id`,`plugin_id`, `config`, `sort`, `enabled`, `date_created`, `date_updated`) VALUES ('1801816010882822186','649330b6c2d74edcbe8e8a54df9eb385','9', NULL, 130, 0, '2022-05-25 18:02:53.000', '2022-05-25 18:02:53.000');
INSERT INTO `shenyu`.`plugin_ns_rel` (`id`,`namespace_id`,`plugin_id`, `config`, `sort`, `enabled`, `date_created`, `date_updated`) VALUES ('1801816010882822186','649330b6c2d74edcbe8e8a54df9eb385','9', NULL, 130, 0, '2022-05-25 18:02:53.000', '2022-05-25 18:02:53.000');



INSERT INTO `shenyu`.`resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`)
VALUES ('1792749362445840479', '1357956838021890048', 'SHENYU.MENU.SYSTEM.MANAGMENT.PLUGINNAMESPACE', 'pluginNamespace', '/config/pluginNamespace', 'pluginNamespace', 1, 2, 'build', 0, 0, '', 1, '2024-06-25 18:02:53.000', '2024-06-25 18:02:53.000');


INSERT INTO `shenyu`.`resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`)VALUES ('1792749362445840479', '1357956838021890048', 'SHENYU.MENU.SYSTEM.MANAGMENT.PLUGINNAMESPACE', 'pluginNamespace', '/config/pluginNamespace', 'pluginNamespace', 1, 2, 'build', 0, 0, '', 1, '2024-06-25 18:02:53.000', '2024-06-25 18:02:53.000');
INSERT INTO `shenyu`.`resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1792749362445840480', '1792749362445840479', 'SHENYU.BUTTON.SYSTEM.LIST', '', '', '', 2, 0, '', 1, 0, 'system:pluginNamespace:list', 1, '2024-06-25 18:02:53.000', '2024-06-25 18:02:53.000');
INSERT INTO `shenyu`.`resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1792749362445840481', '1792749362445840479', 'SHENYU.BUTTON.SYSTEM.DELETE', '', '', '', 2, 1, '', 1, 0, 'system:pluginNamespace:delete', 1, '2024-06-25 18:02:53.000', '2024-06-25 18:02:53.000');
INSERT INTO `shenyu`.`resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1792749362445840482', '1792749362445840479', 'SHENYU.BUTTON.SYSTEM.ADD', '', '', '', 2, 2, '', 1, 0, 'system:pluginNamespace:add', 1, '2024-06-25 18:02:53.000', '2024-06-25 18:02:53.000');
INSERT INTO `shenyu`.`resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1792749362445840483', '1792749362445840479', 'SHENYU.BUTTON.SYSTEM.SYNCHRONIZE', '', '', '', 2, 3, '', 1, 0, 'system:pluginNamespace:modify', 1, '2024-06-25 18:02:53.000', '2024-06-25 18:02:53.000');
INSERT INTO `shenyu`.`resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1792749362445840484', '1792749362445840479', 'SHENYU.BUTTON.SYSTEM.ENABLE', '', '', '', 2, 4, '', 1, 0, 'system:pluginNamespace:disable', 1, '2024-06-25 18:02:53.000', '2024-06-25 18:02:53.000');
INSERT INTO `shenyu`.`resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1792749362445840485', '1792749362445840479', 'SHENYU.BUTTON.SYSTEM.EDIT', '', '', '', 2, 5, '', 1, 0, 'system:pluginNamespace:edit', 1,'2024-06-25 18:02:53.000', '2024-06-25 18:02:53.000');
INSERT INTO `shenyu`.`resource` (`id`, `parent_id`, `title`, `name`, `url`, `component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`, `status`, `date_created`, `date_updated`) VALUES ('1792749362445840486', '1792749362445840479', 'SHENYU.BUTTON.SYSTEM.RESOURCE', '', '', '', 2, 6, '', 1, 0, 'system:pluginNamespace:resource', 1,'2024-06-25 18:02:53.000', '2024-06-25 18:02:53.000');


INSERT INTO `shenyu`.`permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1792779493541343260', '1346358560427216896', '1792749362445840479', '2024-06-25 20:00:00.000', '2024-06-25 20:00:00.000');
INSERT INTO `shenyu`.`permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1792779493541343261', '1346358560427216896', '1792749362445840480', '2024-06-25 20:00:00.000', '2024-06-25 20:00:00.000');
INSERT INTO `shenyu`.`permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1792779493541343262', '1346358560427216896', '1792749362445840481', '2024-06-25 20:00:00.000', '2024-06-25 20:00:00.000');
INSERT INTO `shenyu`.`permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1792779493541343263', '1346358560427216896', '1792749362445840482', '2024-06-25 20:00:00.000', '2024-06-25 20:00:00.000');
INSERT INTO `shenyu`.`permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1792779493541343264', '1346358560427216896', '1792749362445840483', '2024-06-25 20:00:00.000', '2024-06-25 20:00:00.000');
INSERT INTO `shenyu`.`permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1792779493541343265', '1346358560427216896', '1792749362445840484', '2024-06-25 20:00:00.000', '2024-06-25 20:00:00.000');
INSERT INTO `shenyu`.`permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1792779493541343266', '1346358560427216896', '1792749362445840485', '2024-06-25 20:00:00.000', '2024-06-25 20:00:00.000');
INSERT INTO `shenyu`.`permission` (`id`, `object_id`, `resource_id`, `date_created`, `date_updated`) VALUES ('1792779493541343267', '1346358560427216896', '1792749362445840486', '2024-06-25 20:00:00.000', '2024-06-25 20:00:00.000');
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import org.apache.shenyu.admin.model.dto.PluginDTO;
import org.apache.shenyu.admin.model.page.CommonPager;
import org.apache.shenyu.admin.model.page.PageParameter;
import org.apache.shenyu.admin.model.query.PluginNamespaceQueryCondition;
import org.apache.shenyu.admin.model.query.PluginQuery;
import org.apache.shenyu.admin.model.query.PluginQueryCondition;
import org.apache.shenyu.admin.model.result.ShenyuAdminResult;
import org.apache.shenyu.admin.model.vo.PluginVO;
import org.apache.shenyu.admin.service.PageService;
Expand Down Expand Up @@ -53,8 +53,8 @@
* this is plugin controller.
*/
@RestApi("/plugin")
public class PluginController implements PagedController<PluginNamespaceQueryCondition, PluginVO> {
public class PluginController implements PagedController<PluginQueryCondition, PluginVO> {

private final PluginService pluginService;

private final SyncDataService syncDataService;
Expand Down Expand Up @@ -197,7 +197,7 @@ public ShenyuAdminResult activePluginSnapshot() {
}

@Override
public PageService<PluginNamespaceQueryCondition, PluginVO> pageService() {
public PageService<PluginQueryCondition, PluginVO> pageService() {
return pluginService;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
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;
Expand All @@ -46,8 +48,6 @@
import org.springframework.web.bind.annotation.RequestBody;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

Expand Down Expand Up @@ -76,9 +76,8 @@ public PluginNamespaceController(final PluginNamespaceService pluginNamespaceSer
* @param pageSize page size.
* @return {@linkplain ShenyuAdminResult}
*/
@GetMapping("/{namespaceId}")
@GetMapping("")
public ShenyuAdminResult queryPlugins(final String name, final Integer enabled,
@PathVariable("namespaceId")
@Existed(message = "namespace is not existed",
provider = NamespaceMapper.class) final String namespaceId,
@NotNull final Integer currentPage,
Expand All @@ -103,19 +102,20 @@ public ShenyuAdminResult queryAllPlugins(

/**
* detail plugin.
*
* @param namespaceId namespace id.
* @param pluginId plugin id.
* @param id id.
* @return {@linkplain ShenyuAdminResult}
*/
@GetMapping("/pluginId={pluginId}&namespaceId={namespaceId}")
@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("pluginId")
@Existed(message = "plugin is not existed",
provider = PluginMapper.class) final String pluginId) {
PluginNamespaceVO pluginNamespaceVO = pluginNamespaceService.findById(pluginId, 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);
}

Expand All @@ -135,7 +135,7 @@ public ShenyuAdminResult detailPlugin(
/**
* update plugin.
*
* @param namespaceId namespace id.
* @param namespaceId namespace id.
* @param pluginId primary key.
* @param pluginNamespaceDTO plugin namespace.
* @return {@linkplain ShenyuAdminResult}
Expand All @@ -158,15 +158,13 @@ public ShenyuAdminResult updatePlugin(
/**
* delete plugins.
*
* @param pluginIds primary key.
* @param namespaceId namespace id.
* @param batchNamespaceCommonDTO the batch namespace common dto
* @return {@linkplain ShenyuAdminResult}
*/
@DeleteMapping("/batch")
@RequiresPermissions("system:plugin:delete")
public ShenyuAdminResult deletePlugins(@RequestBody @NotEmpty final List<@NotBlank String> pluginIds,
@NotBlank final String namespaceId) {
final String result = pluginNamespaceService.delete(pluginIds, namespaceId);
public ShenyuAdminResult deletePlugins(@Valid @RequestBody final BatchNamespaceCommonDTO batchNamespaceCommonDTO) {
final String result = pluginNamespaceService.delete(batchNamespaceCommonDTO.getIds(), batchNamespaceCommonDTO.getNamespaceId());
if (StringUtils.isNoneBlank(result)) {
return ShenyuAdminResult.error(result);
}
Expand All @@ -182,6 +180,9 @@ public ShenyuAdminResult deletePlugins(@RequestBody @NotEmpty final List<@NotBla
@PostMapping("/enabled")
@RequiresPermissions("system:plugin:disable")
public ShenyuAdminResult enabled(@Valid @RequestBody final BatchCommonDTO batchCommonDTO) {
if (batchCommonDTO.getEnabled() == null) {
return ShenyuAdminResult.error(ShenyuResultMessage.ENABLED_NOT_NULL);
}
final String result = pluginNamespaceService.enabled(batchCommonDTO.getIds(), batchCommonDTO.getEnabled(), batchCommonDTO.getNamespaceId());
if (StringUtils.isNoneBlank(result)) {
return ShenyuAdminResult.error(result);
Expand Down Expand Up @@ -209,7 +210,7 @@ public ShenyuAdminResult syncPluginAll() {
* Sync plugin data.
*
* @param namespaceId namespace id.
* @param id the id
* @param id the id
* @return the mono
*/
@PutMapping("/syncPluginData/id={id}&namespaceId={namespaceId}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.apache.ibatis.annotations.Param;
import org.apache.shenyu.admin.model.entity.PluginDO;
import org.apache.shenyu.admin.model.query.PluginQuery;
import org.apache.shenyu.admin.model.query.PluginNamespaceQueryCondition;
import org.apache.shenyu.admin.model.query.PluginQueryCondition;
import org.apache.shenyu.admin.model.vo.PluginSnapshotVO;
import org.apache.shenyu.admin.model.vo.PluginVO;
import org.apache.shenyu.admin.validation.ExistProvider;
Expand Down Expand Up @@ -211,5 +211,5 @@ public interface PluginMapper extends ExistProvider {
* @param condition condition.
* @return list
*/
List<PluginVO> searchByCondition(@Param("condition") PluginNamespaceQueryCondition condition);
List<PluginVO> searchByCondition(@Param("condition") PluginQueryCondition condition);
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ public interface PluginNsRelMapper extends ExistProvider {
/**
* select plugin by pluginId.
*
* @param pluginId primary key.
* @param id primary key.
* @param namespaceId namespace id.
* @return {@linkplain PluginVO}
*/
PluginNamespaceVO selectById(String pluginId, String namespaceId);
PluginNamespaceVO selectById(String id, String namespaceId);

/**
* search by condition.
Expand Down Expand Up @@ -101,11 +101,11 @@ public interface PluginNsRelMapper extends ExistProvider {
/**
* select plugin by id.
*
* @param pluginIds primary keys.
* @param ids primary keys.
* @param namespaceId namespace id.
* @return {@linkplain PluginNsRelDO}
*/
List<PluginNamespaceVO> selectByIds(List<String> pluginIds, String namespaceId);
List<PluginNamespaceVO> selectByIds(List<String> ids, String namespaceId);


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public class BatchCommonDTO implements Serializable {
@NotNull
private Boolean enabled;

@NotNull
private String namespaceId;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -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
private String namespaceId;

/**
* Gets the value of ids.
*
* @return the value of ids
*/
public List<String> getIds() {
return ids;
}

/**
* Sets the ids.
*
* @param ids ids
*/
public void setIds(final List<String> ids) {
this.ids = ids;
}

/**
* Gets the value of enabled.
*
* @return the value of enabled
*/
public Boolean getEnabled() {
return enabled;
}

/**
* Sets the enabled.
*
* @param enabled enabled
*/
public void setEnabled(final Boolean enabled) {
this.enabled = enabled;
}

/**
* Gets the value of namespaceId.
*
* @return the value of namespaceId
*/
public String getNamespaceId() {
return namespaceId;
}

/**
* Sets the namespaceId.
*
* @param namespaceId namespaceId
*/
public void setNamespaceId(final String namespaceId) {
this.namespaceId = namespaceId;
}

@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
BatchNamespaceCommonDTO that = (BatchNamespaceCommonDTO) o;
return Objects.equals(ids, that.ids) && Objects.equals(enabled, that.enabled) && Objects.equals(namespaceId, that.namespaceId);
}

@Override
public int hashCode() {
return Objects.hash(ids, enabled, namespaceId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ public static PluginNsRelDO buildPluginNsRelDO(final PluginNamespaceDTO pluginNa
.config(item.getConfig())
.enabled(item.getEnabled())
.sort(item.getSort())
.namespaceId(item.getNamespaceId())
.pluginId(item.getPluginId())
.dateUpdated(currentTime)
.build();
return pluginNsRelDO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package org.apache.shenyu.admin.model.event.plugin;

import org.apache.commons.lang3.StringUtils;
import org.apache.shenyu.admin.model.entity.PluginDO;
import org.apache.shenyu.admin.model.enums.EventTypeEnum;
import org.apache.shenyu.admin.model.event.AdminDataModelChangedEvent;
import org.apache.shenyu.admin.model.vo.PluginNamespaceVO;
Expand Down Expand Up @@ -54,9 +53,9 @@ public String buildContext() {
}

private String contrast() {
final PluginDO before = (PluginDO) getBefore();
final PluginNamespaceVO before = (PluginNamespaceVO) getBefore();
Objects.requireNonNull(before);
final PluginDO after = (PluginDO) getAfter();
final PluginNamespaceVO after = (PluginNamespaceVO) getAfter();
Objects.requireNonNull(after);
if (Objects.equals(before, after)) {
return "it no change";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public class PluginNamespaceQuery implements Serializable {
*/
private String namespaceId;

public PluginNamespaceQuery() {
}

public PluginNamespaceQuery(final String name, final Integer enabled, final PageParameter pageParameter, final String namespaceId) {
this.name = name;
this.enabled = enabled;
Expand Down
Loading

0 comments on commit 1525206

Please sign in to comment.