refactor(controller): 移除自动注入改用静态方法获取用户ID
All checks were successful
test/timeline-server/pipeline/head This commit looks good
All checks were successful
test/timeline-server/pipeline/head This commit looks good
移除StatisticsController中自动注入的UserContextUtils,改为直接调用静态方法UserContextUtils.getCurrentUserId()获取用户ID,简化代码结构并减少依赖注入
This commit is contained in:
@@ -20,9 +20,6 @@ public class StatisticsController {
|
||||
@Autowired
|
||||
private StatisticsService statisticsService;
|
||||
|
||||
@Autowired
|
||||
private UserContextUtils userContextUtils;
|
||||
|
||||
/**
|
||||
* 获取用户统计概览
|
||||
* GET /api/v1/statistics/overview
|
||||
@@ -30,7 +27,7 @@ public class StatisticsController {
|
||||
*/
|
||||
@GetMapping("/overview")
|
||||
public ResponseEntity<UserStatisticsDto> getStatisticsOverview() {
|
||||
String userId = userContextUtils.getCurrentUserId();
|
||||
String userId = UserContextUtils.getCurrentUserId();
|
||||
log.info("获取用户统计概览: userId={}", userId);
|
||||
|
||||
UserStatisticsDto statistics = statisticsService.getStatisticsOverview(userId);
|
||||
@@ -43,7 +40,7 @@ public class StatisticsController {
|
||||
*/
|
||||
@GetMapping("/uploads")
|
||||
public ResponseEntity<Object> getUploadTrends() {
|
||||
String userId = userContextUtils.getCurrentUserId();
|
||||
String userId = UserContextUtils.getCurrentUserId();
|
||||
log.info("获取上传趋势: userId={}", userId);
|
||||
|
||||
Object trends = statisticsService.getUploadTrends(userId);
|
||||
@@ -56,7 +53,7 @@ public class StatisticsController {
|
||||
*/
|
||||
@GetMapping("/storage")
|
||||
public ResponseEntity<Object> getStorageBreakdown() {
|
||||
String userId = userContextUtils.getCurrentUserId();
|
||||
String userId = UserContextUtils.getCurrentUserId();
|
||||
log.info("获取存储分类: userId={}", userId);
|
||||
|
||||
Object breakdown = statisticsService.getStorageBreakdown(userId);
|
||||
@@ -69,7 +66,7 @@ public class StatisticsController {
|
||||
*/
|
||||
@PostMapping("/refresh")
|
||||
public ResponseEntity<Void> refreshStatistics() {
|
||||
String userId = userContextUtils.getCurrentUserId();
|
||||
String userId = UserContextUtils.getCurrentUserId();
|
||||
log.info("强制刷新统计数据: userId={}", userId);
|
||||
|
||||
statisticsService.refreshStatistics(userId);
|
||||
|
||||
Reference in New Issue
Block a user