查看冷门资源

Change-Id: Idb875bd6ff4c6dba3cc40cf6ef298731b526c1a7
diff --git a/src/main/java/com/example/myproject/controller/PromotionController.java b/src/main/java/com/example/myproject/controller/PromotionController.java
index ab6efe7..ed90bf7 100644
--- a/src/main/java/com/example/myproject/controller/PromotionController.java
+++ b/src/main/java/com/example/myproject/controller/PromotionController.java
@@ -5,7 +5,9 @@
 import com.example.myproject.common.base.Result;
 import com.example.myproject.dto.PromotionCreateDTO;
 import com.example.myproject.dto.TorrentUpdateDTO;
+import com.example.myproject.dto.vo.TorrentVO;
 import com.example.myproject.entity.Promotion;
+import com.example.myproject.entity.TorrentEntity;
 import com.example.myproject.service.PromotionService;
 import com.example.myproject.service.TorrentService;
 import com.example.myproject.service.UserService;
@@ -138,4 +140,17 @@
             return Result.error("删除促销失败: " + e.getMessage());
         }
     }
+    @SaCheckLogin
+    @Operation(summary = "查看冷门资源")
+    @GetMapping("/cold")
+    public Result getColdResources() {
+        try {
+            List<TorrentEntity> coldList = torrentService.getColdTorrents(10); // 例如 views < 10
+            return Result.ok(coldList);
+        } catch (Exception e) {
+            return Result.error("获取冷门资源失败: " + e.getMessage());
+        }
+    }
+
+
 }
diff --git a/src/main/java/com/example/myproject/controller/TorrentController.java b/src/main/java/com/example/myproject/controller/TorrentController.java
index 4ce3eca..fd79757 100644
--- a/src/main/java/com/example/myproject/controller/TorrentController.java
+++ b/src/main/java/com/example/myproject/controller/TorrentController.java
@@ -96,6 +96,7 @@
         return Result.ok(list, PageUtil.getPage(list));
     }
 
+
     @SaCheckLogin
     @Operation(summary = "种子详情查询")
     @ApiResponse(responseCode = "0", description = "操作成功", content = {
@@ -104,8 +105,10 @@
     })
     @PostMapping("/info/{id}")
     public Result info(@PathVariable("id")Long id) {
-
-        TorrentEntity entity = torrentService.selectBySeedId(id);
+        TorrentEntity entity = torrentService.selectBySeedIdAndIncrementViews(id);
+        if (entity == null) {
+            return Result.error("未找到该种子");
+        }
         return Result.ok(entity);
     }
 
@@ -264,7 +267,6 @@
              * 作弊检测——下载速度检测
              */
 
-
             TorrentReport report = TorrentReport.builder()
                     .userId(userId)
                     .torrentId(torrent.getId())