Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[type:feat]Rule and MetaData module adapts to namespace transformation #5618

Merged
merged 80 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
cb6e4dd
commit
Jul 21, 2024
dcfca2f
commit
Jul 23, 2024
3538f37
first draft,not verified
Jul 30, 2024
28e6b82
simplify verified
Aug 1, 2024
f8e34d2
simplify verified
Aug 1, 2024
a9c9ee8
Merge branch 'master' into feat_namespace_selector
Aug 1, 2024
819795c
commit
Aug 2, 2024
6c08ca3
commit
Aug 2, 2024
a079729
fix
Aug 2, 2024
4b6320e
fix e2e checkstyle
Aug 2, 2024
7254839
fix e2e
Aug 3, 2024
a70e70b
fix test
Aug 3, 2024
3ea5c2a
fix
Aug 3, 2024
5717cfd
fix
Aug 3, 2024
fc6c199
fix test
Aug 3, 2024
81596fd
fix
Aug 3, 2024
8d5f265
fix
Aug 3, 2024
e1d4d0b
trigger ci
Aug 3, 2024
2c6c556
trigger ci
Aug 3, 2024
3c34e70
fix sql
Aug 3, 2024
b92f2c4
fix sql
Aug 3, 2024
1872673
fix sql
Aug 3, 2024
10043f7
fix
Aug 3, 2024
d897c83
trigger ci
Aug 3, 2024
2e96d3b
trigger ci
Aug 3, 2024
8ede359
fix
Aug 3, 2024
afd48db
trigger ci
Aug 3, 2024
e1643a7
Merge branch 'master' into feat_namespace_selector
xcsnx Aug 5, 2024
a2d9acb
fix
Aug 5, 2024
751517b
Merge remote-tracking branch 'origin/feat_namespace_selector' into fe…
Aug 5, 2024
9020a0d
fix
Aug 5, 2024
9d983d3
fix
Aug 5, 2024
61a174c
Merge branch 'master' into feat_namespace_selector
xcsnx Aug 5, 2024
170e2f9
fix
Aug 5, 2024
42923bb
Merge remote-tracking branch 'origin/feat_namespace_selector' into fe…
Aug 5, 2024
50a9992
trigger ci
Aug 5, 2024
e53fe79
trigger ci
Aug 5, 2024
84794c1
fix
Aug 9, 2024
819ead1
Merge branch 'master' into feat_namespace_selector
xcsnx Aug 9, 2024
5cddb9a
trigger ci
Aug 9, 2024
6d3efda
trigger ci
Aug 9, 2024
0c3760a
trigger ci
Aug 9, 2024
e5400b3
fix cr
Aug 10, 2024
c478cfa
fix cr
Aug 10, 2024
7d28754
commit
Aug 14, 2024
b34cfa7
commit
Aug 15, 2024
fc04662
support e2e
Aug 15, 2024
7650380
commit meta_data
Aug 16, 2024
3774e14
commit
Aug 17, 2024
daad0a9
Merge branch 'master' into feat_namespace_rule
Aug 17, 2024
527b01b
commit
Aug 17, 2024
9bfd03d
commit
Aug 18, 2024
a7f78ad
commit
Aug 18, 2024
952f5b6
commit
Aug 18, 2024
fd8adab
commit
Aug 18, 2024
ee63da5
fix
Aug 18, 2024
afeacf6
fix
Aug 18, 2024
848be3f
fix unit test
Aug 18, 2024
ba96d5c
fix unit test
Aug 19, 2024
23dccc0
fix unit test
Aug 19, 2024
559ca6c
fix unit test
Aug 19, 2024
f28ca27
fix unit test
Aug 19, 2024
d3fb292
fix unit test
Aug 19, 2024
3f2dfde
fix unit test
Aug 19, 2024
9e98a61
trigger ci
Aug 20, 2024
48b6400
Merge branch 'master' into feat_namespace_rule
xcsnx Aug 20, 2024
1a6717b
trigger ci
Aug 21, 2024
bce5c25
Merge remote-tracking branch 'origin/feat_namespace_rule' into feat_n…
Aug 21, 2024
87b4739
Merge branch 'master' into feat_namespace_rule
Aug 21, 2024
a7468d6
merge fix
Aug 21, 2024
367372d
Merge branch 'master' into feat_namespace_rule
xcsnx Aug 22, 2024
22b516b
Merge branch 'master' into feat_namespace_rule
xcsnx Aug 24, 2024
edb78c2
Merge branch 'master' into feat_namespace_rule
VampireAchao Aug 27, 2024
fb24ef0
Merge branch 'master' into feat_namespace_rule
Aias00 Aug 29, 2024
717d5e0
Merge branch 'master' into feat_namespace_rule
xcsnx Aug 31, 2024
e666aec
Merge branch 'master' into feat_namespace_rule
Aias00 Aug 31, 2024
750deda
Merge branch 'master' into feat_namespace_rule
Aias00 Aug 31, 2024
8c4bdf7
support ocean base
Sep 1, 2024
a71baf2
Merge branch 'master' into feat_namespace_rule
xcsnx Sep 1, 2024
054820b
Merge branch 'master' into feat_namespace_rule
moremind Sep 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion db/init/mysql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2371,4 +2371,8 @@ INSERT INTO `shenyu`.`permission` (`id`, `object_id`, `resource_id`, `date_creat
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');

ALTER TABLE `shenyu`.`selector` ADD COLUMN `namespace_id` varchar(50) NULL COMMENT 'namespaceId' AFTER `match_restful`;
ALTER TABLE `shenyu`.`selector` ADD COLUMN `namespace_id` varchar(50) NULL COMMENT 'namespaceId' AFTER `match_restful`;

ALTER TABLE `shenyu`.`rule` ADD COLUMN `namespace_id` varchar(50) NULL COMMENT 'namespaceId' AFTER `match_restful`;

ALTER TABLE `shenyu`.`meta_data` ADD COLUMN `namespace_id` varchar(50) NULL COMMENT 'namespaceId';
6 changes: 5 additions & 1 deletion db/init/ob/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2371,4 +2371,8 @@ INSERT INTO `shenyu`.`permission` (`id`, `object_id`, `resource_id`, `date_creat
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');

ALTER TABLE `shenyu`.`selector` ADD COLUMN `namespace_id` varchar(50) NULL COMMENT 'namespaceId' AFTER `match_restful`;
ALTER TABLE `shenyu`.`selector` ADD COLUMN `namespace_id` varchar(50) NULL COMMENT 'namespaceId' AFTER `match_restful`;

ALTER TABLE `shenyu`.`rule` ADD COLUMN `namespace_id` varchar(50) NULL COMMENT 'namespaceId' AFTER `match_restful`;

ALTER TABLE `shenyu`.`meta_data` ADD COLUMN `namespace_id` varchar(50) NULL COMMENT 'namespaceId';
5 changes: 5 additions & 0 deletions db/init/og/create-table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2677,3 +2677,8 @@ INSERT INTO "public"."permission" VALUES ('1792779493541343267', '13463585604272
ALTER TABLE "public"."selector" ADD COLUMN namespace_id VARCHAR(50) NULL;
COMMENT ON COLUMN "public"."selector"."namespace_id" IS 'namespaceId';

ALTER TABLE "public"."rule" ADD COLUMN namespace_id VARCHAR(50) NULL;
COMMENT ON COLUMN "public"."rule"."namespace_id" IS 'namespaceId';

ALTER TABLE "public"."meta_data" ADD COLUMN namespace_id VARCHAR(50) NULL;
COMMENT ON COLUMN "public"."meta_data"."namespace_id" IS 'namespaceId';
8 changes: 7 additions & 1 deletion db/init/oracle/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2860,4 +2860,10 @@ INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */ INTO permission (id, o


ALTER TABLE selector ADD namespace_id VARCHAR2(50) NULL;
COMMENT ON COLUMN selector.namespace_id IS 'namespaceId';
COMMENT ON COLUMN selector.namespace_id IS 'namespaceId';

ALTER TABLE rule ADD namespace_id VARCHAR2(50) NULL;
COMMENT ON COLUMN rule.namespace_id IS 'namespaceId';

ALTER TABLE meta_data ADD namespace_id VARCHAR2(50) NULL;
COMMENT ON COLUMN meta_data.namespace_id IS 'namespaceId';
8 changes: 7 additions & 1 deletion db/init/pg/create-table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2792,4 +2792,10 @@ INSERT INTO "public"."permission" VALUES ('1792779493541343266', '13463585604272
INSERT INTO "public"."permission" VALUES ('1792779493541343267', '1346358560427216896', '1792749362445840486', '2024-06-25 20:00:00.000', '2024-06-25 20:00:00.000');

ALTER TABLE "public"."selector" ADD COLUMN namespace_id VARCHAR(50) NULL;
COMMENT ON COLUMN "public"."selector"."namespace_id" IS 'namespaceId';
COMMENT ON COLUMN "public"."selector"."namespace_id" IS 'namespaceId';

ALTER TABLE "public"."rule" ADD COLUMN namespace_id VARCHAR(50) NULL;
COMMENT ON COLUMN "public"."rule"."namespace_id" IS 'namespaceId';

ALTER TABLE "public"."meta_data" ADD COLUMN namespace_id VARCHAR(50) NULL;
COMMENT ON COLUMN "public"."meta_data"."namespace_id" IS 'namespaceId';
16 changes: 15 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 @@ -174,4 +174,18 @@ ALTER TABLE `shenyu`.`selector` ADD COLUMN `namespace_id` varchar(50) NULL COMME

UPDATE selector
SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385'
WHERE namespaceId IS NULL;
WHERE namespace_id IS NULL;


ALTER TABLE `shenyu`.`rule` ADD COLUMN `namespace_id` varchar(50) NULL COMMENT 'namespaceId' AFTER `match_restful`;

UPDATE rule
SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385'
WHERE namespace_id IS NULL;

ALTER TABLE `shenyu`.`meta_data` ADD COLUMN `namespace_id` varchar(50) NULL COMMENT 'namespaceId';

UPDATE meta_data
SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385'
WHERE namespace_id IS NULL;

12 changes: 11 additions & 1 deletion db/upgrade/2.6.1-upgrade-2.7.0-og.sql
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,14 @@ COMMENT ON COLUMN "public"."dashboard_user".client_id IS 'client id';
ALTER TABLE "public"."selector" ADD COLUMN namespace_id VARCHAR(50) NULL;
COMMENT ON COLUMN "public"."selector"."namespace_id" IS 'namespaceId';

UPDATE "public"."selector" SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385' WHERE namespace_id IS NULL;
UPDATE "public"."selector" SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385' WHERE namespace_id IS NULL;

ALTER TABLE "public"."rule" ADD COLUMN namespace_id VARCHAR(50) NULL;
COMMENT ON COLUMN "public"."rule"."namespace_id" IS 'namespaceId';

UPDATE "public"."rule" SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385' WHERE namespace_id IS NULL;

ALTER TABLE "public"."meta_data" ADD COLUMN namespace_id VARCHAR(50) NULL;
COMMENT ON COLUMN "public"."meta_data"."namespace_id" IS 'namespaceId';

UPDATE "public"."meta_data" SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385' WHERE namespace_id IS NULL;
12 changes: 11 additions & 1 deletion db/upgrade/2.6.1-upgrade-2.7.0-oracle.sql
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,14 @@ COMMENT ON COLUMN dashboard_user.client_id IS 'client id';
ALTER TABLE selector ADD namespace_id VARCHAR2(50) NULL;
COMMENT ON COLUMN selector.namespace_id IS 'namespaceId';

UPDATE selector SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385' WHERE namespace_id IS NULL;
UPDATE selector SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385' WHERE namespace_id IS NULL;

ALTER TABLE rule ADD namespace_id VARCHAR2(50) NULL;
COMMENT ON COLUMN rule.namespace_id IS 'namespaceId';

UPDATE rule SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385' WHERE namespace_id IS NULL;

ALTER TABLE meta_data ADD namespace_id VARCHAR2(50) NULL;
COMMENT ON COLUMN meta_data.namespace_id IS 'namespaceId';

UPDATE meta_data SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385' WHERE namespace_id IS NULL;
12 changes: 11 additions & 1 deletion db/upgrade/2.6.1-upgrade-2.7.0-pg.sql
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,14 @@ COMMENT ON COLUMN "public"."dashboard_user".client_id IS 'client id';
ALTER TABLE "public"."selector" ADD COLUMN namespace_id VARCHAR(50) NULL;
COMMENT ON COLUMN "public"."selector"."namespace_id" IS 'namespaceId';

UPDATE "public"."selector" SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385' WHERE namespace_id IS NULL;
UPDATE "public"."selector" SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385' WHERE namespace_id IS NULL;

ALTER TABLE "public"."rule" ADD COLUMN namespace_id VARCHAR(50) NULL;
COMMENT ON COLUMN "public"."rule"."namespace_id" IS 'namespaceId';

UPDATE "public"."rule" SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385' WHERE namespace_id IS NULL;

ALTER TABLE "public"."meta_data" ADD COLUMN namespace_id VARCHAR(50) NULL;
COMMENT ON COLUMN "public"."meta_data"."namespace_id" IS 'namespaceId';

UPDATE "public"."meta_data" SET namespace_id = '649330b6-c2d7-4edc-be8e-8a54df9eb385' WHERE namespace_id IS NULL;
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@

package org.apache.shenyu.admin.controller;

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
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.model.dto.BatchCommonDTO;
import org.apache.shenyu.admin.model.dto.BatchNamespaceCommonDTO;
import org.apache.shenyu.admin.model.dto.MetaDataDTO;
import org.apache.shenyu.admin.model.page.CommonPager;
import org.apache.shenyu.admin.model.page.PageParameter;
Expand All @@ -28,6 +32,7 @@
import org.apache.shenyu.admin.model.vo.MetaDataVO;
import org.apache.shenyu.admin.service.MetaDataService;
import org.apache.shenyu.admin.utils.ShenyuResultMessage;
import org.apache.shenyu.admin.validation.annotation.Existed;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.DeleteMapping;
Expand All @@ -37,12 +42,6 @@
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

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

/**
* The type Meta data controller.
*/
Expand All @@ -61,14 +60,17 @@ public MetaDataController(final MetaDataService metaDataService) {
* @param path the path
* @param currentPage the current page
* @param pageSize the page size
* @param namespaceId namespaceId.
* @return the shenyu result
*/
@GetMapping("/queryList")
@RequiresPermissions("system:meta:list")
public ShenyuAdminResult queryList(final String path,
@RequestParam @NotNull(message = "currentPage not null") final Integer currentPage,
@RequestParam @NotNull(message = "pageSize not null") final Integer pageSize) {
CommonPager<MetaDataVO> commonPager = metaDataService.listByPage(new MetaDataQuery(path, new PageParameter(currentPage, pageSize)));
@RequestParam @NotNull(message = "pageSize not null") final Integer pageSize,
@Valid @Existed(message = "namespaceId is not existed",
provider = NamespaceMapper.class) final String namespaceId) {
CommonPager<MetaDataVO> commonPager = metaDataService.listByPage(new MetaDataQuery(path, new PageParameter(currentPage, pageSize), namespaceId));
return ShenyuAdminResult.success(ShenyuResultMessage.QUERY_SUCCESS, commonPager);
}

Expand Down Expand Up @@ -98,12 +100,15 @@ public ShenyuAdminResult findAllGroup() {
* Get detail of metadata.
*
* @param id the id
* @param namespaceId namespaceId.
* @return the shenyu result
*/
@GetMapping("/{id}")
@GetMapping("/{id}/{namespaceId}")
@RequiresPermissions("system:meta:edit")
public ShenyuAdminResult detail(@PathVariable("id") final String id) {
return ShenyuAdminResult.success(ShenyuResultMessage.DETAIL_SUCCESS, metaDataService.findById(id));
public ShenyuAdminResult detail(@PathVariable("id") final String id,
@PathVariable("namespaceId") @Valid
@Existed(provider = NamespaceMapper.class, message = "namespaceId is not existed") final String namespaceId) {
return ShenyuAdminResult.success(ShenyuResultMessage.DETAIL_SUCCESS, metaDataService.findByIdAndNamespaceId(id, namespaceId));
}

/**
Expand All @@ -121,26 +126,14 @@ public ShenyuAdminResult createOrUpdate(@Valid @RequestBody final MetaDataDTO me
/**
* Batch deleted metadata.
*
* @param ids the ids
* @return the shenyu result
*/
@PostMapping("/batchDeleted")
@RequiresPermissions("system:meta:delete")
public ShenyuAdminResult batchDeleted(@RequestBody @NotEmpty final List<@NotBlank String> ids) {
Integer deleteCount = metaDataService.delete(ids);
return ShenyuAdminResult.success(ShenyuResultMessage.DELETE_SUCCESS, deleteCount);
}

/**
* Batch deleted metadata.
*
* @param ids the ids
* @param batchNamespaceCommonDTO batchNamespaceCommonDTO.
* @return the shenyu result
*/
@DeleteMapping("/batchDeleted")
@RequiresPermissions("system:meta:delete")
public ShenyuAdminResult batchDelete(@RequestBody @NotEmpty final List<@NotBlank String> ids) {
return batchDeleted(ids);
public ShenyuAdminResult batchDeleted(@Valid @RequestBody final BatchNamespaceCommonDTO batchNamespaceCommonDTO) {
Integer deleteCount = metaDataService.deleteByIdsAndNamespaceId(batchNamespaceCommonDTO.getIds(), batchNamespaceCommonDTO.getNamespaceId());
return ShenyuAdminResult.success(ShenyuResultMessage.DELETE_SUCCESS, deleteCount);
}

/**
Expand All @@ -152,7 +145,7 @@ public ShenyuAdminResult batchDelete(@RequestBody @NotEmpty final List<@NotBlank
@PostMapping("/batchEnabled")
@RequiresPermissions("system:meta:disable")
public ShenyuAdminResult batchEnabled(@Valid @RequestBody final BatchCommonDTO batchCommonDTO) {
final String result = metaDataService.enabled(batchCommonDTO.getIds(), batchCommonDTO.getEnabled());
final String result = metaDataService.enabledByIdsAndNamespaceId(batchCommonDTO.getIds(), batchCommonDTO.getEnabled(), batchCommonDTO.getNamespaceId());
if (StringUtils.isNoneBlank(result)) {
return ShenyuAdminResult.error(result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@

package org.apache.shenyu.admin.controller;

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import org.apache.shenyu.admin.aspect.annotation.RestApi;
import org.apache.shenyu.admin.mapper.NamespaceMapper;
import org.apache.shenyu.admin.mapper.RuleMapper;
import org.apache.shenyu.admin.model.dto.BatchCommonDTO;
import org.apache.shenyu.admin.model.dto.BatchNamespaceCommonDTO;
import org.apache.shenyu.admin.model.dto.RuleDTO;
import org.apache.shenyu.admin.model.page.CommonPager;
import org.apache.shenyu.admin.model.page.PageCondition;
Expand All @@ -41,12 +45,6 @@
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

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

/**
* this is rule controller.
*/
Expand All @@ -66,30 +64,37 @@ public RuleController(final RuleService ruleService) {
* @param name rule name.
* @param currentPage current page.
* @param pageSize page size.
* @param namespaceId namespaceId.
* @return {@linkplain ShenyuAdminResult}
*/
@GetMapping("")
public AdminResult<CommonPager<RuleVO>> queryRules(final String selectorId, final String name,
@RequestParam @NotNull final Integer currentPage,
@RequestParam @NotNull final Integer pageSize) {
@RequestParam @NotNull final Integer pageSize,
@Valid @Existed(message = "namespaceId is not existed",
provider = NamespaceMapper.class) final String namespaceId) {
final RuleQueryCondition condition = new RuleQueryCondition();
condition.setUserId(SessionUtil.visitor().getUserId());
condition.setSelectors(ListUtil.of(selectorId));
condition.setKeyword(name);
condition.setNamespaceId(namespaceId);
return searchAdaptor(new PageCondition<>(currentPage, pageSize, condition));
}

/**
* detail rule.
*
* @param id rule id.
* @param namespaceId namespaceId.
* @return {@linkplain ShenyuAdminResult}
*/
@GetMapping("/{id}")
@GetMapping("/{id}/{namespaceId}")
public ShenyuAdminResult detailRule(@PathVariable("id") @Valid
@Existed(provider = RuleMapper.class,
message = "rule is not existed") final String id) {
RuleVO ruleVO = ruleService.findById(id);
message = "rule is not existed") final String id,
@PathVariable("namespaceId") @Valid
@Existed(provider = NamespaceMapper.class, message = "namespaceId is not existed") final String namespaceId) {
RuleVO ruleVO = ruleService.findByIdAndNamespaceId(id, namespaceId);
return ShenyuAdminResult.success(ShenyuResultMessage.DETAIL_SUCCESS, ruleVO);
}

Expand Down Expand Up @@ -130,7 +135,7 @@ public ShenyuAdminResult updateRule(@PathVariable("id") @Valid
*/
@PostMapping("/batchEnabled")
public ShenyuAdminResult batchEnabled(@Valid @RequestBody final BatchCommonDTO batchCommonDTO) {
if (!ruleService.enabled(batchCommonDTO.getIds(), batchCommonDTO.getEnabled())) {
if (!ruleService.enabledByIdsAndNamespaceId(batchCommonDTO.getIds(), batchCommonDTO.getEnabled(), batchCommonDTO.getNamespaceId())) {
return ShenyuAdminResult.error(ShenyuResultMessage.NOT_FOUND_EXCEPTION);
}
return ShenyuAdminResult.success(ShenyuResultMessage.ENABLE_SUCCESS);
Expand All @@ -139,12 +144,12 @@ public ShenyuAdminResult batchEnabled(@Valid @RequestBody final BatchCommonDTO b
/**
* delete rules.
*
* @param ids primary key.
* @param batchNamespaceCommonDTO batchNamespaceCommonDTO.
* @return {@linkplain ShenyuAdminResult}
*/
@DeleteMapping("/batch")
public ShenyuAdminResult deleteRules(@RequestBody @NotEmpty final List<@NotBlank String> ids) {
Integer deleteCount = ruleService.delete(ids);
public ShenyuAdminResult deleteRules(@Valid @RequestBody final BatchNamespaceCommonDTO batchNamespaceCommonDTO) {
Integer deleteCount = ruleService.deleteByIdsAndNamespaceId(batchNamespaceCommonDTO.getIds(), batchNamespaceCommonDTO.getNamespaceId());
return ShenyuAdminResult.success(ShenyuResultMessage.DELETE_SUCCESS, deleteCount);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public interface DiscoveryMapper extends ExistProvider {
DiscoveryDO selectById(String id);

/**
* selectAll.
* selectAllByNamespaceId.
*
* @return discoveryDOList
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ public interface DiscoveryUpstreamMapper extends ExistProvider {
Boolean existed(@Param("id") Serializable key);

/**
* selectByIds.
* selectByIdsAndNamespaceId.
*
* @param ids id list
* @return discoveryUpstreamDO list
*/
List<DiscoveryUpstreamDO> selectByIds(@Param("ids") List<String> ids);

/**
* selectAll.
* selectAllByNamespaceId.
*
* @return discoveryUpstreamDO list
*/
Expand Down Expand Up @@ -102,7 +102,7 @@ public interface DiscoveryUpstreamMapper extends ExistProvider {
int updateSelective(DiscoveryUpstreamDO discoveryUpstreamDO);

/**
* deleteByIds.
* deleteByIdsAndNamespaceId.
*
* @param ids id list
* @return rows int
Expand Down
Loading
Loading