blob: 56125cbd6b10ad8bedab9c18db41973159fd455e [file] [log] [blame]
Edwardsamaxlf1bf7ad2025-06-03 23:52:16 +08001package com.pt.entity;
2
3import jakarta.persistence.*;
4import java.time.LocalDateTime;
5
6@Entity
7public class PeerInfoEntity {
8
9 @Id
10 @GeneratedValue(strategy = GenerationType.IDENTITY)
11 private Long id;
12
13 private String infoHash;
14 private String ip;
15 private int port;
16 private String peerId;
17 private LocalDateTime lastSeen;
18
ystxdfd42b32025-06-07 13:26:52 +080019 // 新增状态字段
20 private String status; // "seeding", "downloading", "completed"
21 private boolean isActive; // 是否活跃
22
23 // 下载字段
24 private long uploaded; // 已上传量
25 private long downloaded; // 已下载量
26 private long left; // 剩余下载量
27
22301102f5670302025-06-08 14:10:02 +080028 private String username; // 添加用户名字段
29
22301102ca0fb2f2025-06-09 18:40:42 +080030 public PeerInfoEntity(String ipAddress, int port, String peerId) {
31 this.ip = ipAddress;
32 this.port = port;
33 this.peerId = peerId;
34 this.lastSeen = LocalDateTime.now();
35 this.status = "downloading"; // 默认状态为下载中
36 this.isActive = true; // 默认活跃状态
37 this.uploaded = 0;
38 this.downloaded = 0;
39 this.left = 0;
40 }
41
42 public PeerInfoEntity() {
43
44 }
45
Edwardsamaxlf1bf7ad2025-06-03 23:52:16 +080046 public Long getId() {
47 return id;
48 }
49
50 public void setId(Long id) {
51 this.id = id;
52 }
53
54 public String getInfoHash() {
55 return infoHash;
56 }
57
ystxdfd42b32025-06-07 13:26:52 +080058 public long getUploaded() {
59 return uploaded;
60 }
61
62 public void setUploaded(long uploaded) {
63 this.uploaded = uploaded;
64 }
65
66 public long getDownloaded() {
67 return downloaded;
68 }
69
70 public void setDownloaded(long downloaded) {
71 this.downloaded = downloaded;
72 }
73
74 public long getLeft() {
75 return left;
76 }
77
78 public void setLeft(long left) {
79 this.left = left;
80 }
81
Edwardsamaxlf1bf7ad2025-06-03 23:52:16 +080082 public void setInfoHash(String infoHash) {
83 this.infoHash = infoHash;
84 }
85
86 public String getIp() {
87 return ip;
88 }
89
90 public void setIp(String ip) {
91 this.ip = ip;
92 }
93
94 public int getPort() {
95 return port;
96 }
97
98 public void setPort(int port) {
99 this.port = port;
100 }
101
102 public LocalDateTime getLastSeen() {
103 return lastSeen;
104 }
105
106 public void setLastSeen(LocalDateTime lastSeen) {
107 this.lastSeen = lastSeen;
108 }
109
110 public String getPeerId() {
111 return peerId;
112 }
113
114 public void setPeerId(String peerId) {
115 this.peerId = peerId;
116 }
ystxdfd42b32025-06-07 13:26:52 +0800117
118 // 新增状态字段的getter与setter
119 public String getStatus() {
120 return status;
121 }
122
123 public void setStatus(String status) {
124 this.status = status;
125 }
126
127 public boolean isActive() {
128 return isActive;
129 }
130
131 public void setActive(boolean active) {
132 isActive = active;
133 }
22301102f5670302025-06-08 14:10:02 +0800134
135 public String getUsername() {
136 return username;
137 }
138
139 public void setUsername(String username) {
140 this.username = username;
141 }
Edwardsamaxlf1bf7ad2025-06-03 23:52:16 +0800142}