Skip to content

Commit e01df09

Browse files
committed
feat: 新增查询仪表盘数据总览相关接口, 重构仪表盘相关代码
1 parent 731bfa0 commit e01df09

File tree

10 files changed

+322
-188
lines changed

10 files changed

+322
-188
lines changed

continew-admin-plugins/continew-admin-generator/src/main/java/top/continew/admin/generator/model/entity/InnerGenConfigDO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
/**
3232
* 内部生成配置信息
3333
*
34-
* @author zhangqcc
34+
* @author Charles7c
3535
* @since 2024/8/30 19:35
3636
*/
3737
@Data

continew-admin-system/src/main/java/top/continew/admin/system/mapper/LogMapper.java

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,21 @@
1616

1717
package top.continew.admin.system.mapper;
1818

19+
import com.alicp.jetcache.anno.Cached;
1920
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
2021
import com.baomidou.mybatisplus.core.metadata.IPage;
2122
import com.baomidou.mybatisplus.core.toolkit.Constants;
2223
import org.apache.ibatis.annotations.Param;
24+
import org.apache.ibatis.annotations.Select;
25+
import top.continew.admin.common.constant.CacheConstants;
2326
import top.continew.admin.system.model.entity.LogDO;
2427
import top.continew.admin.system.model.resp.dashboard.DashboardAccessTrendResp;
2528
import top.continew.admin.system.model.resp.dashboard.DashboardChartCommonResp;
26-
import top.continew.admin.system.model.resp.dashboard.DashboardTotalResp;
29+
import top.continew.admin.system.model.resp.dashboard.DashboardOverviewCommonResp;
2730
import top.continew.admin.system.model.resp.log.LogResp;
2831
import top.continew.starter.data.mp.base.BaseMapper;
2932

33+
import java.util.Date;
3034
import java.util.List;
3135

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

5862
/**
59-
* 查询仪表盘总计信息
63+
* 查询总数量
6064
*
61-
* @return 仪表盘总计信息
65+
* @return 总数量
6266
*/
63-
DashboardTotalResp selectDashboardTotal();
67+
@Select("SELECT COUNT(*) FROM sys_log")
68+
Long selectTotalCount();
69+
70+
/**
71+
* 查询仪表盘 PV 总览
72+
*
73+
* @return 仪表盘 PV 总览
74+
*/
75+
DashboardOverviewCommonResp selectDashboardOverviewPv();
76+
77+
/**
78+
* 查询仪表盘 IP 总览
79+
*
80+
* @return 仪表盘 IP 总览
81+
*/
82+
DashboardOverviewCommonResp selectDashboardOverviewIp();
83+
84+
/**
85+
* 查询仪表盘 PV 近 N 月各月份信息
86+
*
87+
* @param months 近 N 月月份列表
88+
* @return 仪表盘 PV 近 N 月各月份信息
89+
*/
90+
@Cached(key = "#months[0]", name = CacheConstants.DASHBOARD_KEY_PREFIX + "PV:")
91+
List<DashboardChartCommonResp> selectListDashboardAnalysisPv(@Param("months") List<String> months);
92+
93+
/**
94+
* 查询仪表盘 IP 近 N 月各月份信息
95+
*
96+
* @param months 近 N 月月份列表
97+
* @return 仪表盘 IP 近 N 月各月份信息
98+
*/
99+
@Cached(key = "#months[0]", name = CacheConstants.DASHBOARD_KEY_PREFIX + "IP:")
100+
List<DashboardChartCommonResp> selectListDashboardAnalysisIp(@Param("months") List<String> months);
64101

65102
/**
66103
* 查询仪表盘访问趋势信息
67104
*
68-
* @param days 日期数
105+
* @param startTime 开始时间
106+
* @param endTime 结束时间
69107
* @return 仪表盘访问趋势信息
70108
*/
71-
List<DashboardAccessTrendResp> selectListDashboardAccessTrend(@Param("days") Integer days);
109+
List<DashboardAccessTrendResp> selectListDashboardAccessTrend(@Param("startTime") Date startTime,
110+
@Param("endTime") Date endTime);
72111

