页面样式,svg
This commit is contained in:
@@ -2,9 +2,15 @@ package org.xyzh.system.controller;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.xyzh.common.core.domain.ResultDomain;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -24,9 +30,25 @@ public class SystemOverviewController {
|
||||
*/
|
||||
@GetMapping("/statistics")
|
||||
public ResultDomain<Map<String, Object>> getSystemStatistics() {
|
||||
// TODO: 实现获取系统总览数据统计
|
||||
// 统计系统总用户数、资源总数、今日访问量
|
||||
return null;
|
||||
// TODO: 后续接入真实统计数据(用户表、资源表、访问统计表等)
|
||||
ResultDomain<Map<String, Object>> result = new ResultDomain<>();
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
|
||||
// 顶部统计卡片:总用户数、总资源数、今日访问量、活跃用户
|
||||
data.put("totalUsers", 1234);
|
||||
data.put("totalUsersChange", "+12%");
|
||||
|
||||
data.put("totalResources", 5678);
|
||||
data.put("totalResourcesChange", "+8%");
|
||||
|
||||
data.put("todayVisits", 892);
|
||||
data.put("todayVisitsChange", "+15%");
|
||||
|
||||
data.put("activeUsers", 456);
|
||||
data.put("activeUsersChange", "+5%");
|
||||
|
||||
result.success("获取系统总览统计成功", data);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,9 +56,23 @@ public class SystemOverviewController {
|
||||
*/
|
||||
@GetMapping("/active-users")
|
||||
public ResultDomain<Map<String, Object>> getActiveUsersChart(
|
||||
@RequestParam(required = false) Integer days) {
|
||||
// TODO: 实现获取活跃用户图表数据(折线图,展示7/30天活跃用户数)
|
||||
return null;
|
||||
@RequestParam(required = true, name = "start") String start, @RequestParam(required = true, name = "end") String end) {
|
||||
// TODO: 后续根据days参数(7/30天)查询真实活跃用户统计
|
||||
ResultDomain<Map<String, Object>> result = new ResultDomain<>();
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
|
||||
// 默认展示7天
|
||||
LocalDate startDate = LocalDate.parse(start);
|
||||
LocalDate endDate = LocalDate.parse(end);
|
||||
long days = startDate.until(endDate).getDays();
|
||||
|
||||
// X轴:周一 ~ 周日(示例)
|
||||
data.put("labels", List.of("周一", "周二", "周三", "周四", "周五", "周六", "周日"));
|
||||
// Y轴数据:活跃用户数量(示例数据)
|
||||
data.put("values", List.of(120, 200, 150, 80, 70, 110, 130));
|
||||
|
||||
result.success("获取活跃用户图表数据成功", data);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,17 +80,22 @@ public class SystemOverviewController {
|
||||
*/
|
||||
@GetMapping("/resource-category-stats")
|
||||
public ResultDomain<Map<String, Object>> getResourceCategoryStats() {
|
||||
// TODO: 实现获取资源分类统计(饼图,展示各类型资源占比)
|
||||
return null;
|
||||
}
|
||||
// TODO: 后续从资源表统计各类型资源数量
|
||||
ResultDomain<Map<String, Object>> result = new ResultDomain<>();
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 获取用户活跃度数据
|
||||
*/
|
||||
@GetMapping("/user-activity")
|
||||
public ResultDomain<Map<String, Object>> getUserActivityData() {
|
||||
// TODO: 实现获取用户活跃度数据
|
||||
return null;
|
||||
// 饼图数据:名称 + 数量
|
||||
List<Map<String, Object>> categories = List.of(
|
||||
createCategory("文章", 1048),
|
||||
createCategory("视频", 735),
|
||||
createCategory("音频", 580),
|
||||
createCategory("课程", 484),
|
||||
createCategory("其他", 300)
|
||||
);
|
||||
|
||||
data.put("items", categories);
|
||||
result.success("获取资源分类统计成功", data);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,8 +103,17 @@ public class SystemOverviewController {
|
||||
*/
|
||||
@GetMapping("/today-visits")
|
||||
public ResultDomain<Map<String, Object>> getTodayVisits() {
|
||||
// TODO: 实现获取今日访问量统计
|
||||
return null;
|
||||
// TODO: 后续接入访问日志/统计表,计算今日指标
|
||||
ResultDomain<Map<String, Object>> result = new ResultDomain<>();
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
|
||||
data.put("uv", 892);
|
||||
data.put("pv", 3456);
|
||||
data.put("avgVisitDuration", "5分32秒");
|
||||
data.put("bounceRate", "35.6%");
|
||||
|
||||
result.success("获取今日访问量统计成功", data);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +121,21 @@ public class SystemOverviewController {
|
||||
*/
|
||||
@GetMapping("/system-status")
|
||||
public ResultDomain<Map<String, Object>> getSystemStatus() {
|
||||
// TODO: 实现获取系统运行状态
|
||||
return null;
|
||||
// TODO: 后续接入真实系统运行状态(CPU、内存、服务可用性等)
|
||||
ResultDomain<Map<String, Object>> result = new ResultDomain<>();
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
|
||||
data.put("status", "UP");
|
||||
data.put("message", "系统运行正常");
|
||||
|
||||
result.success("获取系统运行状态成功", data);
|
||||
return result;
|
||||
}
|
||||
|
||||
private Map<String, Object> createCategory(String name, int value) {
|
||||
Map<String, Object> item = new HashMap<>();
|
||||
item.put("name", name);
|
||||
item.put("value", value);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,8 +59,8 @@ public class LoginUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 从Redis获取LoginDomain
|
||||
String redisKey = REDIS_LOGIN_PREFIX + userId;
|
||||
// 从Redis获取LoginDomain(按token维度存储和获取会话信息)
|
||||
String redisKey = REDIS_LOGIN_PREFIX + token;
|
||||
LoginDomain loginDomain = (LoginDomain) redisService.get(redisKey);
|
||||
|
||||
if (loginDomain != null) {
|
||||
|
||||
Reference in New Issue
Block a user