Skip to content

Commit

Permalink
feat: 完善仪表盘访客地域分布区块内容
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Sep 9, 2023
1 parent 83b2e2a commit dc1691f
Show file tree
Hide file tree
Showing 19 changed files with 253 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -44,4 +45,11 @@ public interface LogMapper extends BaseMapper<LogDO> {
* @return 仪表盘热门模块列表
*/
List<DashboardPopularModuleVO> selectListDashboardPopularModule();

/**
* 查询仪表盘访客地域分布信息
*
* @return 仪表盘访客地域分布信息
*/
List<Map<String, Object>> selectListDashboardGeoDistribution();
}
Original file line number Diff line number Diff line change
@@ -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:https://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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* @since 2023/9/9 9:52
*/
@Data
@Schema(description = "仪表盘-热门模块信息")
public class DashboardPopularModuleVO implements Serializable {

private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* @since 2023/9/8 21:32
*/
@Data
@Schema(description = "仪表盘-总计信息")
public class DashboardTotalVO implements Serializable {

private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

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;
Expand All @@ -44,6 +45,13 @@ public interface DashboardService {
*/
List<DashboardPopularModuleVO> listPopularModule();

/**
* 查询访客地域分布信息
*
* @return 访客地域分布信息
*/
DashboardGeoDistributionVO getGeoDistribution();

/**
* 查询公告列表
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -87,5 +88,12 @@ public interface LogService {
*
* @return 仪表盘热门模块列表
*/
List<DashboardPopularModuleVO> listPopularModule();
List<DashboardPopularModuleVO> listDashboardPopularModule();

/**
* 查询仪表盘访客地域分布信息
*
* @return 仪表盘访客地域分布信息
*/
List<Map<String, Object>> listDashboardGeoDistribution();
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@

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;
Expand Down Expand Up @@ -61,7 +65,7 @@ public DashboardTotalVO getTotal() {

@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();
Expand All @@ -73,6 +77,16 @@ public List<DashboardPopularModuleVO> listPopularModule() {
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -151,10 +152,15 @@ public DashboardTotalVO getDashboardTotal() {
}

@Override
public List<DashboardPopularModuleVO> listPopularModule() {
public List<DashboardPopularModuleVO> listDashboardPopularModule() {
return logMapper.selectListDashboardPopularModule();
}

@Override
public List<Map<String, Object>> listDashboardGeoDistribution() {
return logMapper.selectListDashboardGeoDistribution();
}

/**
* 填充数据
*
Expand Down
10 changes: 10 additions & 0 deletions continew-admin-monitor/src/main/resources/mapper/LogMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @since 2023/8/20 10:55
*/
@Data
@Schema(description = "仪表盘公告信息")
@Schema(description = "仪表盘-公告信息")
public class DashboardAnnouncementVO implements Serializable {

private static final long serialVersionUID = 1L;
Expand Down
24 changes: 12 additions & 12 deletions continew-admin-ui/src/api/common/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export interface DashboardPopularModuleRecord {
newPvFromYesterday: number;
}

export interface DashboardGeoDistributionRecord {
locations: string[];
locationIpStatistics: [];
}

export interface DashboardAnnouncementRecord {
id: string;
title: string;
Expand All @@ -32,6 +37,12 @@ export function listPopularModule() {
);
}

export function getGeoDistribution() {
return axios.get<DashboardGeoDistributionRecord>(
`${BASE_URL}/geo/distribution`
);
}

export function listAnnouncement() {
return axios.get<DashboardAnnouncementRecord[]>(`${BASE_URL}/announcement`);
}
Expand All @@ -43,15 +54,4 @@ export interface ContentDataRecord {

export function queryContentData() {
return axios.get<ContentDataRecord[]>('/api/content-data');
}

export interface PopularRecord {
key: number;
clickNumber: string;
title: string;
increases: number;
}

export function queryPopularList(params: { type: string }) {
return axios.get<TableData[]>('/api/popular/list', { params });
}
}

This file was deleted.

Loading

0 comments on commit dc1691f

Please sign in to comment.