root | d4959a8 | 2025-05-27 07:07:37 +0000 | [diff] [blame^] | 1 | package entity; |
| 2 | |
| 3 | import java.time.LocalDateTime; |
| 4 | |
| 5 | import javax.persistence.Column; |
| 6 | import javax.persistence.Entity; |
| 7 | import javax.persistence.Id; |
| 8 | import javax.persistence.Table; |
| 9 | |
| 10 | @Entity |
| 11 | @Table(name = "SeedDownload") |
| 12 | public class SeedDownload { |
| 13 | |
| 14 | @Id |
| 15 | @Column(name = "task_id", length = 64, nullable = false) |
| 16 | public String taskId; |
| 17 | |
| 18 | @Column(name = "user_id", length = 36, nullable = false) |
| 19 | public String userId; |
| 20 | |
| 21 | @Column(name = "seed_id", length = 64, nullable = false) |
| 22 | public String seedId; |
| 23 | |
| 24 | @Column(name = "download_start", nullable = false) |
| 25 | public LocalDateTime downloadStart; |
| 26 | |
| 27 | @Column(name = "download_end") |
| 28 | public LocalDateTime downloadEnd; |
| 29 | |
| 30 | @Column(name = "is_dedicated", nullable = false) |
| 31 | public boolean isDedicated; |
| 32 | |
| 33 | @Column(name = "client_ip", length = 45) |
| 34 | public String clientIp; |
| 35 | |
| 36 | // Constructors |
| 37 | public SeedDownload() {} |
| 38 | |
| 39 | public SeedDownload(String taskId, String userId, String seedId, LocalDateTime downloadStart, LocalDateTime downloadEnd, boolean isDedicated, String clientIp) { |
| 40 | this.taskId = taskId; |
| 41 | this.userId = userId; |
| 42 | this.seedId = seedId; |
| 43 | this.downloadStart = downloadStart; |
| 44 | this.downloadEnd = downloadEnd; |
| 45 | this.isDedicated = isDedicated; |
| 46 | this.clientIp = clientIp; |
| 47 | } |
| 48 | |
| 49 | // Getters and Setters |
| 50 | public String getTaskId() { |
| 51 | return taskId; |
| 52 | } |
| 53 | |
| 54 | public void setTaskId(String taskId) { |
| 55 | this.taskId = taskId; |
| 56 | } |
| 57 | |
| 58 | public String getUserId() { |
| 59 | return userId; |
| 60 | } |
| 61 | |
| 62 | public void setUserId(String userId) { |
| 63 | this.userId = userId; |
| 64 | } |
| 65 | |
| 66 | public String getSeedId() { |
| 67 | return seedId; |
| 68 | } |
| 69 | |
| 70 | public void setSeedId(String seedId) { |
| 71 | this.seedId = seedId; |
| 72 | } |
| 73 | |
| 74 | public LocalDateTime getDownloadStart() { |
| 75 | return downloadStart; |
| 76 | } |
| 77 | |
| 78 | public void setDownloadStart(LocalDateTime downloadStart) { |
| 79 | this.downloadStart = downloadStart; |
| 80 | } |
| 81 | |
| 82 | public LocalDateTime getDownloadEnd() { |
| 83 | return downloadEnd; |
| 84 | } |
| 85 | |
| 86 | public void setDownloadEnd(LocalDateTime downloadEnd) { |
| 87 | this.downloadEnd = downloadEnd; |
| 88 | } |
| 89 | |
| 90 | public boolean isDedicated() { |
| 91 | return isDedicated; |
| 92 | } |
| 93 | |
| 94 | public void setDedicated(boolean dedicated) { |
| 95 | isDedicated = dedicated; |
| 96 | } |
| 97 | |
| 98 | public String getClientIp() { |
| 99 | return clientIp; |
| 100 | } |
| 101 | |
| 102 | public void setClientIp(String clientIp) { |
| 103 | this.clientIp = clientIp; |
| 104 | } |
| 105 | |
| 106 | // equals and hashCode based on taskId |
| 107 | @Override |
| 108 | public boolean equals(Object o) { |
| 109 | if (this == o) return true; |
| 110 | if (!(o instanceof SeedDownload)) return false; |
| 111 | SeedDownload that = (SeedDownload) o; |
| 112 | return taskId != null && taskId.equals(that.taskId); |
| 113 | } |
| 114 | |
| 115 | @Override |
| 116 | public int hashCode() { |
| 117 | return 31 + (taskId != null ? taskId.hashCode() : 0); |
| 118 | } |
| 119 | } |