feat(dashboard): 新增仪表盘控制器
- 新增DashboardController控制器类 - 实现仪表盘数据统计接口 - 支持用户统计、登录统计、存储统计等功能 - 配置dashboard权限验证
This commit is contained in:
parent
a775809c4d
commit
91393b7a57
@ -0,0 +1,173 @@
|
|||||||
|
package org.leocoder.thin.system.controller.dashboard;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
|
import org.leocoder.thin.common.exception.coder.YUtil;
|
||||||
|
import org.leocoder.thin.domain.model.vo.system.DashboardStatisticsVo;
|
||||||
|
import org.leocoder.thin.domain.model.vo.system.LoginTrendVo;
|
||||||
|
import org.leocoder.thin.system.service.dashboard.DashboardService;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仪表盘统计控制器
|
||||||
|
*
|
||||||
|
* @author Leocoder
|
||||||
|
*/
|
||||||
|
@Tag(name = "仪表盘管理", description = "仪表盘统计数据接口")
|
||||||
|
@Slf4j
|
||||||
|
@Validated
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/coder/dashboard")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class DashboardController {
|
||||||
|
|
||||||
|
private final DashboardService dashboardService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 获取仪表盘统计数据
|
||||||
|
* @author Leocoder
|
||||||
|
*/
|
||||||
|
@Operation(
|
||||||
|
summary = "获取仪表盘统计数据",
|
||||||
|
description = "获取用户、登录、存储、活跃度等核心统计数据"
|
||||||
|
)
|
||||||
|
@GetMapping("/getStatistics")
|
||||||
|
@SaCheckPermission("dashboard:view")
|
||||||
|
public DashboardStatisticsVo getStatistics() {
|
||||||
|
DashboardStatisticsVo statistics = dashboardService.getStatistics();
|
||||||
|
YUtil.isTrue(ObjectUtils.isEmpty(statistics), "获取仪表盘统计数据失败");
|
||||||
|
return statistics;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 获取登录趋势数据
|
||||||
|
* @author Leocoder
|
||||||
|
*/
|
||||||
|
@Operation(
|
||||||
|
summary = "获取登录趋势数据",
|
||||||
|
description = "获取最近N天的登录趋势图表数据"
|
||||||
|
)
|
||||||
|
@GetMapping("/getLoginTrend")
|
||||||
|
@SaCheckPermission("dashboard:view")
|
||||||
|
public LoginTrendVo getLoginTrend(
|
||||||
|
@Parameter(description = "查询天数", example = "7") @RequestParam(
|
||||||
|
defaultValue = "7"
|
||||||
|
) Integer days
|
||||||
|
) {
|
||||||
|
LoginTrendVo loginTrend = dashboardService.getLoginTrend(days);
|
||||||
|
YUtil.isTrue(ObjectUtils.isEmpty(loginTrend), "获取登录趋势数据失败");
|
||||||
|
return loginTrend;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 获取完整仪表盘数据
|
||||||
|
* @author Leocoder
|
||||||
|
*/
|
||||||
|
@Operation(
|
||||||
|
summary = "获取完整仪表盘数据",
|
||||||
|
description = "一次性获取所有仪表盘数据,减少前端请求次数"
|
||||||
|
)
|
||||||
|
@GetMapping("/getAllData")
|
||||||
|
@SaCheckPermission("dashboard:view")
|
||||||
|
public DashboardStatisticsVo getAllData(
|
||||||
|
@Parameter(
|
||||||
|
description = "是否包含趋势数据",
|
||||||
|
example = "true"
|
||||||
|
) @RequestParam(defaultValue = "true") Boolean includeTrend,
|
||||||
|
@Parameter(description = "趋势数据天数", example = "7") @RequestParam(
|
||||||
|
defaultValue = "7"
|
||||||
|
) Integer trendDays
|
||||||
|
) {
|
||||||
|
DashboardStatisticsVo allData = dashboardService.getAllData(
|
||||||
|
includeTrend,
|
||||||
|
trendDays
|
||||||
|
);
|
||||||
|
YUtil.isTrue(ObjectUtils.isEmpty(allData), "获取完整仪表盘数据失败");
|
||||||
|
return allData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 获取用户统计数据
|
||||||
|
* @author Leocoder
|
||||||
|
*/
|
||||||
|
@Operation(
|
||||||
|
summary = "获取用户统计数据",
|
||||||
|
description = "获取用户相关的统计信息"
|
||||||
|
)
|
||||||
|
@GetMapping("/getUserStats")
|
||||||
|
@SaCheckPermission("dashboard:view")
|
||||||
|
public DashboardStatisticsVo.UserStatsVo getUserStats() {
|
||||||
|
DashboardStatisticsVo.UserStatsVo userStats =
|
||||||
|
dashboardService.getUserStats();
|
||||||
|
YUtil.isTrue(ObjectUtils.isEmpty(userStats), "获取用户统计数据失败");
|
||||||
|
return userStats;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 获取登录统计数据
|
||||||
|
* @author Leocoder
|
||||||
|
*/
|
||||||
|
@Operation(
|
||||||
|
summary = "获取登录统计数据",
|
||||||
|
description = "获取登录相关的统计信息"
|
||||||
|
)
|
||||||
|
@GetMapping("/getLoginStats")
|
||||||
|
@SaCheckPermission("dashboard:view")
|
||||||
|
public DashboardStatisticsVo.LoginStatsVo getLoginStats(
|
||||||
|
@Parameter(
|
||||||
|
description = "是否包含趋势数据",
|
||||||
|
example = "false"
|
||||||
|
) @RequestParam(defaultValue = "false") Boolean includeTrend,
|
||||||
|
@Parameter(description = "趋势数据天数", example = "7") @RequestParam(
|
||||||
|
defaultValue = "7"
|
||||||
|
) Integer trendDays
|
||||||
|
) {
|
||||||
|
DashboardStatisticsVo.LoginStatsVo loginStats =
|
||||||
|
dashboardService.getLoginStats(includeTrend, trendDays);
|
||||||
|
YUtil.isTrue(ObjectUtils.isEmpty(loginStats), "获取登录统计数据失败");
|
||||||
|
return loginStats;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 获取存储统计数据
|
||||||
|
* @author Leocoder
|
||||||
|
*/
|
||||||
|
@Operation(
|
||||||
|
summary = "获取存储统计数据",
|
||||||
|
description = "获取存储相关的统计信息"
|
||||||
|
)
|
||||||
|
@GetMapping("/getStorageStats")
|
||||||
|
@SaCheckPermission("dashboard:view")
|
||||||
|
public DashboardStatisticsVo.StorageStatsVo getStorageStats() {
|
||||||
|
DashboardStatisticsVo.StorageStatsVo storageStats =
|
||||||
|
dashboardService.getStorageStats();
|
||||||
|
YUtil.isTrue(ObjectUtils.isEmpty(storageStats), "获取存储统计数据失败");
|
||||||
|
return storageStats;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 获取今日活跃统计数据
|
||||||
|
* @author Leocoder
|
||||||
|
*/
|
||||||
|
@Operation(
|
||||||
|
summary = "获取今日活跃统计数据",
|
||||||
|
description = "获取今日活跃相关的统计信息"
|
||||||
|
)
|
||||||
|
@GetMapping("/getDailyActivityStats")
|
||||||
|
@SaCheckPermission("dashboard:view")
|
||||||
|
public DashboardStatisticsVo.DailyActivityStatsVo getDailyActivityStats() {
|
||||||
|
DashboardStatisticsVo.DailyActivityStatsVo activityStats =
|
||||||
|
dashboardService.getDailyActivityStats();
|
||||||
|
YUtil.isTrue(
|
||||||
|
ObjectUtils.isEmpty(activityStats),
|
||||||
|
"获取今日活跃统计数据失败"
|
||||||
|
);
|
||||||
|
return activityStats;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user