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 dc1691f commit a1c20af
Show file tree
Hide file tree
Showing 16 changed files with 369 additions and 223 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

import top.charles7c.cnadmin.common.base.BaseMapper;
import top.charles7c.cnadmin.monitor.model.entity.LogDO;
import top.charles7c.cnadmin.monitor.model.vo.DashboardAccessTrendVO;
import top.charles7c.cnadmin.monitor.model.vo.DashboardPopularModuleVO;
import top.charles7c.cnadmin.monitor.model.vo.DashboardTotalVO;

Expand All @@ -39,9 +42,19 @@ public interface LogMapper extends BaseMapper<LogDO> {
*/
DashboardTotalVO selectDashboardTotal();

/**
* 查询仪表盘访问趋势信息
*
* @param days
* 日期数
*
* @return 仪表盘访问趋势信息
*/
List<DashboardAccessTrendVO> selectListDashboardAccessTrend(@Param("days") Integer days);

/**
* 查询仪表盘热门模块列表
*
*
* @return 仪表盘热门模块列表
*/
List<DashboardPopularModuleVO> selectListDashboardPopularModule();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* 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 lombok.Data;

import io.swagger.v3.oas.annotations.media.Schema;

/**
* 仪表盘-访问趋势信息
*
* @author Charles7c
* @since 2023/9/9 20:20
*/
@Data
@Schema(description = "仪表盘-访问趋势信息")
public class DashboardAccessTrendVO implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 日期
*/
@Schema(description = "日期", example = "2023-08-08")
private String date;

/**
* 浏览量(PV)
*/
@Schema(description = "浏览量(PV)", example = "1000")
private Long pvCount;

/**
* IP 数
*/
@Schema(description = "IP 数", example = "500")
private Long ipCount;
}
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.DashboardAccessTrendVO;
import top.charles7c.cnadmin.monitor.model.vo.DashboardGeoDistributionVO;
import top.charles7c.cnadmin.monitor.model.vo.DashboardPopularModuleVO;
import top.charles7c.cnadmin.monitor.model.vo.DashboardTotalVO;
Expand All @@ -38,16 +39,25 @@ public interface DashboardService {
*/
DashboardTotalVO getTotal();

/**
* 查询访问趋势信息
*
* @param days
* 日期数
* @return 访问趋势信息
*/
List<DashboardAccessTrendVO> listAccessTrend(Integer days);

/**
* 查询热门模块列表
*
*
* @return 热门模块列表
*/
List<DashboardPopularModuleVO> listPopularModule();

/**
* 查询访客地域分布信息
*
*
* @return 访客地域分布信息
*/
DashboardGeoDistributionVO getGeoDistribution();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,16 @@ public interface LogService {
*/
DashboardTotalVO getDashboardTotal();

/**
* 查询仪表盘访问趋势信息
*
* @return 仪表盘访问趋势信息
*/
List<DashboardAccessTrendVO> listDashboardAccessTrend(Integer days);

/**
* 查询仪表盘热门模块列表
*
*
* @return 仪表盘热门模块列表
*/
List<DashboardPopularModuleVO> listDashboardPopularModule();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.NumberUtil;

import top.charles7c.cnadmin.monitor.model.vo.DashboardAccessTrendVO;
import top.charles7c.cnadmin.monitor.model.vo.DashboardGeoDistributionVO;
import top.charles7c.cnadmin.monitor.model.vo.DashboardPopularModuleVO;
import top.charles7c.cnadmin.monitor.model.vo.DashboardTotalVO;
Expand Down Expand Up @@ -63,6 +64,11 @@ public DashboardTotalVO getTotal() {
return totalVO;
}

@Override
public List<DashboardAccessTrendVO> listAccessTrend(Integer days) {
return logService.listDashboardAccessTrend(days);
}

@Override
public List<DashboardPopularModuleVO> listPopularModule() {
List<DashboardPopularModuleVO> popularModuleList = logService.listDashboardPopularModule();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ public DashboardTotalVO getDashboardTotal() {
return logMapper.selectDashboardTotal();
}

@Override
public List<DashboardAccessTrendVO> listDashboardAccessTrend(Integer days) {
return logMapper.selectListDashboardAccessTrend(days);
}

@Override
public List<DashboardPopularModuleVO> listDashboardPopularModule() {
return logMapper.selectListDashboardPopularModule();
Expand Down
12 changes: 12 additions & 0 deletions continew-admin-monitor/src/main/resources/mapper/LogMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@
(SELECT COUNT(*) FROM `sys_log` WHERE DATE(`create_time`) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)) AS yesterdayPvCount
</select>

<select id="selectListDashboardAccessTrend"
resultType="top.charles7c.cnadmin.monitor.model.vo.DashboardAccessTrendVO">
SELECT
DATE(`create_time`) AS date,
COUNT(*) AS pvCount,
COUNT(DISTINCT `client_ip`) AS ipCount
FROM `sys_log`
GROUP BY DATE(`create_time`)
ORDER BY DATE(`create_time`) DESC
LIMIT #{days}
</select>

<select id="selectListDashboardPopularModule"
resultType="top.charles7c.cnadmin.monitor.model.vo.DashboardPopularModuleVO">
SELECT
Expand Down
22 changes: 12 additions & 10 deletions continew-admin-ui/src/api/common/dashboard.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import axios from 'axios';
import type { TableData } from '@arco-design/web-vue/es/table/interface';

const BASE_URL = '/dashboard';

Expand All @@ -10,6 +9,12 @@ export interface DashboardTotalRecord {
newPvFromYesterday: number;
}

export interface DashboardAccessTrendRecord {
date: string;
pvCount: number;
ipCount: number;
}

export interface DashboardPopularModuleRecord {
module: string;
pvCount: number;
Expand All @@ -31,6 +36,12 @@ export function getTotal() {
return axios.get<DashboardTotalRecord>(`${BASE_URL}/total`);
}

export function listAccessTrend(days: number) {
return axios.get<DashboardAccessTrendRecord[]>(
`${BASE_URL}/access/trend/${days}`
);
}

export function listPopularModule() {
return axios.get<DashboardPopularModuleRecord[]>(
`${BASE_URL}/popular/module`
Expand All @@ -46,12 +57,3 @@ export function getGeoDistribution() {
export function listAnnouncement() {
return axios.get<DashboardAnnouncementRecord[]>(`${BASE_URL}/announcement`);
}

export interface ContentDataRecord {
x: string;
y: number;
}

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

0 comments on commit a1c20af

Please sign in to comment.