diff --git a/src/main/java/ink/wgink/gateway/dao/log/IRequestLogDao.java b/src/main/java/ink/wgink/gateway/dao/log/IRequestLogDao.java index 43d8f7a..7689b94 100644 --- a/src/main/java/ink/wgink/gateway/dao/log/IRequestLogDao.java +++ b/src/main/java/ink/wgink/gateway/dao/log/IRequestLogDao.java @@ -23,7 +23,4 @@ public interface IRequestLogDao extends ReactiveMongoRepository countByStartTimeAndEndTime(String startTime, String endTime); - } diff --git a/src/main/java/ink/wgink/gateway/handler/count/CountHandler.java b/src/main/java/ink/wgink/gateway/handler/count/CountHandler.java index bfa1fdc..7ad0d2c 100644 --- a/src/main/java/ink/wgink/gateway/handler/count/CountHandler.java +++ b/src/main/java/ink/wgink/gateway/handler/count/CountHandler.java @@ -19,6 +19,7 @@ import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.aggregation.Aggregation; import org.springframework.data.mongodb.core.aggregation.AggregationResults; import org.springframework.data.mongodb.core.query.Criteria; +import org.springframework.data.mongodb.core.query.Query; import org.springframework.http.MediaType; import org.springframework.stereotype.Service; import org.springframework.web.reactive.function.server.ServerRequest; @@ -62,31 +63,19 @@ public class CountHandler extends BaseHandler { public Mono countHome(ServerRequest serverResponse) { return ServerResponse.ok().contentType(MediaType.TEXT_EVENT_STREAM).body( Flux.interval(Duration.ofSeconds(0), Duration.ofSeconds(15)) - .flatMap(second -> routeTypeDao.count() - .flatMap(routeTypeCount -> routeDao.count() - .flatMap(routeCount -> requestLogDao.count() - .flatMap(requestCount -> { - RequestLog requestLogExample = new RequestLog(); - requestLogExample.setGmtCreate(DateUtil.getDay()); + .flatMap(second -> { + Long routeTypeCount = mongoTemplate.count(new Query(), IRouteTypeDao.COLLECTION_NAME); + Long routeCount = mongoTemplate.count(new Query(), IRouteDao.COLLECTION_NAME); + Long requestCount = mongoTemplate.count(new Query(), IRequestLogDao.COLLECTION_NAME); + Long requestDayCount = mongoTemplate.count(Query.query(Criteria.where("gmtCreate").regex(DateUtil.getDay() +".*")), IRequestLogDao.COLLECTION_NAME); - ExampleMatcher exampleMatcher = ExampleMatcher.matching() - .withMatcher("gmtCreate", ExampleMatcher.GenericPropertyMatcher::contains) - .withIgnoreCase("id"); - Example example = Example.of(requestLogExample, exampleMatcher); - - return requestLogDao.count(example) - .flatMap(requestTodayCount -> { - HomeCount homeCount = new HomeCount(); - homeCount.setRouteTypeCount(routeTypeCount); - homeCount.setRouteCount(routeCount); - homeCount.setRequestCount(requestCount); - homeCount.setRequestTodayCount((Long) requestTodayCount); - return Mono.just(homeCount); - }); - }) - ) - ) - ), + HomeCount homeCount = new HomeCount(); + homeCount.setRouteTypeCount(routeTypeCount); + homeCount.setRouteCount(routeCount); + homeCount.setRequestCount(requestCount); + homeCount.setRequestTodayCount(requestDayCount); + return Mono.just(homeCount); + }), HomeCount.class); } diff --git a/src/main/resources/static/wg/assets/images/logo.png b/src/main/resources/static/wg/assets/images/logo.png new file mode 100644 index 0000000..cd3d035 Binary files /dev/null and b/src/main/resources/static/wg/assets/images/logo.png differ diff --git a/src/main/resources/static/wg/home.html b/src/main/resources/static/wg/home.html index 749be98..077a531 100644 --- a/src/main/resources/static/wg/home.html +++ b/src/main/resources/static/wg/home.html @@ -145,7 +145,7 @@ }, initRequestLogLineChat: function(data) { var self = this; - if(self.lastRequestLogLineChat) { + if(!data && self.lastRequestLogLineChat) { self.lastRequestLogLineChat.resize(); return; } @@ -158,15 +158,19 @@ seriesData.push(item.count); } var option = { + visualMap: [{ + show: true, + type: 'continuous', + seriesIndex: 0, + min: 0, + max: 1000 + }], title: { text: '最近一小时内接口网关调用次数' }, tooltip: { trigger: 'axis' }, - legend: { - data: legendData - }, grid: { left: '3%', right: '4%', @@ -186,6 +190,10 @@ name: '访问次数', type: 'line', stack: '总量', + smooth: false, + lineStyle: { + width: 3 + }, data: seriesData } ] @@ -195,7 +203,7 @@ self.lastRequestLogLineChat.setOption(option); return; } - self.lastRequestLogLineChat.setOption(option); + self.lastRequestLogLineChat.setOption(option, true); }, sseRequestLogLineChat: function() { var self = this; diff --git a/src/main/resources/static/wg/index.html b/src/main/resources/static/wg/index.html index e921710..b02a464 100644 --- a/src/main/resources/static/wg/index.html +++ b/src/main/resources/static/wg/index.html @@ -10,11 +10,20 @@ +
-
-
    +
    + + +
    -
    +
    首页 -
    +
    @@ -49,6 +62,7 @@ var $ = layui.$; var $win = $(window); var layer = layui.layer; + var homeHref = 'home.html'; window.dialog = layui.dialog; window.restAjax = layui.restajax; window.dataMessage = layui.datamessage; @@ -63,10 +77,15 @@ window.onresize = resize; - $('#defaultIFrame').attr('src', 'home.html'); - - $('.menu-item').on('click', function() { - $('#defaultIFrame').attr('src', this.dataset.href); + $('#defaultIFrame').attr('src', homeHref); + $(document).on('click', '.menu-item', function() { + var href = this.dataset.href; + $('#defaultIFrame').attr('src', href); + if(href === homeHref) { + $('#breadcrumbTitle').empty(); + $('#breadcrumbTitle').append('首页'); + return; + } if($('#subBreadcrumbTitle').length > 0) { $('#subBreadcrumbTitle').empty(); $('#subBreadcrumbTitle').append(''+ this.text +'');