blob: 63e4c722de85fab1cb6fd7305dc3e5d3face20b0 [file] [log] [blame]
ystx89bd5442025-06-07 19:35:27 +08001package com.pt.controller;
2
3import com.pt.entity.TorrentStats;
4import com.pt.service.TorrentStatsService;
5import org.springframework.beans.factory.annotation.Autowired;
6import org.springframework.web.bind.annotation.*;
7
8import java.util.List;
9
10@RestController
11@RequestMapping("/api/stats")
12public class TorrentStatsController {
13
14 @Autowired
15 private TorrentStatsService statsService;
16
17 // 1. 获取单个种子统计
18 @GetMapping("/{torrentId}")
19 public TorrentStats getStats(@PathVariable Long torrentId) {
20 return statsService.getTorrentStats(torrentId);
21 }
22
23 // 2. 获取热门种子(做种人数TOP N)
24 @GetMapping("/top-seeded")
25 public List<TorrentStats> getTopSeeded(
26 @RequestParam(defaultValue = "10") int limit) {
27 return statsService.getTopSeededTorrents(limit);
28 }
29
30 // 3. 获取最近活跃种子
31 @GetMapping("/recent-active")
32 public List<TorrentStats> getRecentActive(
33 @RequestParam(defaultValue = "10") int limit) {
34 return statsService.getRecentActiveTorrents(limit);
35 }
36
37 // 4. 批量获取统计信息
38 @PostMapping("/batch")
39 public List<TorrentStats> getBatchStats(@RequestBody List<Long> torrentIds) {
40 return statsService.getBatchStats(torrentIds);
41 }
42}