This is an automated email from the ASF dual-hosted git repository. hefengen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push: new 73a7129a97 [type:improve] Add dynamically scale admin page (#5706) 73a7129a97 is described below commit 73a7129a97c3347f293e997d321c07d0853b3ac2 Author: VampireAchao <ac...@apache.org> AuthorDate: Wed Oct 16 20:37:29 2024 +0800 [type:improve] Add dynamically scale admin page (#5706) * [type:improve] Add dynamically scale admin page * [type:fix] fix ci --------- Co-authored-by: aias00 <rok...@163.com> --- db/init/ob/schema.sql | 2 +- db/init/og/create-table.sql | 12 ++++++ db/init/oracle/schema.sql | 12 ++++++ db/init/pg/create-table.sql | 12 ++++++ .../admin/controller/ScaleRlueController.java | 19 ++++++-- .../shenyu/admin/model/dto/ScaleRuleDTO.java | 3 -- .../shenyu/admin/model/entity/ScalePolicyDO.java | 8 ++-- .../shenyu/admin/model/query/ScaleRuleQuery.java | 50 +++++++++++++++++++++- .../main/resources/mappers/scale-policy-sqlmap.xml | 7 ++- .../main/resources/mappers/scale-rule-sqlmap.xml | 13 ++++-- 10 files changed, 117 insertions(+), 21 deletions(-) diff --git a/db/init/ob/schema.sql b/db/init/ob/schema.sql index 4b98bf35d1..6d8926494b 100644 --- a/db/init/ob/schema.sql +++ b/db/init/ob/schema.sql @@ -2380,4 +2380,4 @@ 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 ('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'); \ No newline at end of file +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'); diff --git a/db/init/og/create-table.sql b/db/init/og/create-table.sql index fc98ecc6e2..7f4c756403 100644 --- a/db/init/og/create-table.sql +++ b/db/init/og/create-table.sql @@ -912,6 +912,12 @@ INSERT INTO "public"."permission" VALUES ('1697146375754190848','134635856042721 INSERT INTO "public"."permission" VALUES ('1697146617543233536','1346358560427216896','1697146617513873408', '2023-08-31 15:17:39', '2023-08-31 07:17:39'); INSERT INTO "public"."permission" VALUES ('1697146860569595904','1346358560427216896','1697146860540235776', '2023-08-31 15:18:37', '2023-08-31 07:18:37'); +INSERT INTO "public"."permission" VALUES ('1697141926281381720','1346358560427216896','1844015648095666176', '2023-08-31 06:59:01', '2023-08-31 06:59:01'); +INSERT INTO "public"."permission" VALUES ('1697145808239621836','1346358560427216896','1844025735425183744', '2023-08-31 07:22:07', '2023-08-31 07:22:07'); +INSERT INTO "public"."permission" VALUES ('1697146375754129471','1346358560427216896','1844025850382667776', '2023-08-31 07:14:26', '2023-08-31 07:14:26'); +INSERT INTO "public"."permission" VALUES ('1697146617543248162','1346358560427216896','1844025989214130176', '2023-08-31 07:22:07', '2023-08-31 07:22:07'); +INSERT INTO "public"."permission" VALUES ('1697146860569542740','1346358560427216896','1844026099075534848', '2023-08-31 07:18:37', '2023-08-31 07:18:37'); + -- ---------------------------- -- Table structure for plugin -- ---------------------------- @@ -1843,6 +1849,12 @@ INSERT INTO "public"."resource" VALUES ('1697145808210333696','16971419262477639 INSERT INTO "public"."resource" VALUES ('1697146617513873408','1697141926247763968','SHENYU.BUTTON.SYSTEM.DELETE','','','',2,0,'delete',1,0,'system:alert:delete',1,'2023-08-31 15:17:39.731','2023-08-31 07:22:07.675'); INSERT INTO "public"."resource" VALUES ('1697146860540235776','1697141926247763968','SHENYU.BUTTON.SYSTEM.EDIT','','','',2,0,'edit',1,0,'system:alert:edit',1,'2023-08-31 15:18:37.673','2023-08-31 07:18:37.675'); +INSERT INTO "public"."resource" VALUES ('1844015648095666176', '1346776175553376256', 'SHENYU.MENU.SYSTEM.MANAGMENT.SCALE', '', '/system/scale', '', 1, 4, 'sliders', 0, 0, '', 1, '2024-10-09 22:02:45.317000', '2024-10-10 14:33:43.897017'); +INSERT INTO "public"."resource" VALUES ('1844025735425183744', '1844015648095666176', 'SHENYU.BUTTON.SYSTEM.LIST', '', '', '', 2, 0, 'unordered-list', 1, 0, 'system:scale:list', 1, '2024-10-09 22:42:50.322000', '2024-10-09 22:42:50.325462'); +INSERT INTO "public"."resource" VALUES ('1844025850382667776', '1844015648095666176', 'SHENYU.BUTTON.SYSTEM.ADD', '', '', '', 2, 0, 'plus', 1, 0, 'system:scale:add', 1, '2024-10-09 22:43:17.731000', '2024-10-09 22:43:17.731661'); +INSERT INTO "public"."resource" VALUES ('1844025989214130176', '1844015648095666176', 'SHENYU.BUTTON.SYSTEM.DELETE', '', '', '', 2, 0, 'delete', 1, 0, 'system:scale:delete', 1, '2024-10-09 22:43:50.831000', '2024-10-09 22:43:50.831705'); +INSERT INTO "public"."resource" VALUES ('1844026099075534848', '1844015648095666176', 'SHENYU.BUTTON.SYSTEM.EDIT', '', '', '', 2, 0, 'edit', 1, 0, 'system:scale:edit', 1, '2024-10-09 22:44:17.024000', '2024-10-09 22:44:17.024555'); + -- ---------------------------- -- Table structure for role -- ---------------------------- diff --git a/db/init/oracle/schema.sql b/db/init/oracle/schema.sql index cd305ac06b..9daf4d0a0f 100644 --- a/db/init/oracle/schema.sql +++ b/db/init/oracle/schema.sql @@ -2324,6 +2324,12 @@ INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX("resource" (id)) */ INTO "resource" (id, INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX("resource" (id)) */ INTO "resource" (id, parent_id, title, name, url, component, resource_type, sort, icon, is_leaf, is_route, perms, status) VALUES ('1697146617513873408','1697141926247763968','SHENYU.BUTTON.SYSTEM.DELETE','','','',2,0,'delete',1,0,'system:alert:delete',1); INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX("resource" (id)) */ INTO "resource" (id, parent_id, title, name, url, component, resource_type, sort, icon, is_leaf, is_route, perms, status) VALUES ('1697146860540235776','1697141926247763968','SHENYU.BUTTON.SYSTEM.EDIT','','','',2,0,'edit',1,0,'system:alert:edit',1); +INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX("resource" (id)) */ INTO "resource" (id, parent_id, title, name, url, component, resource_type, sort, icon, is_leaf, is_route, perms, status) VALUES ('1844015648095666176', '1346776175553376256', 'SHENYU.MENU.SYSTEM.MANAGMENT.SCALE', '', '/system/scale', '', 1, 4, 'sliders', 0, 0, '', 1); +INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX("resource" (id)) */ INTO "resource" (id, parent_id, title, name, url, component, resource_type, sort, icon, is_leaf, is_route, perms, status) VALUES ('1844025735425183744', '1844015648095666176', 'SHENYU.BUTTON.SYSTEM.LIST', '', '', '', 2, 0, 'unordered-list', 1, 0, 'system:scale:list', 1); +INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX("resource" (id)) */ INTO "resource" (id, parent_id, title, name, url, component, resource_type, sort, icon, is_leaf, is_route, perms, status) VALUES ('1844025850382667776', '1844015648095666176', 'SHENYU.BUTTON.SYSTEM.ADD', '', '', '', 2, 0, 'plus', 1, 0, 'system:scale:add', 1); +INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX("resource" (id)) */ INTO "resource" (id, parent_id, title, name, url, component, resource_type, sort, icon, is_leaf, is_route, perms, status) VALUES ('1844025989214130176', '1844015648095666176', 'SHENYU.BUTTON.SYSTEM.DELETE', '', '', '', 2, 0, 'delete', 1, 0, 'system:scale:delete', 1); +INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX("resource" (id)) */ INTO "resource" (id, parent_id, title, name, url, component, resource_type, sort, icon, is_leaf, is_route, perms, status) VALUES ('1844026099075534848', '1844015648095666176', 'SHENYU.BUTTON.SYSTEM.EDIT', '', '', '', 2, 0, 'edit', 1, 0, 'system:scale:edit', 1); + /* default permission */ INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */ INTO permission (id, object_id, resource_id) VALUES ('1351007708572688384', '1346358560427216896', '1346775491550474240'); @@ -2394,6 +2400,12 @@ INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */ INTO permission (id, o INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */ INTO permission (id, object_id, resource_id) VALUES ('1697146617543233536', '1346358560427216896', '1697146617513873408'); INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */ INTO permission (id, object_id, resource_id) VALUES ('1697146860569595904', '1346358560427216896', '1697146860540235776'); +INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */ INTO permission (id, object_id, resource_id) VALUES ('1697141926281381720', '1346358560427216896', '1844015648095666176'); +INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */ INTO permission (id, object_id, resource_id) VALUES ('1697145808239621836', '1346358560427216896', '1844025735425183744'); +INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */ INTO permission (id, object_id, resource_id) VALUES ('1697146375754129471', '1346358560427216896', '1844025850382667776'); +INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */ INTO permission (id, object_id, resource_id) VALUES ('1697146617543248162', '1346358560427216896', '1844025989214130176'); +INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX (permission(id)) */ INTO permission (id, object_id, resource_id) VALUES ('1697146860569542740', '1346358560427216896', '1844026099075534848'); + create table tag ( id VARCHAR2(128) not null, diff --git a/db/init/pg/create-table.sql b/db/init/pg/create-table.sql index fc1dc341ec..e289adce14 100644 --- a/db/init/pg/create-table.sql +++ b/db/init/pg/create-table.sql @@ -912,6 +912,12 @@ INSERT INTO "public"."permission" VALUES ('1697146375754190848', '13463585604272 INSERT INTO "public"."permission" VALUES ('1697146617543233536', '1346358560427216896', '1697146617513873408', '2023-08-31 15:17:39', '2023-08-31 07:17:39'); INSERT INTO "public"."permission" VALUES ('1697146860569595904', '1346358560427216896', '1697146860540235776', '2023-08-31 15:18:37', '2023-08-31 07:18:37'); +INSERT INTO "public"."permission" VALUES ('1697141926281381720', '1346358560427216896', '1844015648095666176', '2023-08-31 06:59:01', '2023-08-31 06:59:01'); +INSERT INTO "public"."permission" VALUES ('1697145808239621836', '1346358560427216896', '1844025735425183744', '2023-08-31 07:22:07', '2023-08-31 07:22:07'); +INSERT INTO "public"."permission" VALUES ('1697146375754129471', '1346358560427216896', '1844025850382667776', '2023-08-31 07:14:26', '2023-08-31 07:14:26'); +INSERT INTO "public"."permission" VALUES ('1697146617543248162', '1346358560427216896', '1844025989214130176', '2023-08-31 07:22:07', '2023-08-31 07:22:07'); +INSERT INTO "public"."permission" VALUES ('1697146860569542740', '1346358560427216896', '1844026099075534848', '2023-08-31 07:18:37', '2023-08-31 07:18:37'); + INSERT INTO "public"."permission" VALUES ('1792793304205819904', '1346358560427216896','1792749362361954340', '2022-05-25 18:02:58', '2022-05-25 18:02:58'); INSERT INTO "public"."permission" VALUES ('1792793304205819905', '1346358560427216896','1792749362445840411', '2022-05-25 18:02:58', '2022-05-25 18:02:58'); INSERT INTO "public"."permission" VALUES ('1792793304205819906', '1346358560427216896','1792749362445840412', '2022-05-25 18:02:58', '2022-05-25 18:02:58'); @@ -1903,6 +1909,12 @@ INSERT INTO "public"."resource" VALUES ('1697145808210333696','16971419262477639 INSERT INTO "public"."resource" VALUES ('1697146617513873408','1697141926247763968','SHENYU.BUTTON.SYSTEM.DELETE','','','',2,0,'delete',1,0,'system:alert:delete',1,'2023-08-31 15:17:39','2023-08-31 07:22:07'); INSERT INTO "public"."resource" VALUES ('1697146860540235776','1697141926247763968','SHENYU.BUTTON.SYSTEM.EDIT','','','',2,0,'edit',1,0,'system:alert:edit',1,'2023-08-31 15:18:37','2023-08-31 07:18:37'); +INSERT INTO "public"."resource" VALUES ('1844015648095666176', '1346776175553376256', 'SHENYU.MENU.SYSTEM.MANAGMENT.SCALE', '', '/system/scale', '', 1, 4, 'sliders', 0, 0, '', 1, '2024-10-09 22:02:45.317000', '2024-10-10 14:33:43.897017'); +INSERT INTO "public"."resource" VALUES ('1844025735425183744', '1844015648095666176', 'SHENYU.BUTTON.SYSTEM.LIST', '', '', '', 2, 0, 'unordered-list', 1, 0, 'system:scale:list', 1, '2024-10-09 22:42:50.322000', '2024-10-09 22:42:50.325462'); +INSERT INTO "public"."resource" VALUES ('1844025850382667776', '1844015648095666176', 'SHENYU.BUTTON.SYSTEM.ADD', '', '', '', 2, 0, 'plus', 1, 0, 'system:scale:add', 1, '2024-10-09 22:43:17.731000', '2024-10-09 22:43:17.731661'); +INSERT INTO "public"."resource" VALUES ('1844025989214130176', '1844015648095666176', 'SHENYU.BUTTON.SYSTEM.DELETE', '', '', '', 2, 0, 'delete', 1, 0, 'system:scale:delete', 1, '2024-10-09 22:43:50.831000', '2024-10-09 22:43:50.831705'); +INSERT INTO "public"."resource" VALUES ('1844026099075534848', '1844015648095666176', 'SHENYU.BUTTON.SYSTEM.EDIT', '', '', '', 2, 0, 'edit', 1, 0, 'system:scale:edit', 1, '2024-10-09 22:44:17.024000', '2024-10-09 22:44:17.024555'); + INSERT INTO "public"."resource" VALUES ('1792749362361954340', '1346775491550474240', 'casdoor', 'casdoor', '/plug/casdoor', 'casdoor', 1, 0, 'safety', 0, 0, '', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); INSERT INTO "public"."resource" VALUES ('1792749362445840411', '1792749362361954340', 'SHENYU.BUTTON.PLUGIN.SELECTOR.ADD', '', '', '', 2, 0, '', 1, 0, 'plugin:casdoorSelector:add', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); INSERT INTO "public"."resource" VALUES ('1792749362445840412', '1792749362361954340', 'SHENYU.BUTTON.PLUGIN.SELECTOR.QUERY', '', '', '', 2, 0, '', 1, 0, 'plugin:casdoorSelector:query', 1, '2022-05-25 18:02:58', '2022-05-25 18:02:58'); diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ScaleRlueController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ScaleRlueController.java index 338585508a..6ff48a840d 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ScaleRlueController.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/ScaleRlueController.java @@ -22,6 +22,7 @@ import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; import org.apache.shenyu.admin.aspect.annotation.RestApi; +import org.apache.shenyu.admin.exception.ShenyuAdminException; import org.apache.shenyu.admin.mapper.ScaleRuleMapper; import org.apache.shenyu.admin.model.dto.ScaleRuleDTO; import org.apache.shenyu.admin.model.page.CommonPager; @@ -32,13 +33,13 @@ import org.apache.shenyu.admin.model.vo.ScaleRuleVO; import org.apache.shenyu.admin.service.ScaleRuleService; import org.apache.shenyu.admin.utils.ShenyuResultMessage; import org.apache.shenyu.admin.validation.annotation.Existed; +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.RequestParam; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.RequestParam; import java.util.List; import java.util.Optional; @@ -51,8 +52,11 @@ public class ScaleRlueController { private final ScaleRuleService scaleRuleService; - public ScaleRlueController(final ScaleRuleService scaleRuleService) { + private final ScaleRuleMapper scaleRuleMapper; + + public ScaleRlueController(final ScaleRuleService scaleRuleService, final ScaleRuleMapper scaleRuleMapper) { this.scaleRuleService = scaleRuleService; + this.scaleRuleMapper = scaleRuleMapper; } /** @@ -69,16 +73,20 @@ public class ScaleRlueController { * query scale rule. * * @param metricName metricName + * @param type type + * @param status status * @param currentPage currentPage * @param pageSize pageSize * @return org.apache.shenyu.admin.model.result.ShenyuAdminResult */ @GetMapping public ShenyuAdminResult queryRule(final String metricName, + final Integer type, + final Integer status, @RequestParam @NotNull final Integer currentPage, @RequestParam @NotNull final Integer pageSize) { CommonPager<ScaleRuleVO> commonPager = - scaleRuleService.listByPage(new ScaleRuleQuery(metricName, new PageParameter(currentPage, pageSize))); + scaleRuleService.listByPage(new ScaleRuleQuery(metricName, type, status, new PageParameter(currentPage, pageSize))); return ShenyuAdminResult.success(ShenyuResultMessage.QUERY_SUCCESS, commonPager); } @@ -118,6 +126,9 @@ public class ScaleRlueController { */ @PutMapping public ShenyuAdminResult updateRule(@Valid @RequestBody final ScaleRuleDTO scaleRuleDTO) { + if (!scaleRuleMapper.existed(scaleRuleDTO.getId())) { + throw new ShenyuAdminException("scale rule is not existed"); + } return ShenyuAdminResult.success(ShenyuResultMessage.UPDATE_SUCCESS, scaleRuleService.createOrUpdate(scaleRuleDTO)); } diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/ScaleRuleDTO.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/ScaleRuleDTO.java index 27a48d6b61..6360d50192 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/ScaleRuleDTO.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/dto/ScaleRuleDTO.java @@ -19,8 +19,6 @@ package org.apache.shenyu.admin.model.dto; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; -import org.apache.shenyu.admin.mapper.ScaleRuleMapper; -import org.apache.shenyu.admin.validation.annotation.Existed; import java.io.Serializable; import java.util.Objects; @@ -35,7 +33,6 @@ public class ScaleRuleDTO implements Serializable { /** * primary key id. */ - @Existed(provider = ScaleRuleMapper.class, nullOfIgnore = true, message = "scale rule is not existed") private String id; /** diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/ScalePolicyDO.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/ScalePolicyDO.java index 5ddfdbf6cb..2e6d02b21b 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/ScalePolicyDO.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/ScalePolicyDO.java @@ -236,10 +236,10 @@ public final class ScalePolicyDO extends BaseDO { .sort(item.getSort()) .status(item.getStatus()) .num(item.getNum()) - .beginTime(DateUtils.isValidDate(DateUtils.localDateTimeToString(item.getBeginTime())) - ? new SimpleDateFormat("yyyy-MM-dd").parse(DateUtils.localDateTimeToString(item.getBeginTime())) : null) - .endTime(DateUtils.isValidDate(DateUtils.localDateTimeToString(item.getEndTime())) - ? new SimpleDateFormat("yyyy-MM-dd").parse(DateUtils.localDateTimeToString(item.getEndTime())) : null) + .beginTime(item.getBeginTime() != null && DateUtils.isValidDate(DateUtils.localDateTimeToString(item.getBeginTime())) + ? new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(DateUtils.localDateTimeToString(item.getBeginTime())) : null) + .endTime(item.getEndTime() != null && DateUtils.isValidDate(DateUtils.localDateTimeToString(item.getEndTime())) + ? new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(DateUtils.localDateTimeToString(item.getEndTime())) : null) .dateUpdated(currentTime) .build(); if (StringUtils.isEmpty(item.getId())) { diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/query/ScaleRuleQuery.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/query/ScaleRuleQuery.java index b15e5d04a0..5ba935599b 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/query/ScaleRuleQuery.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/query/ScaleRuleQuery.java @@ -34,6 +34,16 @@ public class ScaleRuleQuery implements Serializable { */ private String metricName; + /** + * type 0:shenyu 1:k8s 2:others. + */ + private Integer type; + + /** + * status 1:enable 0:disable. + */ + private Integer status; + /** * page parameter. */ @@ -42,9 +52,11 @@ public class ScaleRuleQuery implements Serializable { public ScaleRuleQuery() { } - public ScaleRuleQuery(final String metricName, final PageParameter pageParameter) { + public ScaleRuleQuery(final String metricName, final Integer type, final Integer status, final PageParameter pageParameter) { this.metricName = metricName; this.pageParameter = pageParameter; + this.type = type; + this.status = status; } /** @@ -65,6 +77,42 @@ public class ScaleRuleQuery implements Serializable { this.metricName = metricName; } + /** + * Gets the value of type. + * + * @return the value of type + */ + public Integer getType() { + return type; + } + + /** + * Sets the type. + * + * @param type type + */ + public void setType(final Integer type) { + this.type = type; + } + + /** + * Gets the value of status. + * + * @return the value of status + */ + public Integer getStatus() { + return status; + } + + /** + * Sets the status. + * + * @param status status + */ + public void setStatus(final Integer status) { + this.status = status; + } + /** * Gets the value of pageParameter. * diff --git a/shenyu-admin/src/main/resources/mappers/scale-policy-sqlmap.xml b/shenyu-admin/src/main/resources/mappers/scale-policy-sqlmap.xml index 6ef188059c..78013f86eb 100644 --- a/shenyu-admin/src/main/resources/mappers/scale-policy-sqlmap.xml +++ b/shenyu-admin/src/main/resources/mappers/scale-policy-sqlmap.xml @@ -49,10 +49,10 @@ </delete> <insert id="insert" parameterType="org.apache.shenyu.admin.model.entity.ScalePolicyDO"> insert into scale_policy (id, sort, `status`, num, - begin_time, end_time, date_created, + begin_time, end_time, date_created, date_updated) values (#{id,jdbcType=VARCHAR}, #{sort,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, #{num,jdbcType=INTEGER}, - #{beginTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, #{dateCreated,jdbcType=TIMESTAMP}, + #{beginTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, #{dateCreated,jdbcType=TIMESTAMP}, #{dateUpdated,jdbcType=TIMESTAMP}) </insert> <insert id="insertSelective" parameterType="org.apache.shenyu.admin.model.entity.ScalePolicyDO"> @@ -140,7 +140,6 @@ num = #{num,jdbcType=INTEGER}, begin_time = #{beginTime,jdbcType=TIMESTAMP}, end_time = #{endTime,jdbcType=TIMESTAMP}, - date_created = #{dateCreated,jdbcType=TIMESTAMP}, date_updated = #{dateUpdated,jdbcType=TIMESTAMP} where id = #{id,jdbcType=VARCHAR} </update> @@ -149,4 +148,4 @@ <include refid="Base_Column_List"/> FROM scale_policy </select> -</mapper> \ No newline at end of file +</mapper> diff --git a/shenyu-admin/src/main/resources/mappers/scale-rule-sqlmap.xml b/shenyu-admin/src/main/resources/mappers/scale-rule-sqlmap.xml index 9937a5b85f..5123b367f8 100644 --- a/shenyu-admin/src/main/resources/mappers/scale-rule-sqlmap.xml +++ b/shenyu-admin/src/main/resources/mappers/scale-rule-sqlmap.xml @@ -70,6 +70,12 @@ <bind name="nameLike" value="('%' + metricName + '%')"/> and metric_name like #{nameLike, jdbcType=VARCHAR} </if> + <if test="type != null"> + and type = #{type, jdbcType=INTEGER} + </if> + <if test="status != null"> + and status = #{status, jdbcType=INTEGER} + </if> </where> order by sort, date_created </select> @@ -85,10 +91,10 @@ </delete> <insert id="insert" parameterType="org.apache.shenyu.admin.model.entity.ScaleRuleDO"> insert into scale_rule (id, metric_name, `type`, sort, - `status`, minimum, maximum, + `status`, minimum, maximum, date_created, date_updated) values (#{id,jdbcType=VARCHAR}, #{metricName,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{sort,jdbcType=INTEGER}, - #{status,jdbcType=INTEGER}, #{minimum,jdbcType=VARCHAR}, #{maximum,jdbcType=VARCHAR}, + #{status,jdbcType=INTEGER}, #{minimum,jdbcType=VARCHAR}, #{maximum,jdbcType=VARCHAR}, #{dateCreated,jdbcType=TIMESTAMP}, #{dateUpdated,jdbcType=TIMESTAMP}) </insert> <insert id="insertSelective" parameterType="org.apache.shenyu.admin.model.entity.ScaleRuleDO"> @@ -192,7 +198,6 @@ `status` = #{status,jdbcType=INTEGER}, minimum = #{minimum,jdbcType=VARCHAR}, maximum = #{maximum,jdbcType=VARCHAR}, - date_created = #{dateCreated,jdbcType=TIMESTAMP}, date_updated = #{dateUpdated,jdbcType=TIMESTAMP} where id = #{id,jdbcType=VARCHAR} </update> @@ -214,4 +219,4 @@ #{id, jdbcType=VARCHAR} </foreach> </delete> -</mapper> \ No newline at end of file +</mapper>