1.调整首页
2.修改统计逻辑
This commit is contained in:
parent
5aacf09cb2
commit
fcb4463e5f
@ -23,7 +23,4 @@ public interface IRequestLogDao extends ReactiveMongoRepository<RequestLog, Stri
|
||||
|
||||
String COLLECTION_NAME = "log_request";
|
||||
|
||||
@Aggregation("[{$match: {gmtCreate: {$gte: 'startTime', $lte: 'endTime'}}}, {$group: {_id: '$gmtCreate', num_tutorial: {$sum: 1}}}, {$sort: {gmtCreate: -1}}]")
|
||||
List<RequestLog> countByStartTimeAndEndTime(String startTime, String endTime);
|
||||
|
||||
}
|
||||
|
@ -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<ServerResponse> 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);
|
||||
}
|
||||
|
||||
|
BIN
src/main/resources/static/wg/assets/images/logo.png
Normal file
BIN
src/main/resources/static/wg/assets/images/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
@ -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;
|
||||
|
@ -10,11 +10,20 @@
|
||||
<link rel="icon" href="assets/favicon.ico" type="image/x-icon"/>
|
||||
<link rel="stylesheet" href="assets/layui/css/layui.css"/>
|
||||
<link rel="stylesheet" href="assets/layui/css/admin.css"/>
|
||||
<style>
|
||||
.logo {float: left; margin-left: 45px;}
|
||||
.logo img{margin-top: 10px; height: 40px;}
|
||||
.layui-header .layui-nav{background-color: transparent;}
|
||||
.layui-elem-quote {margin-bottom: 0px; background-color: #FFFFFF;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-app">
|
||||
<div class="layui-header">
|
||||
<ul class="layui-nav layui-bg-blue" lay-filter="">
|
||||
<div class="layui-header header header-index layui-bg-cyan">
|
||||
<a class="logo menu-item" href="javascript:void(0);">
|
||||
<img src="assets/images/logo.png" alt="网关">
|
||||
</a>
|
||||
<ul class="layui-nav" style="float: left;">
|
||||
<li class="layui-nav-item">
|
||||
<a href="javascript:void(0);">网关管理</a>
|
||||
<dl class="layui-nav-child">
|
||||
@ -22,8 +31,12 @@
|
||||
<dd><a href="javascript:void(0);" class="menu-item" data-href="route/route/list.html">映射管理</a></dd>
|
||||
</dl>
|
||||
</li>
|
||||
<li class="layui-nav-item" style="float: right;">
|
||||
<a href="javascript:void(0);"><img src="assets/images/user-avatar.png" class="layui-nav-img"></a>
|
||||
</ul>
|
||||
<ul class="layui-nav" style="float: right;">
|
||||
<li class="layui-nav-item">
|
||||
<a href="javascript:void(0);">
|
||||
<img src="assets/images/user-avatar.png" class="layui-nav-img">管理员
|
||||
</a>
|
||||
<dl class="layui-nav-child">
|
||||
<dd><a href="api/sign/out">退出</a></dd>
|
||||
</dl>
|
||||
@ -31,11 +44,11 @@
|
||||
</ul>
|
||||
</div>
|
||||
<div class="iframe-container">
|
||||
<div class="iframe-breadcrumb-box">
|
||||
<blockquote class="layui-elem-quote">
|
||||
<span id="breadcrumbTitle" class="layui-breadcrumb">
|
||||
<a href="javascript:void(0);" class="menu-item" data-href="home.html">首页</a>
|
||||
</span>
|
||||
</div>
|
||||
</blockquote>
|
||||
<div class="iframe-box">
|
||||
<iframe id="defaultIFrame" frameborder="0" border="0" class="layadmin-iframe"></iframe>
|
||||
</div>
|
||||
@ -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('<a href="javascript:void(0);" class="menu-item" data-href="home.html">首页</a>');
|
||||
return;
|
||||
}
|
||||
if($('#subBreadcrumbTitle').length > 0) {
|
||||
$('#subBreadcrumbTitle').empty();
|
||||
$('#subBreadcrumbTitle').append('<cite>'+ this.text +'</cite>');
|
||||
|
Loading…
Reference in New Issue
Block a user