new
Change-Id: I09ebe0fb4cefb34a94fb26d777363231b81cc2af
diff --git a/src/main/java/com/pt/entity/Download.java b/src/main/java/com/pt/entity/Download.java
index 38b955a..38c8de6 100644
--- a/src/main/java/com/pt/entity/Download.java
+++ b/src/main/java/com/pt/entity/Download.java
@@ -1,9 +1,6 @@
package com.pt.entity;
-import jakarta.persistence.Entity;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
-import jakarta.persistence.Id;
+import jakarta.persistence.*;
import java.time.LocalDateTime;
diff --git a/src/main/java/com/pt/entity/Resource.java b/src/main/java/com/pt/entity/Resource.java
index 9b7da39..0ac7321 100644
--- a/src/main/java/com/pt/entity/Resource.java
+++ b/src/main/java/com/pt/entity/Resource.java
@@ -23,6 +23,7 @@
private String description;
private byte[] torrentData;
+ private String info_hash;
public Resource() {
}
@@ -78,6 +79,14 @@
this.torrentData = torrentData;
}
+ public String getInfo_hash() {
+ return info_hash;
+ }
+
+ public void setInfo_hash(String info_hash) {
+ this.info_hash = info_hash;
+ }
+
/*
* 重写toString方法,将资源信息以JSON字符串形式返回
*/
diff --git a/src/main/java/com/pt/service/ResourceService.java b/src/main/java/com/pt/service/ResourceService.java
index d85315e..7d68817 100644
--- a/src/main/java/com/pt/service/ResourceService.java
+++ b/src/main/java/com/pt/service/ResourceService.java
@@ -48,6 +48,7 @@
resource.setPublishTime(LocalDateTime.now());
resource.setTorrentData(torrentBytes);
+ resource.setInfo_hash(meta.getInfoHash());
// 这里可以保存torrent文件路径,或直接存数据库,依据你的设计
resourceRepository.save(resource);
}