mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-09 20:57:21 +08:00
feat: 完善仪表盘热门模块区块内容
1.完善仪表盘热门模块区块内容 2.sys_log 表增加 module 字段索引 3.优化总计区块图标
This commit is contained in:
@@ -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;
|
||||
|
||||
/**
|
||||
@@ -31,7 +34,14 @@ public interface LogMapper extends BaseMapper<LogDO> {
|
||||
/**
|
||||
* 查询仪表盘总计信息
|
||||
*
|
||||
* @return 总计信息
|
||||
* @return 仪表盘总计信息
|
||||
*/
|
||||
DashboardTotalVO selectDashboardTotal();
|
||||
|
||||
/**
|
||||
* 查询仪表盘热门模块列表
|
||||
*
|
||||
* @return 仪表盘热门模块列表
|
||||
*/
|
||||
List<DashboardPopularModuleVO> selectListDashboardPopularModule();
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
@@ -26,7 +26,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/**
|
||||
* 仪表盘总计信息
|
||||
* 仪表盘-总计信息
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2023/9/8 21:32
|
||||
@@ -51,7 +51,7 @@ public class DashboardTotalVO implements Serializable {
|
||||
/**
|
||||
* 今日浏览量(PV)
|
||||
*/
|
||||
@Schema(description = "今日浏览量", example = "1234")
|
||||
@Schema(description = "今日浏览量(PV)", example = "1234")
|
||||
private Long todayPvCount;
|
||||
|
||||
/**
|
||||
|
@@ -18,6 +18,7 @@ package top.charles7c.cnadmin.monitor.service;
|
||||
|
||||
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;
|
||||
|
||||
@@ -36,6 +37,13 @@ public interface DashboardService {
|
||||
*/
|
||||
DashboardTotalVO getTotal();
|
||||
|
||||
/**
|
||||
* 查询热门模块列表
|
||||
*
|
||||
* @return 热门模块列表
|
||||
*/
|
||||
List<DashboardPopularModuleVO> listPopularModule();
|
||||
|
||||
/**
|
||||
* 查询公告列表
|
||||
*
|
||||
|
@@ -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;
|
||||
@@ -79,4 +81,11 @@ public interface LogService {
|
||||
* @return 仪表盘总计信息
|
||||
*/
|
||||
DashboardTotalVO getDashboardTotal();
|
||||
|
||||
/**
|
||||
* 查询仪表盘热门模块列表
|
||||
*
|
||||
* @return 仪表盘热门模块列表
|
||||
*/
|
||||
List<DashboardPopularModuleVO> listPopularModule();
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
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;
|
||||
@@ -58,6 +59,20 @@ public class DashboardServiceImpl implements DashboardService {
|
||||
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();
|
||||
|
@@ -150,6 +150,11 @@ public class LogServiceImpl implements LogService {
|
||||
return logMapper.selectDashboardTotal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DashboardPopularModuleVO> listPopularModule() {
|
||||
return logMapper.selectListDashboardPopularModule();
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充数据
|
||||
*
|
||||
|
@@ -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>
|
Reference in New Issue
Block a user