Skip to content

Commit

Permalink
feat: 完善仪表盘热门模块区块内容
Browse files Browse the repository at this point in the history
1.完善仪表盘热门模块区块内容
2.sys_log 表增加 module 字段索引
3.优化总计区块图标
  • Loading branch information
Charles7c committed Sep 9, 2023
1 parent 3440aa4 commit 83b2e2a
Show file tree
Hide file tree
Showing 27 changed files with 200 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@

package top.charles7c.cnadmin.monitor.mapper;

import java.util.List;

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

/**
Expand All @@ -31,7 +34,14 @@ public interface LogMapper extends BaseMapper<LogDO> {
/**
* 查询仪表盘总计信息
*
* @return 总计信息
* @return 仪表盘总计信息
*/
DashboardTotalVO selectDashboardTotal();

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

import lombok.Data;

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

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
* 仪表盘-热门模块信息
*
* @author Charles7c
* @since 2023/9/9 9:52
*/
@Data
public class DashboardPopularModuleVO implements Serializable {

private static final long serialVersionUID = 1L;

/**
* 模块
*/
@Schema(description = "模块", example = "角色管理")
private String module;

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

/**
* 较昨日新增 PV(百分比)
*/
@Schema(description = "较昨日新增(百分比)", example = "23.4")
private BigDecimal newPvFromYesterday;

/**
* 今日浏览量(PV)
*/
@JsonIgnore
private Long todayPvCount;

/**
* 昨日浏览量(PV)
*/
@JsonIgnore
private Long yesterdayPvCount;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import com.fasterxml.jackson.annotation.JsonIgnore;

/**
* 仪表盘总计信息
* 仪表盘-总计信息
*
* @author Charles7c
* @since 2023/9/8 21:32
Expand All @@ -51,7 +51,7 @@ public class DashboardTotalVO implements Serializable {
/**
* 今日浏览量(PV)
*/
@Schema(description = "今日浏览量", example = "1234")
@Schema(description = "今日浏览量(PV)", example = "1234")
private Long todayPvCount;

/**
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.DashboardPopularModuleVO;
import top.charles7c.cnadmin.monitor.model.vo.DashboardTotalVO;
import top.charles7c.cnadmin.system.model.vo.DashboardAnnouncementVO;

Expand All @@ -36,6 +37,13 @@ public interface DashboardService {
*/
DashboardTotalVO getTotal();

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

/**
* 查询公告列表
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package top.charles7c.cnadmin.monitor.service;

import java.util.List;

import top.charles7c.cnadmin.common.model.query.PageQuery;
import top.charles7c.cnadmin.common.model.vo.PageDataVO;
import top.charles7c.cnadmin.monitor.model.query.LoginLogQuery;
Expand Down Expand Up @@ -79,4 +81,11 @@ public interface LogService {
* @return 仪表盘总计信息
*/
DashboardTotalVO getDashboardTotal();

/**
* 查询仪表盘热门模块列表
*
* @return 仪表盘热门模块列表
*/
List<DashboardPopularModuleVO> listPopularModule();
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import cn.hutool.core.util.NumberUtil;

import top.charles7c.cnadmin.monitor.model.vo.DashboardPopularModuleVO;
import top.charles7c.cnadmin.monitor.model.vo.DashboardTotalVO;
import top.charles7c.cnadmin.monitor.service.DashboardService;
import top.charles7c.cnadmin.monitor.service.LogService;
Expand Down Expand Up @@ -58,6 +59,20 @@ public DashboardTotalVO getTotal() {
return totalVO;
}

@Override
public List<DashboardPopularModuleVO> listPopularModule() {
List<DashboardPopularModuleVO> popularModuleList = logService.listPopularModule();
for (DashboardPopularModuleVO popularModule : popularModuleList) {
Long todayPvCount = popularModule.getTodayPvCount();
Long yesterdayPvCount = popularModule.getYesterdayPvCount();
BigDecimal newPvCountFromYesterday = NumberUtil.sub(todayPvCount, yesterdayPvCount);
BigDecimal newPvFromYesterday = (0 == yesterdayPvCount) ? BigDecimal.valueOf(100)
: NumberUtil.round(NumberUtil.mul(NumberUtil.div(newPvCountFromYesterday, yesterdayPvCount), 100), 1);
popularModule.setNewPvFromYesterday(newPvFromYesterday);
}
return popularModuleList;
}

@Override
public List<DashboardAnnouncementVO> listAnnouncement() {
return announcementService.listDashboard();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ public DashboardTotalVO getDashboardTotal() {
return logMapper.selectDashboardTotal();
}

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

/**
* 填充数据
*
Expand Down
14 changes: 14 additions & 0 deletions continew-admin-monitor/src/main/resources/mapper/LogMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,18 @@
(SELECT COUNT(*) FROM `sys_log` WHERE DATE(`create_time`) = CURDATE()) AS todayPvCount,
(SELECT COUNT(*) FROM `sys_log` WHERE DATE(`create_time`) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)) AS yesterdayPvCount
</select>

<select id="selectListDashboardPopularModule"
resultType="top.charles7c.cnadmin.monitor.model.vo.DashboardPopularModuleVO">
SELECT
`module`,
COUNT(*) AS pvCount,
SUM(CASE WHEN DATE(`create_time`) = CURDATE() THEN 1 ELSE 0 END) AS todayPvCount,
SUM(CASE WHEN DATE(`create_time`) = DATE_SUB(CURDATE(), INTERVAL 1 DAY) THEN 1 ELSE 0 END) AS yesterdayPvCount
FROM `sys_log`
GROUP BY `module`
HAVING `module` != '验证码' AND `module` != '登录'
ORDER BY `pvCount` DESC
LIMIT 10
</select>
</mapper>
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public interface AnnouncementMapper extends BaseMapper<AnnouncementDO> {
/**
* 查询仪表盘公告列表
*
* @return 公告列表
* @return 仪表盘公告列表
*/
List<DashboardAnnouncementVO> selectDashboardList();
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import top.charles7c.cnadmin.system.enums.AnnouncementTypeEnum;

/**
* 仪表盘公告信息
* 仪表盘-公告信息
*
* @author Charles7c
* @since 2023/8/20 10:55
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public interface AnnouncementService
/**
* 查询仪表盘公告列表
*
* @return 公告列表
* @return 仪表盘公告列表
*/
List<DashboardAnnouncementVO> listDashboard();
}
12 changes: 12 additions & 0 deletions continew-admin-ui/src/api/common/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ export interface DashboardTotalRecord {
newPvFromYesterday: number;
}

export interface DashboardPopularModuleRecord {
module: string;
pvCount: number;
newPvFromYesterday: number;
}

export interface DashboardAnnouncementRecord {
id: string;
title: string;
Expand All @@ -20,6 +26,12 @@ export function getTotal() {
return axios.get<DashboardTotalRecord>(`${BASE_URL}/total`);
}

export function listPopularModule() {
return axios.get<DashboardPopularModuleRecord[]>(
`${BASE_URL}/popular/module`
);
}

export function listAnnouncement() {
return axios.get<DashboardAnnouncementRecord[]>(`${BASE_URL}/announcement`);
}
Expand Down
Binary file added continew-admin-ui/src/assets/icons/png/data.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added continew-admin-ui/src/assets/icons/png/hot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion continew-admin-ui/src/assets/icons/svg/data.svg

This file was deleted.

1 change: 0 additions & 1 deletion continew-admin-ui/src/assets/icons/svg/hot.svg

This file was deleted.

1 change: 0 additions & 1 deletion continew-admin-ui/src/assets/icons/svg/popularity.svg

This file was deleted.

1 change: 0 additions & 1 deletion continew-admin-ui/src/assets/icons/svg/same-city.svg

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
:span="{ xs: 12, sm: 12, md: 12, lg: 12, xl: 12, xxl: 6 }"
>
<a-space>
<a-avatar :size="54" class="col-avatar">
<svg-icon icon-class="popularity" />
<a-avatar :size="50" class="col-avatar">
<img :src="PvCountIcon" alt="PvCountIcon" />
</a-avatar>
<a-statistic
:title="$t('workplace.pvCount')"
Expand All @@ -26,8 +26,8 @@
:span="{ xs: 12, sm: 12, md: 12, lg: 12, xl: 12, xxl: 6 }"
>
<a-space>
<a-avatar :size="54" class="col-avatar">
<svg-icon icon-class="same-city" />
<a-avatar :size="50" class="col-avatar">
<img :src="IpCountIcon" alt="IpCountIcon" />
</a-avatar>
<a-statistic
:title="$t('workplace.ipCount')"
Expand All @@ -47,8 +47,8 @@
:span="{ xs: 12, sm: 12, md: 12, lg: 12, xl: 12, xxl: 6 }"
>
<a-space>
<a-avatar :size="54" class="col-avatar">
<svg-icon icon-class="hot" />
<a-avatar :size="50" class="col-avatar">
<img :src="TodayPvCountIcon" alt="TodayPvCountIcon" />
</a-avatar>
<a-statistic
:title="$t('workplace.todayPvCount')"
Expand All @@ -69,8 +69,8 @@
style="border-right: none"
>
<a-space>
<a-avatar :size="54" class="col-avatar">
<svg-icon icon-class="data" />
<a-avatar :size="50" class="col-avatar">
<img :src="NewPvFromYesterdayIcon" alt="NewPvFromYesterdayIcon" />
</a-avatar>
<a-statistic
:title="$t('workplace.newPvFromYesterday')"
Expand Down Expand Up @@ -102,6 +102,10 @@
<script lang="ts" setup>
import { ref } from 'vue';
import { DashboardTotalRecord, getTotal } from '@/api/common/dashboard';
import PvCountIcon from '@/assets/icons/png/popularity.png';
import IpCountIcon from '@/assets/icons/png/same-city.png';
import TodayPvCountIcon from '@/assets/icons/png/hot.png';
import NewPvFromYesterdayIcon from '@/assets/icons/png/data.png';
const totalData = ref<DashboardTotalRecord>({
pvCount: 0,
Expand Down
Loading

0 comments on commit 83b2e2a

Please sign in to comment.