修改Tracker服务器相关bug
Change-Id: Id3ec61034575bd794724be98f832f8c065448b92
diff --git a/src/main/java/com/pt/entity/PeerInfoEntity.java b/src/main/java/com/pt/entity/PeerInfoEntity.java
index 56125cb..e2d89be 100644
--- a/src/main/java/com/pt/entity/PeerInfoEntity.java
+++ b/src/main/java/com/pt/entity/PeerInfoEntity.java
@@ -8,24 +8,26 @@
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
- private Long id;
+ private long id;
+
+ private String peerId;
private String infoHash;
private String ip;
private int port;
- private String peerId;
+
private LocalDateTime lastSeen;
// 新增状态字段
private String status; // "seeding", "downloading", "completed"
- private boolean isActive; // 是否活跃
+ private int isActive; // 是否活跃
// 下载字段
- private long uploaded; // 已上传量
- private long downloaded; // 已下载量
- private long left; // 剩余下载量
+ private long upload; // 已上传量
+ private long download; // 已下载量 // 剩余下载量
- private String username; // 添加用户名字段
+ @Column(name = "download_left")
+ private long left;
public PeerInfoEntity(String ipAddress, int port, String peerId) {
this.ip = ipAddress;
@@ -33,21 +35,19 @@
this.peerId = peerId;
this.lastSeen = LocalDateTime.now();
this.status = "downloading"; // 默认状态为下载中
- this.isActive = true; // 默认活跃状态
- this.uploaded = 0;
- this.downloaded = 0;
- this.left = 0;
+ this.isActive = 1; // 默认活跃状态
+ this.upload = 0;
+ this.download = 0;
}
public PeerInfoEntity() {
}
- public Long getId() {
+ public long getId() {
return id;
}
-
- public void setId(Long id) {
+ public void setId(long id) {
this.id = id;
}
@@ -56,27 +56,19 @@
}
public long getUploaded() {
- return uploaded;
+ return upload;
}
public void setUploaded(long uploaded) {
- this.uploaded = uploaded;
+ this.upload = uploaded;
}
public long getDownloaded() {
- return downloaded;
+ return download;
}
public void setDownloaded(long downloaded) {
- this.downloaded = downloaded;
- }
-
- public long getLeft() {
- return left;
- }
-
- public void setLeft(long left) {
- this.left = left;
+ this.download = downloaded;
}
public void setInfoHash(String infoHash) {
@@ -124,19 +116,27 @@
this.status = status;
}
- public boolean isActive() {
+ public int isActive() {
return isActive;
}
- public void setActive(boolean active) {
+ public void setActive(int active) {
isActive = active;
}
- public String getUsername() {
- return username;
+ public void setIsActive(int isActive) {
+ this.isActive = isActive;
}
- public void setUsername(String username) {
- this.username = username;
+ public int getIsActive() {
+ return isActive;
+ }
+
+ public long getLeft() {
+ return left;
+ }
+
+ public void setLeft(long left) {
+ this.left = left;
}
}
diff --git a/src/main/java/com/pt/entity/Resource.java b/src/main/java/com/pt/entity/Resource.java
index 0ac7321..073dbbb 100644
--- a/src/main/java/com/pt/entity/Resource.java
+++ b/src/main/java/com/pt/entity/Resource.java
@@ -15,7 +15,6 @@
private int resourceId;
private String name;
- private double size;
private LocalDateTime publishTime;
private String author;
@@ -23,14 +22,12 @@
private String description;
private byte[] torrentData;
- private String info_hash;
public Resource() {
}
- public Resource(int resourceId, String name, double size, LocalDateTime publishTime, String author) {
+ public Resource(int resourceId, String name, LocalDateTime publishTime, String author) {
this.resourceId = resourceId;
this.name = name;
- this.size = size;
this.publishTime = publishTime;
this.author = author;
}
@@ -47,12 +44,6 @@
public void setName(String name) {
this.name = name;
}
- public double getSize() {
- return size;
- }
- public void setSize(double size) {
- this.size = size;
- }
public LocalDateTime getPublishTime() {
return publishTime;
}
@@ -79,14 +70,6 @@
this.torrentData = torrentData;
}
- public String getInfo_hash() {
- return info_hash;
- }
-
- public void setInfo_hash(String info_hash) {
- this.info_hash = info_hash;
- }
-
/*
* 重写toString方法,将资源信息以JSON字符串形式返回
*/
@@ -95,7 +78,6 @@
return "{" +
"\"resourceId\":" + resourceId +
", \"name\":\"" + name + "\"" +
- ", \"size\":" + size +
", \"publishTime\":\"" + publishTime + "\"" +
", \"author\":\"" + author + "\"" +
", \"description\":\"" + description + "\"" +