mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-10-26 06:57:08 +08:00
feat: 完善仪表盘访客地域分布区块内容
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package top.charles7c.cnadmin.monitor.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseMapper;
|
||||
import top.charles7c.cnadmin.monitor.model.entity.LogDO;
|
||||
@@ -44,4 +45,11 @@ public interface LogMapper extends BaseMapper<LogDO> {
|
||||
* @return 仪表盘热门模块列表
|
||||
*/
|
||||
List<DashboardPopularModuleVO> selectListDashboardPopularModule();
|
||||
|
||||
/**
|
||||
* 查询仪表盘访客地域分布信息
|
||||
*
|
||||
* @return 仪表盘访客地域分布信息
|
||||
*/
|
||||
List<Map<String, Object>> selectListDashboardGeoDistribution();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.cnadmin.monitor.model.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
/**
|
||||
* 仪表盘-访客地域分布信息
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2023/9/9 12:07
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "仪表盘-访客地域分布信息")
|
||||
public class DashboardGeoDistributionVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 地点列表
|
||||
*/
|
||||
@Schema(description = "地点列表", example = "[\"中国北京北京市\",\"中国广东省深圳市\"]")
|
||||
private List<String> locations;
|
||||
|
||||
/**
|
||||
* 地点 IP 统计信息
|
||||
*/
|
||||
@Schema(description = "地点 IP 统计信息",
|
||||
example = "[{\"name\":\"中国北京北京市\",\"value\":1000},{\"name\":\"中国广东省深圳市\",\"value\": 500}]")
|
||||
private List<Map<String, Object>> locationIpStatistics;
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
* @since 2023/9/9 9:52
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "仪表盘-热门模块信息")
|
||||
public class DashboardPopularModuleVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
* @since 2023/9/8 21:32
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "仪表盘-总计信息")
|
||||
public class DashboardTotalVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -18,6 +18,7 @@ package top.charles7c.cnadmin.monitor.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import top.charles7c.cnadmin.monitor.model.vo.DashboardGeoDistributionVO;
|
||||
import top.charles7c.cnadmin.monitor.model.vo.DashboardPopularModuleVO;
|
||||
import top.charles7c.cnadmin.monitor.model.vo.DashboardTotalVO;
|
||||
import top.charles7c.cnadmin.system.model.vo.DashboardAnnouncementVO;
|
||||
@@ -44,6 +45,13 @@ public interface DashboardService {
|
||||
*/
|
||||
List<DashboardPopularModuleVO> listPopularModule();
|
||||
|
||||
/**
|
||||
* 查询访客地域分布信息
|
||||
*
|
||||
* @return 访客地域分布信息
|
||||
*/
|
||||
DashboardGeoDistributionVO getGeoDistribution();
|
||||
|
||||
/**
|
||||
* 查询公告列表
|
||||
*
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package top.charles7c.cnadmin.monitor.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import top.charles7c.cnadmin.common.model.query.PageQuery;
|
||||
import top.charles7c.cnadmin.common.model.vo.PageDataVO;
|
||||
@@ -87,5 +88,12 @@ public interface LogService {
|
||||
*
|
||||
* @return 仪表盘热门模块列表
|
||||
*/
|
||||
List<DashboardPopularModuleVO> listPopularModule();
|
||||
List<DashboardPopularModuleVO> listDashboardPopularModule();
|
||||
|
||||
/**
|
||||
* 查询仪表盘访客地域分布信息
|
||||
*
|
||||
* @return 仪表盘访客地域分布信息
|
||||
*/
|
||||
List<Map<String, Object>> listDashboardGeoDistribution();
|
||||
}
|
||||
|
||||
@@ -18,14 +18,18 @@ package top.charles7c.cnadmin.monitor.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
|
||||
import top.charles7c.cnadmin.monitor.model.vo.DashboardGeoDistributionVO;
|
||||
import top.charles7c.cnadmin.monitor.model.vo.DashboardPopularModuleVO;
|
||||
import top.charles7c.cnadmin.monitor.model.vo.DashboardTotalVO;
|
||||
import top.charles7c.cnadmin.monitor.service.DashboardService;
|
||||
@@ -61,7 +65,7 @@ public class DashboardServiceImpl implements DashboardService {
|
||||
|
||||
@Override
|
||||
public List<DashboardPopularModuleVO> listPopularModule() {
|
||||
List<DashboardPopularModuleVO> popularModuleList = logService.listPopularModule();
|
||||
List<DashboardPopularModuleVO> popularModuleList = logService.listDashboardPopularModule();
|
||||
for (DashboardPopularModuleVO popularModule : popularModuleList) {
|
||||
Long todayPvCount = popularModule.getTodayPvCount();
|
||||
Long yesterdayPvCount = popularModule.getYesterdayPvCount();
|
||||
@@ -73,6 +77,16 @@ public class DashboardServiceImpl implements DashboardService {
|
||||
return popularModuleList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DashboardGeoDistributionVO getGeoDistribution() {
|
||||
List<Map<String, Object>> locationIpStatistics = logService.listDashboardGeoDistribution();
|
||||
DashboardGeoDistributionVO geoDistribution = new DashboardGeoDistributionVO();
|
||||
geoDistribution.setLocationIpStatistics(locationIpStatistics);
|
||||
geoDistribution.setLocations(
|
||||
locationIpStatistics.stream().map(m -> Convert.toStr(m.get("name"))).collect(Collectors.toList()));
|
||||
return geoDistribution;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DashboardAnnouncementVO> listAnnouncement() {
|
||||
return announcementService.listDashboard();
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package top.charles7c.cnadmin.monitor.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -151,10 +152,15 @@ public class LogServiceImpl implements LogService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DashboardPopularModuleVO> listPopularModule() {
|
||||
public List<DashboardPopularModuleVO> listDashboardPopularModule() {
|
||||
return logMapper.selectListDashboardPopularModule();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> listDashboardGeoDistribution() {
|
||||
return logMapper.selectListDashboardGeoDistribution();
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充数据
|
||||
*
|
||||
|
||||
@@ -22,4 +22,14 @@
|
||||
ORDER BY `pvCount` DESC
|
||||
LIMIT 10
|
||||
</select>
|
||||
|
||||
<select id="selectListDashboardGeoDistribution" resultType="java.util.Map">
|
||||
SELECT
|
||||
`location` AS name,
|
||||
COUNT(DISTINCT `client_ip`) AS value
|
||||
FROM `sys_log`
|
||||
GROUP BY `location`
|
||||
ORDER BY COUNT(DISTINCT `client_ip`) DESC
|
||||
LIMIT 10
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user