Skip to content

Commit

Permalink
feat: 新增查询仪表盘数据总览相关接口, 重构仪表盘相关代码
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Oct 19, 2024
1 parent 731bfa0 commit e01df09
Show file tree
Hide file tree
Showing 10 changed files with 322 additions and 188 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/**
* 内部生成配置信息
*
* @author zhangqcc
* @author Charles7c
* @since 2024/8/30 19:35
*/
@Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,21 @@

package top.continew.admin.system.mapper;

import com.alicp.jetcache.anno.Cached;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import top.continew.admin.common.constant.CacheConstants;
import top.continew.admin.system.model.entity.LogDO;
import top.continew.admin.system.model.resp.dashboard.DashboardAccessTrendResp;
import top.continew.admin.system.model.resp.dashboard.DashboardChartCommonResp;
import top.continew.admin.system.model.resp.dashboard.DashboardTotalResp;
import top.continew.admin.system.model.resp.dashboard.DashboardOverviewCommonResp;
import top.continew.admin.system.model.resp.log.LogResp;
import top.continew.starter.data.mp.base.BaseMapper;

import java.util.Date;
import java.util.List;

/**
Expand Down Expand Up @@ -56,19 +60,54 @@ IPage<LogResp> selectLogPage(@Param("page") IPage<LogDO> page,
List<LogResp> selectLogList(@Param(Constants.WRAPPER) QueryWrapper<LogDO> queryWrapper);

/**
* 查询仪表盘总计信息
* 查询总数量
*
* @return 仪表盘总计信息
* @return 总数量
*/
DashboardTotalResp selectDashboardTotal();
@Select("SELECT COUNT(*) FROM sys_log")
Long selectTotalCount();

/**
* 查询仪表盘 PV 总览
*
* @return 仪表盘 PV 总览
*/
DashboardOverviewCommonResp selectDashboardOverviewPv();

/**
* 查询仪表盘 IP 总览
*
* @return 仪表盘 IP 总览
*/
DashboardOverviewCommonResp selectDashboardOverviewIp();

/**
* 查询仪表盘 PV 近 N 月各月份信息
*
* @param months 近 N 月月份列表
* @return 仪表盘 PV 近 N 月各月份信息
*/
@Cached(key = "#months[0]", name = CacheConstants.DASHBOARD_KEY_PREFIX + "PV:")
List<DashboardChartCommonResp> selectListDashboardAnalysisPv(@Param("months") List<String> months);

/**
* 查询仪表盘 IP 近 N 月各月份信息
*
* @param months 近 N 月月份列表
* @return 仪表盘 IP 近 N 月各月份信息
*/
@Cached(key = "#months[0]", name = CacheConstants.DASHBOARD_KEY_PREFIX + "IP:")
List<DashboardChartCommonResp> selectListDashboardAnalysisIp(@Param("months") List<String> months);

/**
* 查询仪表盘访问趋势信息
*
* @param days 日期数
* @param startTime 开始时间
* @param endTime 结束时间
* @return 仪表盘访问趋势信息
*/
List<DashboardAccessTrendResp> selectListDashboardAccessTrend(@Param("days") Integer days);
List<DashboardAccessTrendResp> selectListDashboardAccessTrend(@Param("startTime") Date startTime,
@Param("endTime") Date endTime);

/**
* 查询仪表盘访问时段分析信息
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
package top.continew.admin.system.model.resp.dashboard;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;
Expand All @@ -29,6 +31,8 @@
* @since 2023/9/9 20:20
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "仪表盘-访问趋势信息")
public class DashboardAccessTrendResp implements Serializable {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* 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.continew.admin.system.model.resp.dashboard;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
* 仪表盘-通用总览信息
*
* @author Charles7c
* @since 2024/10/19 12:19
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "仪表盘-通用总览信息")
public class DashboardOverviewCommonResp implements Serializable {

@Serial
private static final long serialVersionUID = 1L;

/**
* 总数
*/
@Schema(description = "总数", example = "888888")
private Long total;

/**
* 今日数量
*/
@Schema(description = "今日数量", example = "888")
private Long today;

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

/**
* 图表数据
*/
@Schema(description = "图表数据")
private List<DashboardChartCommonResp> dataList;

/**
* 昨日数量
*/
@JsonIgnore
private Long yesterday;
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,33 @@
public interface DashboardService {

/**
* 查询总计信息
* 查询公告列表
*
* @return 总计信息
* @return 公告列表
*/
DashboardTotalResp getTotal();
List<DashboardNoticeResp> listNotice();

/**
* 查询访问趋势信息
* 查询 PV 总览
*
* @param days 日期数
* @return 访问趋势信息
* @return PV 总览
*/
List<DashboardAccessTrendResp> listAccessTrend(Integer days);
DashboardOverviewCommonResp getOverviewPv();

/**
* 查询公告列表
* 查询 IP 总览
*
* @return 公告列表
* @return IP 总览
*/
List<DashboardNoticeResp> listNotice();
DashboardOverviewCommonResp getOverviewIp();

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

/**
* 查询访问时段分析信息
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,12 @@

import jakarta.servlet.http.HttpServletResponse;
import top.continew.admin.system.model.query.LogQuery;
import top.continew.admin.system.model.resp.dashboard.DashboardAccessTrendResp;
import top.continew.admin.system.model.resp.dashboard.DashboardChartCommonResp;
import top.continew.admin.system.model.resp.dashboard.DashboardTotalResp;
import top.continew.admin.system.model.resp.log.LogDetailResp;
import top.continew.admin.system.model.resp.log.LogResp;
import top.continew.starter.extension.crud.model.query.PageQuery;
import top.continew.starter.extension.crud.model.query.SortQuery;
import top.continew.starter.extension.crud.model.resp.PageResp;

import java.util.List;

/**
* 系统日志业务接口
*
Expand Down Expand Up @@ -71,58 +66,4 @@ public interface LogService {
* @param response 响应对象
*/
void exportOperationLog(LogQuery query, SortQuery sortQuery, HttpServletResponse response);

/**
* 查询仪表盘总计信息
*
* @return 仪表盘总计信息
*/
DashboardTotalResp getDashboardTotal();

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

/**
* 查询仪表盘访问时段分析信息
*
* @return 仪表盘访问时段分析信息
*/
List<DashboardChartCommonResp> listDashboardAnalysisTimeslot();

/**
* 查询仪表盘地域分析信息
*
* @param top 显示数量
* @return 仪表盘地域分析信息
*/
List<DashboardChartCommonResp> listDashboardAnalysisGeo(int top);

/**
* 查询仪表盘模块分析信息
*
* @param top 显示数量
* @return 仪表盘模块分析信息
*/
List<DashboardChartCommonResp> listDashboardAnalysisModule(int top);

/**
* 查询仪表盘终端分析信息
*
* @param top 显示数量
* @return 仪表盘终端分析信息
*/
List<DashboardChartCommonResp> listDashboardAnalysisOs(int top);

/**
* 查询仪表盘浏览器分析信息
*
* @param top 显示数量
* @return 仪表盘浏览器分析信息
*/
List<DashboardChartCommonResp> listDashboardAnalysisBrowser(int top);
}
Loading

0 comments on commit e01df09

Please sign in to comment.