Krishya | b0cc188 | 2025-06-09 10:54:09 +0800 | [diff] [blame^] | 1 | package com.example.myproject.controller; |
| 2 | |
| 3 | import com.example.myproject.entity.TorrentEntity; |
| 4 | import com.example.myproject.service.PopularSeedService; |
| 5 | import com.example.myproject.service.RecommendationService; |
| 6 | import io.swagger.annotations.Api; |
| 7 | import io.swagger.annotations.ApiOperation; |
| 8 | import io.swagger.annotations.ApiParam; |
| 9 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | import org.springframework.web.bind.annotation.*; |
| 11 | |
| 12 | import java.util.List; |
| 13 | |
| 14 | @RestController |
| 15 | @RequestMapping("/echo/recommendation") |
| 16 | @Api("推荐接口") |
| 17 | public 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 | } |