From ae37028c61d78f786214a88ddf79382b66cfc60c Mon Sep 17 00:00:00 2001 From: tanghc Date: Tue, 21 May 2019 18:49:46 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=90=E6=B5=81=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sop-1.8.0.sql | 32 +++++++ .../api/service/param/LimitNewAddParam.java | 5 + .../api/service/param/LimitNewParam.java | 6 +- .../service/param/LimitNewUpdateParam.java | 5 + .../sop/adminserver/entity/ConfigLimit.java | 3 + .../sop-admin-vue/src/views/isv/index.vue | 10 +- .../src/views/service/limit/index2.vue | 36 ++++--- .../manager/DefaultLimitConfigManager.java | 6 +- .../zuul/filter/PreLimitFilter.java | 24 +++-- .../servercommon/annotation/ApiMapping.java | 2 +- .../sop/servercommon/bean/ServiceConfig.java | 4 +- .../AlipayServiceConfiguration.java | 17 +++- .../param/ApiArgumentResolver.java | 66 +++++++++---- .../SopHandlerMethodArgumentResolver.java | 12 +++ .../storyweb/controller/StoryController.java | 32 ++++++- .../java/com/gitee/sop/LimitDemoPostTest.java | 2 +- .../com/gitee/sop/LimitDemoPostTest2.java | 95 +++++++++++++++++++ .../com/gitee/sop/LimitDemoPostTest3.java | 80 ++++++++++++++++ .../com/gitee/sop/LimitDemoPostTest4.java | 80 ++++++++++++++++ .../com/gitee/sop/LimitDemoPostTest5.java | 80 ++++++++++++++++ .../com/gitee/sop/LimitDemoPostTest6.java | 81 ++++++++++++++++ sop.sql | 86 ++++++++++++----- 22 files changed, 689 insertions(+), 75 deletions(-) create mode 100644 sop-1.8.0.sql create mode 100644 sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/param/SopHandlerMethodArgumentResolver.java create mode 100644 sop-test/src/test/java/com/gitee/sop/LimitDemoPostTest2.java create mode 100644 sop-test/src/test/java/com/gitee/sop/LimitDemoPostTest3.java create mode 100644 sop-test/src/test/java/com/gitee/sop/LimitDemoPostTest4.java create mode 100644 sop-test/src/test/java/com/gitee/sop/LimitDemoPostTest5.java create mode 100644 sop-test/src/test/java/com/gitee/sop/LimitDemoPostTest6.java diff --git a/sop-1.8.0.sql b/sop-1.8.0.sql new file mode 100644 index 00000000..820c668f --- /dev/null +++ b/sop-1.8.0.sql @@ -0,0 +1,32 @@ + +DROP TABLE IF EXISTS `config_limit`; + + +CREATE TABLE `config_limit` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `route_id` varchar(128) DEFAULT NULL COMMENT '路由id', + `app_key` varchar(128) DEFAULT NULL, + `limit_ip` varchar(300) DEFAULT NULL COMMENT '限流ip,多个用英文逗号隔开', + `service_id` varchar(64) NOT NULL DEFAULT '' COMMENT '服务id', + `limit_type` tinyint(4) NOT NULL DEFAULT '1' COMMENT '限流策略,1:漏桶策略,2:令牌桶策略', + `exec_count_per_second` int(11) DEFAULT NULL COMMENT '每秒可处理请求数', + `limit_code` varchar(64) DEFAULT NULL COMMENT '返回的错误码', + `limit_msg` varchar(100) DEFAULT NULL COMMENT '返回的错误信息', + `token_bucket_count` int(11) DEFAULT NULL COMMENT '令牌桶容量', + `limit_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '限流开启状态,1:开启,0关闭', + `order_index` int(11) NOT NULL DEFAULT '0' COMMENT '顺序,值小的优先执行', + `remark` varchar(128) DEFAULT NULL COMMENT '备注', + `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 COMMENT='限流配置'; + +INSERT INTO `config_limit` (`id`, `route_id`, `app_key`, `limit_ip`, `service_id`, `limit_type`, `exec_count_per_second`, `limit_code`, `limit_msg`, `token_bucket_count`, `limit_status`, `order_index`, `remark`, `gmt_create`, `gmt_modified`) VALUES + (1,'alipay.story.get1.0','','192.168.1.1,172.2.2.3','story-service',2,5,'','',6,1,3,NULL,'2019-05-17 19:21:35','2019-05-21 09:12:15'), + (2,'alipay.story.get1.0','2019032617262200001','','story-service',1,5,'service-budy','服务器忙',5,1,0,NULL,'2019-05-17 19:39:30','2019-05-21 15:36:52'), + (3,'alipay.story.find1.0','20190331562013861008375808','','story-service',1,3,'service-busy','服务器忙',5,1,1,NULL,'2019-05-17 20:20:32','2019-05-20 17:40:17'), + (4,'alipay.story.get1.2','','','story-service',2,5,'','',3,1,1,NULL,'2019-05-20 16:27:21','2019-05-21 15:53:10'), + (5,'','20190401562373796095328256','','story-service',1,5,'service-busy','服务器忙',5,1,0,'这个appKey调用很频繁,重点照顾','2019-05-21 15:48:08','2019-05-21 18:45:32'), + (6,'','','10.1.30.54','story-service',1,5,'service-busy','服务器忙',5,1,0,'这个ip在攻击我们','2019-05-21 15:55:33','2019-05-21 18:17:29'), + (7,'story.get1.1','','10.1.30.54','story-service',1,5,'service-busy','服务器忙',5,1,0,NULL,'2019-05-21 16:30:48','2019-05-21 16:30:48'), + (8,'','20190513577548661718777857','10.1.30.54','story-service',1,5,'service-busy','服务器忙',5,1,0,NULL,'2019-05-21 17:10:45','2019-05-21 17:10:52'); \ No newline at end of file diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/param/LimitNewAddParam.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/param/LimitNewAddParam.java index 9d9b85ba..0936c270 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/param/LimitNewAddParam.java +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/param/LimitNewAddParam.java @@ -2,6 +2,7 @@ package com.gitee.sop.adminserver.api.service.param; import com.gitee.easyopen.doc.annotation.ApiDocField; import lombok.Data; +import org.hibernate.validator.constraints.Length; import javax.validation.constraints.Min; import javax.validation.constraints.NotBlank; @@ -59,4 +60,8 @@ public class LimitNewAddParam { @NotNull(message = "orderIndex不能为空") @Min(value = 0, message = "orderIndex必须大于等于0") private Integer orderIndex; + + @ApiDocField(description = "备注") + @Length(max = 128, message = "备注不能超过128") + private String remark; } diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/param/LimitNewParam.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/param/LimitNewParam.java index b25636e4..c7bb8079 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/param/LimitNewParam.java +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/param/LimitNewParam.java @@ -3,6 +3,7 @@ package com.gitee.sop.adminserver.api.service.param; import com.gitee.easyopen.doc.annotation.ApiDocField; import com.gitee.fastmybatis.core.query.Operator; import com.gitee.fastmybatis.core.query.annotation.Condition; +import com.gitee.fastmybatis.core.query.param.PageParam; import lombok.Data; import lombok.EqualsAndHashCode; @@ -11,7 +12,10 @@ import lombok.EqualsAndHashCode; */ @Data @EqualsAndHashCode(callSuper = false) -public class LimitNewParam extends ServiceSearchParam { +public class LimitNewParam extends PageParam { + @ApiDocField(description = "服务名serviceId") + private String serviceId; + @ApiDocField(description = "路由id") @Condition(operator = Operator.like) private String routeId; diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/param/LimitNewUpdateParam.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/param/LimitNewUpdateParam.java index efdb628d..d04630e6 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/param/LimitNewUpdateParam.java +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/param/LimitNewUpdateParam.java @@ -2,6 +2,7 @@ package com.gitee.sop.adminserver.api.service.param; import com.gitee.easyopen.doc.annotation.ApiDocField; import lombok.Data; +import org.hibernate.validator.constraints.Length; import javax.validation.constraints.Min; import javax.validation.constraints.NotBlank; @@ -64,4 +65,8 @@ public class LimitNewUpdateParam { @NotNull(message = "orderIndex不能为空") @Min(value = 0, message = "orderIndex必须大于等于0") private Integer orderIndex; + + @ApiDocField(description = "备注") + @Length(max = 128, message = "备注不能超过128") + private String remark; } diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/entity/ConfigLimit.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/entity/ConfigLimit.java index a0d8c7ea..6c66e8af 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/entity/ConfigLimit.java +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/entity/ConfigLimit.java @@ -58,6 +58,9 @@ public class ConfigLimit { /** 顺序,值小的优先执行, 数据库字段:order_index */ private Integer orderIndex; + /** 备注, 数据库字段:remark */ + private String remark; + /** 数据库字段:gmt_create */ private Date gmtCreate; diff --git a/sop-admin/sop-admin-vue/src/views/isv/index.vue b/sop-admin/sop-admin-vue/src/views/isv/index.vue index 2ee651ce..2e719e23 100644 --- a/sop-admin/sop-admin-vue/src/views/isv/index.vue +++ b/sop-admin/sop-admin-vue/src/views/isv/index.vue @@ -94,9 +94,9 @@ + + + +