73112
/**
74113
* 查询仪表盘访问时段分析信息

continew-admin-system/src/main/java/top/continew/admin/system/model/resp/dashboard/DashboardAccessTrendResp.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
package top.continew.admin.system.model.resp.dashboard;
1818

1919
import io.swagger.v3.oas.annotations.media.Schema;
20+
import lombok.AllArgsConstructor;
2021
import lombok.Data;
22+
import lombok.NoArgsConstructor;
2123

2224
import java.io.Serial;
2325
import java.io.Serializable;
@@ -29,6 +31,8 @@
2931
* @since 2023/9/9 20:20
3032
*/
3133
@Data
34+
@NoArgsConstructor
35+
@AllArgsConstructor
3236
@Schema(description = "仪表盘-访问趋势信息")
3337
public class DashboardAccessTrendResp implements Serializable {
3438

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package top.continew.admin.system.model.resp.dashboard;
18+
19+
import com.fasterxml.jackson.annotation.JsonIgnore;
20+
import io.swagger.v3.oas.annotations.media.Schema;
21+
import lombok.AllArgsConstructor;
22+
import lombok.Data;
23+
import lombok.NoArgsConstructor;
24+
25+
import java.io.Serial;
26+
import java.io.Serializable;
27+
import java.math.BigDecimal;
28+
import java.util.List;
29+
30+
/**
31+
* 仪表盘-通用总览信息
32+
*
33+
* @author Charles7c
34+
* @since 2024/10/19 12:19
35+
*/
36+
@Data
37+
@NoArgsConstructor
38+
@AllArgsConstructor
39+
@Schema(description = "仪表盘-通用总览信息")
40+
public class DashboardOverviewCommonResp implements Serializable {
41+
42+
@Serial
43+
private static final long serialVersionUID = 1L;
44+
45+
/**
46+
* 总数
47+
*/
48+
@Schema(description = "总数", example = "888888")
49+
private Long total;
50+
51+
/**
52+
* 今日数量
53+
*/
54+
@Schema(description = "今日数量", example = "888")
55+
private Long today;
56+
57+
/**
58+
* 较昨日新增(百分比)
59+
*/
60+
@Schema(description = "较昨日新增(百分比)", example = "23.4")
61+
private BigDecimal growth;
62+
63+
/**
64+
* 图表数据
65+
*/
66+
@Schema(description = "图表数据")
67+
private List<DashboardChartCommonResp> dataList;
68+
69+
/**
70+
* 昨日数量
71+
*/
72+
@JsonIgnore
73+
private Long yesterday;
74+
}

continew-admin-system/src/main/java/top/continew/admin/system/service/DashboardService.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,33 @@
2929
public interface DashboardService {
3030

3131
/**
32-
* 查询总计信息
32+
* 查询公告列表
3333
*
34-
* @return 总计信息
34+
* @return 公告列表
3535
*/
36-
DashboardTotalResp getTotal();
36+
List<DashboardNoticeResp> listNotice();
3737

3838
/**
39-
* 查询访问趋势信息
39+
* 查询 PV 总览
4040
*
41-
* @param days 日期数
42-
* @return 访问趋势信息
41+
* @return PV 总览
4342
*/
44-
List<DashboardAccessTrendResp> listAccessTrend(Integer days);
43+
DashboardOverviewCommonResp getOverviewPv();
4544

4645
/**
47-
* 查询公告列表
46+
* 查询 IP 总览
4847
*
49-
* @return 公告列表
48+
* @return IP 总览
5049
*/
51-
List<DashboardNoticeResp> listNotice();
50+
DashboardOverviewCommonResp getOverviewIp();
51+
52+
/**
53+
* 查询访问趋势信息
54+
*
55+
* @param days 日期数
56+
* @return 访问趋势信息
57+
*/
58+
List<DashboardAccessTrendResp> listAccessTrend(Integer days);
5259

5360
/**
5461
* 查询访问时段分析信息

continew-admin-system/src/main/java/top/continew/admin/system/service/LogService.java

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,12 @@
1818

1919
import jakarta.servlet.http.HttpServletResponse;
2020
import top.continew.admin.system.model.query.LogQuery;
21-
import top.continew.admin.system.model.resp.dashboard.DashboardAccessTrendResp;
22-
import top.continew.admin.system.model.resp.dashboard.DashboardChartCommonResp;
23-
import top.continew.admin.system.model.resp.dashboard.DashboardTotalResp;
2421
import top.continew.admin.system.model.resp.log.LogDetailResp;
2522
import top.continew.admin.system.model.resp.log.LogResp;
2623
import top.continew.starter.extension.crud.model.query.PageQuery;
2724
import top.continew.starter.extension.crud.model.query.SortQuery;
2825
import top.continew.starter.extension.crud.model.resp.PageResp;
2926

30-
import java.util.List;
31-
3227
/**
3328
* 系统日志业务接口
3429
*
@@ -71,58 +66,4 @@ public interface LogService {
7166
* @param response 响应对象
7267
*/
7368
void exportOperationLog(LogQuery query, SortQuery sortQuery, HttpServletResponse response);
74-
75-
/**
76-
* 查询仪表盘总计信息
77-
*
78-
* @return 仪表盘总计信息
79-
*/
80-
DashboardTotalResp getDashboardTotal();
81-
82-
/**
83-
* 查询仪表盘访问趋势信息
84-
*
85-
* @param days 日期数
86-
* @return 仪表盘访问趋势信息
87-
*/
88-
List<DashboardAccessTrendResp> listDashboardAccessTrend(Integer days);
89-
90-
/**
91-
* 查询仪表盘访问时段分析信息
92-
*
93-
* @return 仪表盘访问时段分析信息
94-
*/
95-
List<DashboardChartCommonResp> listDashboardAnalysisTimeslot();
96-
97-
/**
98-
* 查询仪表盘地域分析信息
99-
*
100-
* @param top 显示数量
101-
* @return 仪表盘地域分析信息
102-
*/
103-
List<DashboardChartCommonResp> listDashboardAnalysisGeo(int top);
104-
105-
/**
106-
* 查询仪表盘模块分析信息
107-
*
108-
* @param top 显示数量
109-
* @return 仪表盘模块分析信息
110-
*/
111-
List<DashboardChartCommonResp> listDashboardAnalysisModule(int top);
112-
113-
/**
114-
* 查询仪表盘终端分析信息
115-
*
116-
* @param top 显示数量
117-
* @return 仪表盘终端分析信息
118-
*/
119-
List<DashboardChartCommonResp> listDashboardAnalysisOs(int top);
120-
121-
/**
122-
* 查询仪表盘浏览器分析信息
123-
*
124-
* @param top 显示数量
125-
* @return 仪表盘浏览器分析信息
126-
*/
127-
List<DashboardChartCommonResp> listDashboardAnalysisBrowser(int top);
12869
}

0 commit comments

Comments
 (0)