blob: e2d89be7ee12c5ee2c9df1bc3e8bc4e13ef3ce2e [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)
Edwardsamaxlcba512d2025-06-09 21:17:29 +080011 private long id;
12
13 private String peerId;
Edwardsamaxlf1bf7ad2025-06-03 23:52:16 +080014
15 private String infoHash;
16 private String ip;
17 private int port;
Edwardsamaxlcba512d2025-06-09 21:17:29 +080018
Edwardsamaxlf1bf7ad2025-06-03 23:52:16 +080019 private LocalDateTime lastSeen;
20
ystxdfd42b32025-06-07 13:26:52 +080021 // 新增状态字段
22 private String status; // "seeding", "downloading", "completed"
Edwardsamaxlcba512d2025-06-09 21:17:29 +080023 private int isActive; // 是否活跃
ystxdfd42b32025-06-07 13:26:52 +080024
25 // 下载字段
Edwardsamaxlcba512d2025-06-09 21:17:29 +080026 private long upload; // 已上传量
27 private long download; // 已下载量 // 剩余下载量
ystxdfd42b32025-06-07 13:26:52 +080028
Edwardsamaxlcba512d2025-06-09 21:17:29 +080029 @Column(name = "download_left")
30 private long left;
22301102f5670302025-06-08 14:10:02 +080031
22301102ca0fb2f2025-06-09 18:40:42 +080032 public PeerInfoEntity(String ipAddress, int port, String peerId) {
33 this.ip = ipAddress;
34 this.port = port;
35 this.peerId = peerId;
36 this.lastSeen = LocalDateTime.now();
37 this.status = "downloading"; // 默认状态为下载中
Edwardsamaxlcba512d2025-06-09 21:17:29 +080038 this.isActive = 1; // 默认活跃状态
39 this.upload = 0;
40 this.download = 0;
22301102ca0fb2f2025-06-09 18:40:42 +080041 }
42
43 public PeerInfoEntity() {
44
45 }
46
Edwardsamaxlcba512d2025-06-09 21:17:29 +080047 public long getId() {
Edwardsamaxlf1bf7ad2025-06-03 23:52:16 +080048 return id;
49 }
Edwardsamaxlcba512d2025-06-09 21:17:29 +080050 public void setId(long id) {
Edwardsamaxlf1bf7ad2025-06-03 23:52:16 +080051 this.id = id;
52 }
53
54 public String getInfoHash() {
55 return infoHash;
56 }
57
ystxdfd42b32025-06-07 13:26:52 +080058 public long getUploaded() {
Edwardsamaxlcba512d2025-06-09 21:17:29 +080059 return upload;
ystxdfd42b32025-06-07 13:26:52 +080060 }
61
62 public void setUploaded(long uploaded) {
Edwardsamaxlcba512d2025-06-09 21:17:29 +080063 this.upload = uploaded;
ystxdfd42b32025-06-07 13:26:52 +080064 }
65
66 public long getDownloaded() {
Edwardsamaxlcba512d2025-06-09 21:17:29 +080067 return download;
ystxdfd42b32025-06-07 13:26:52 +080068 }
69
70 public void setDownloaded(long downloaded) {
Edwardsamaxlcba512d2025-06-09 21:17:29 +080071 this.download = downloaded;
ystxdfd42b32025-06-07 13:26:52 +080072 }
73
Edwardsamaxlf1bf7ad2025-06-03 23:52:16 +080074 public void setInfoHash(String infoHash) {
75 this.infoHash = infoHash;
76 }
77
78 public String getIp() {
79 return ip;
80 }
81
82 public void setIp(String ip) {
83 this.ip = ip;
84 }
85
86 public int getPort() {
87 return port;
88 }
89
90 public void setPort(int port) {
91 this.port = port;
92 }
93
94 public LocalDateTime getLastSeen() {
95 return lastSeen;
96 }
97
98 public void setLastSeen(LocalDateTime lastSeen) {
99 this.lastSeen = lastSeen;
100 }
101
102 public String getPeerId() {
103 return peerId;
104 }
105
106 public void setPeerId(String peerId) {
107 this.peerId = peerId;
108 }
ystxdfd42b32025-06-07 13:26:52 +0800109
110 // 新增状态字段的getter与setter
111 public String getStatus() {
112 return status;
113 }
114
115 public void setStatus(String status) {
116 this.status = status;
117 }
118
Edwardsamaxlcba512d2025-06-09 21:17:29 +0800119 public int isActive() {
ystxdfd42b32025-06-07 13:26:52 +0800120 return isActive;
121 }
122
Edwardsamaxlcba512d2025-06-09 21:17:29 +0800123 public void setActive(int active) {
ystxdfd42b32025-06-07 13:26:52 +0800124 isActive = active;
125 }
22301102f5670302025-06-08 14:10:02 +0800126
Edwardsamaxlcba512d2025-06-09 21:17:29 +0800127 public void setIsActive(int isActive) {
128 this.isActive = isActive;
22301102f5670302025-06-08 14:10:02 +0800129 }
130
Edwardsamaxlcba512d2025-06-09 21:17:29 +0800131 public int getIsActive() {
132 return isActive;
133 }
134
135 public long getLeft() {
136 return left;
137 }
138
139 public void setLeft(long left) {
140 this.left = left;
22301102f5670302025-06-08 14:10:02 +0800141 }
Edwardsamaxlf1bf7ad2025-06-03 23:52:16 +0800142}