blob: d99c4d03b0ce019203891e4d9268e009a042d0c7 [file] [log] [blame]
Krishyab0cc1882025-06-09 10:54:09 +08001package com.example.myproject.controller;
2
3import com.example.myproject.entity.TorrentEntity;
4import com.example.myproject.service.PopularSeedService;
5import com.example.myproject.service.RecommendationService;
6import io.swagger.annotations.Api;
7import io.swagger.annotations.ApiOperation;
8import io.swagger.annotations.ApiParam;
9import org.springframework.beans.factory.annotation.Autowired;
10import org.springframework.web.bind.annotation.*;
11
12import java.util.List;
13
14@RestController
15@RequestMapping("/echo/recommendation")
16@Api("推荐接口")
17public class RecommendationController {
18
19 @Autowired
20 private RecommendationService recommendationService;
21
22 @Autowired
23 private PopularSeedService popularSeedService;
24
25 @GetMapping("/seeds/{userId}")
26 @ApiOperation("获取基于内容的种子推荐")
27 public List<TorrentEntity> getRecommendedSeeds(@PathVariable Long userId) {
28 return recommendationService.getRecommendedSeeds(userId);
29 }
30
31 @GetMapping("/popular")
32 @ApiOperation("获取热门种子推荐")
33 public List<TorrentEntity> getPopularSeeds(
34 @ApiParam(value = "返回数量", defaultValue = "16")
35 @RequestParam(defaultValue = "16") int limit
36 ) {
37 return popularSeedService.getPopularSeeds(limit);
38 }
39}