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";
|
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.Aggregation;
|
||||||
import org.springframework.data.mongodb.core.aggregation.AggregationResults;
|
import org.springframework.data.mongodb.core.aggregation.AggregationResults;
|
||||||
import org.springframework.data.mongodb.core.query.Criteria;
|
import org.springframework.data.mongodb.core.query.Criteria;
|
||||||
|
import org.springframework.data.mongodb.core.query.Query;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.reactive.function.server.ServerRequest;
|
import org.springframework.web.reactive.function.server.ServerRequest;
|
||||||
@ -62,31 +63,19 @@ public class CountHandler extends BaseHandler {
|
|||||||
public Mono<ServerResponse> countHome(ServerRequest serverResponse) {
|
public Mono<ServerResponse> countHome(ServerRequest serverResponse) {
|
||||||
return ServerResponse.ok().contentType(MediaType.TEXT_EVENT_STREAM).body(
|
return ServerResponse.ok().contentType(MediaType.TEXT_EVENT_STREAM).body(
|
||||||
Flux.interval(Duration.ofSeconds(0), Duration.ofSeconds(15))
|
Flux.interval(Duration.ofSeconds(0), Duration.ofSeconds(15))
|
||||||
.flatMap(second -> routeTypeDao.count()
|
.flatMap(second -> {
|
||||||
.flatMap(routeTypeCount -> routeDao.count()
|
Long routeTypeCount = mongoTemplate.count(new Query(), IRouteTypeDao.COLLECTION_NAME);
|
||||||
.flatMap(routeCount -> requestLogDao.count()
|
Long routeCount = mongoTemplate.count(new Query(), IRouteDao.COLLECTION_NAME);
|
||||||
.flatMap(requestCount -> {
|
Long requestCount = mongoTemplate.count(new Query(), IRequestLogDao.COLLECTION_NAME);
|
||||||
RequestLog requestLogExample = new RequestLog();
|
Long requestDayCount = mongoTemplate.count(Query.query(Criteria.where("gmtCreate").regex(DateUtil.getDay() +".*")), IRequestLogDao.COLLECTION_NAME);
|
||||||
requestLogExample.setGmtCreate(DateUtil.getDay());
|
|
||||||
|
|
||||||
ExampleMatcher exampleMatcher = ExampleMatcher.matching()
|
HomeCount homeCount = new HomeCount();
|
||||||
.withMatcher("gmtCreate", ExampleMatcher.GenericPropertyMatcher::contains)
|
homeCount.setRouteTypeCount(routeTypeCount);
|
||||||
.withIgnoreCase("id");
|
homeCount.setRouteCount(routeCount);
|
||||||
Example example = Example.of(requestLogExample, exampleMatcher);
|
homeCount.setRequestCount(requestCount);
|
||||||
|
homeCount.setRequestTodayCount(requestDayCount);
|
||||||
return requestLogDao.count(example)
|
return Mono.just(homeCount);
|
||||||
.flatMap(requestTodayCount -> {
|
}),
|
||||||
HomeCount homeCount = new HomeCount();
|
|
||||||
homeCount.setRouteTypeCount(routeTypeCount);
|
|
||||||
homeCount.setRouteCount(routeCount);
|
|
||||||
homeCount.setRequestCount(requestCount);
|
|
||||||
homeCount.setRequestTodayCount((Long) requestTodayCount);
|
|
||||||
return Mono.just(homeCount);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
HomeCount.class);
|
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) {
|
initRequestLogLineChat: function(data) {
|
||||||
var self = this;
|
var self = this;
|
||||||
if(self.lastRequestLogLineChat) {
|
if(!data && self.lastRequestLogLineChat) {
|
||||||
self.lastRequestLogLineChat.resize();
|
self.lastRequestLogLineChat.resize();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -158,15 +158,19 @@
|
|||||||
seriesData.push(item.count);
|
seriesData.push(item.count);
|
||||||
}
|
}
|
||||||
var option = {
|
var option = {
|
||||||
|
visualMap: [{
|
||||||
|
show: true,
|
||||||
|
type: 'continuous',
|
||||||
|
seriesIndex: 0,
|
||||||
|
min: 0,
|
||||||
|
max: 1000
|
||||||
|
}],
|
||||||
title: {
|
title: {
|
||||||
text: '最近一小时内接口网关调用次数'
|
text: '最近一小时内接口网关调用次数'
|
||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
trigger: 'axis'
|
trigger: 'axis'
|
||||||
},
|
},
|
||||||
legend: {
|
|
||||||
data: legendData
|
|
||||||
},
|
|
||||||
grid: {
|
grid: {
|
||||||
left: '3%',
|
left: '3%',
|
||||||
right: '4%',
|
right: '4%',
|
||||||
@ -186,6 +190,10 @@
|
|||||||
name: '访问次数',
|
name: '访问次数',
|
||||||
type: 'line',
|
type: 'line',
|
||||||
stack: '总量',
|
stack: '总量',
|
||||||
|
smooth: false,
|
||||||
|
lineStyle: {
|
||||||
|
width: 3
|
||||||
|
},
|
||||||
data: seriesData
|
data: seriesData
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -195,7 +203,7 @@
|
|||||||
self.lastRequestLogLineChat.setOption(option);
|
self.lastRequestLogLineChat.setOption(option);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.lastRequestLogLineChat.setOption(option);
|
self.lastRequestLogLineChat.setOption(option, true);
|
||||||
},
|
},
|
||||||
sseRequestLogLineChat: function() {
|
sseRequestLogLineChat: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -10,11 +10,20 @@
|
|||||||
<link rel="icon" href="assets/favicon.ico" type="image/x-icon"/>
|
<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/layui.css"/>
|
||||||
<link rel="stylesheet" href="assets/layui/css/admin.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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="layui-app">
|
<div class="layui-app">
|
||||||
<div class="layui-header">
|
<div class="layui-header header header-index layui-bg-cyan">
|
||||||
<ul class="layui-nav layui-bg-blue" lay-filter="">
|
<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">
|
<li class="layui-nav-item">
|
||||||
<a href="javascript:void(0);">网关管理</a>
|
<a href="javascript:void(0);">网关管理</a>
|
||||||
<dl class="layui-nav-child">
|
<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>
|
<dd><a href="javascript:void(0);" class="menu-item" data-href="route/route/list.html">映射管理</a></dd>
|
||||||
</dl>
|
</dl>
|
||||||
</li>
|
</li>
|
||||||
<li class="layui-nav-item" style="float: right;">
|
</ul>
|
||||||
<a href="javascript:void(0);"><img src="assets/images/user-avatar.png" class="layui-nav-img"></a>
|
<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">
|
<dl class="layui-nav-child">
|
||||||
<dd><a href="api/sign/out">退出</a></dd>
|
<dd><a href="api/sign/out">退出</a></dd>
|
||||||
</dl>
|
</dl>
|
||||||
@ -31,11 +44,11 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="iframe-container">
|
<div class="iframe-container">
|
||||||
<div class="iframe-breadcrumb-box">
|
<blockquote class="layui-elem-quote">
|
||||||
<span id="breadcrumbTitle" class="layui-breadcrumb">
|
<span id="breadcrumbTitle" class="layui-breadcrumb">
|
||||||
<a href="javascript:void(0);" class="menu-item" data-href="home.html">首页</a>
|
<a href="javascript:void(0);" class="menu-item" data-href="home.html">首页</a>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</blockquote>
|
||||||
<div class="iframe-box">
|
<div class="iframe-box">
|
||||||
<iframe id="defaultIFrame" frameborder="0" border="0" class="layadmin-iframe"></iframe>
|
<iframe id="defaultIFrame" frameborder="0" border="0" class="layadmin-iframe"></iframe>
|
||||||
</div>
|
</div>
|
||||||
@ -49,6 +62,7 @@
|
|||||||
var $ = layui.$;
|
var $ = layui.$;
|
||||||
var $win = $(window);
|
var $win = $(window);
|
||||||
var layer = layui.layer;
|
var layer = layui.layer;
|
||||||
|
var homeHref = 'home.html';
|
||||||
window.dialog = layui.dialog;
|
window.dialog = layui.dialog;
|
||||||
window.restAjax = layui.restajax;
|
window.restAjax = layui.restajax;
|
||||||
window.dataMessage = layui.datamessage;
|
window.dataMessage = layui.datamessage;
|
||||||
@ -63,10 +77,15 @@
|
|||||||
|
|
||||||
window.onresize = resize;
|
window.onresize = resize;
|
||||||
|
|
||||||
$('#defaultIFrame').attr('src', 'home.html');
|
$('#defaultIFrame').attr('src', homeHref);
|
||||||
|
$(document).on('click', '.menu-item', function() {
|
||||||
$('.menu-item').on('click', function() {
|
var href = this.dataset.href;
|
||||||
$('#defaultIFrame').attr('src', 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) {
|
if($('#subBreadcrumbTitle').length > 0) {
|
||||||
$('#subBreadcrumbTitle').empty();
|
$('#subBreadcrumbTitle').empty();
|
||||||
$('#subBreadcrumbTitle').append('<cite>'+ this.text +'</cite>');
|
$('#subBreadcrumbTitle').append('<cite>'+ this.text +'</cite>');
|
||||||
|
Loading…
Reference in New Issue
Block a user