最终修改

Change-Id: If5f00df9d18bd7d61c8fb08fb25a89043a43139f
diff --git a/src/main/java/com/pt/controller/ResourceController.java b/src/main/java/com/pt/controller/ResourceController.java
index c663963..77033be 100644
--- a/src/main/java/com/pt/controller/ResourceController.java
+++ b/src/main/java/com/pt/controller/ResourceController.java
@@ -84,6 +84,7 @@
     public ResponseEntity<?> publishResource(
             @RequestHeader("token") String token,
             @RequestParam("username") String username,
+            @RequestParam("title") String title,
             @RequestParam("description") String description,
             @RequestParam("torrent") MultipartFile torrentFile
             )
@@ -104,7 +105,7 @@
 
         try {
             // 传入种子文件字节,同时传入资源其他信息
-            resourceService.publishResource(torrentFile.getOriginalFilename(), description, username, torrentFile.getBytes(), username);
+            resourceService.publishResource(torrentFile.getOriginalFilename(), title, description, username, torrentFile.getBytes(), username);
         } catch (Exception e) {
             ans.put("message", "Failed to publish resource: " + e.getMessage());
             return ResponseEntity.status(500).body(ans);
@@ -137,7 +138,8 @@
                 "name", resource.getName(),
                 "description", resource.getDescription(),
                 "author", resource.getAuthor(),
-                "publishTime", resource.getPublishTime()
+                "publishTime", resource.getPublishTime(),
+                "title", resource.getTitle()
         ));
 
         return ResponseEntity.ok().body(ans);
diff --git a/src/main/java/com/pt/controller/UserController.java b/src/main/java/com/pt/controller/UserController.java
index d9f53ab..4cadd75 100644
--- a/src/main/java/com/pt/controller/UserController.java
+++ b/src/main/java/com/pt/controller/UserController.java
@@ -83,7 +83,10 @@
                     "username", user.getUsername(),
                     "email", user.getEmail(),
                     "level", user.getLevel(),
-                    "points", user.getPoints()
+                    "points", user.getPoints(),
+                    "uploaded", user.getUploaded(),
+                    "downloaded", user.getDownloaded(),
+                    "shareRatio", user.getShareRatio()
             ));
             return ResponseEntity.ok().body(ans);
         } else {
diff --git a/src/main/java/com/pt/entity/Resource.java b/src/main/java/com/pt/entity/Resource.java
index 073dbbb..175d96f 100644
--- a/src/main/java/com/pt/entity/Resource.java
+++ b/src/main/java/com/pt/entity/Resource.java
@@ -22,6 +22,8 @@
     private String description;
     private byte[] torrentData;
 
+    private String title;
+
     public Resource() {
     }
 
@@ -69,6 +71,12 @@
     public void setTorrentData(byte[] torrentData) {
         this.torrentData = torrentData;
     }
+    public String getTitle() {
+        return title;
+    }
+    public void setTitle(String title) {
+        this.title = title;
+    }
 
     /*
         * 重写toString方法,将资源信息以JSON字符串形式返回
@@ -81,6 +89,7 @@
                 ", \"publishTime\":\"" + publishTime + "\"" +
                 ", \"author\":\"" + author + "\"" +
                 ", \"description\":\"" + description + "\"" +
+                ", \"title\":\"" + title + "\"" +
                 '}';
     }
 }
diff --git a/src/main/java/com/pt/entity/User.java b/src/main/java/com/pt/entity/User.java
index bc3a488..029595d 100644
--- a/src/main/java/com/pt/entity/User.java
+++ b/src/main/java/com/pt/entity/User.java
@@ -81,10 +81,7 @@
     }
 
     public double getShareRatio() {
-        if (downloaded == 0) {
-            return 0;
-        }
-        return (double) uploaded / downloaded;
+        return shareRatio;
     }
 
     public void setShareRatio(double shareRatio) {
@@ -102,6 +99,7 @@
                 ",\npoints:" + points +
                 ",\nuploaded:" + uploaded +
                 ",\ndownloaded:" + downloaded +
+                ",\nshareRatio:" + shareRatio +
                 '}';
     }
 }
diff --git a/src/main/java/com/pt/service/ResourceService.java b/src/main/java/com/pt/service/ResourceService.java
index 4eb7823..3d06d85 100644
--- a/src/main/java/com/pt/service/ResourceService.java
+++ b/src/main/java/com/pt/service/ResourceService.java
@@ -41,7 +41,7 @@
         return resourceRepository.findByAuthor(username);
     }
 
-    public void publishResource(String name, String description, String author, byte[] torrentBytes, String username) throws Exception {
+    public void publishResource(String name, String title, String description, String author, byte[] torrentBytes, String username) throws Exception {
         // 解析并保存torrent元信息
         TorrentMeta meta = torrentService.parseAndSaveTorrent(torrentBytes);
 
@@ -51,6 +51,7 @@
         resource.setDescription(description);
         resource.setAuthor(author);
         resource.setPublishTime(LocalDateTime.now());
+        resource.setTitle(title);
 
         resource.setTorrentData(torrentBytes);
         // 这里可以保存torrent文件路径,或直接存数据库,依据你的设计