blob: 0ac7321ef47d60f8e2dcb8fa645be52d8641c00b [file] [log] [blame]
22301102b1084372025-06-01 16:44:23 +08001package com.pt.entity;
2
3import jakarta.persistence.Entity;
4import jakarta.persistence.GeneratedValue;
5import jakarta.persistence.GenerationType;
6import jakarta.persistence.Id;
7
8import java.time.LocalDateTime;
9
10@Entity
11public class Resource {
12
13 @Id
14 @GeneratedValue(strategy = GenerationType.IDENTITY)
15 private int resourceId;
16
17 private String name;
18 private double size;
19
20 private LocalDateTime publishTime;
21 private String author;
22
23 private String description;
22301102bc6da0a2025-06-02 17:47:29 +080024 private byte[] torrentData;
22301102b1084372025-06-01 16:44:23 +080025
Edwardsamaxla78ad0a2025-06-09 21:17:29 +080026 private String info_hash;
22301102b1084372025-06-01 16:44:23 +080027 public Resource() {
28 }
29
30 public Resource(int resourceId, String name, double size, LocalDateTime publishTime, String author) {
31 this.resourceId = resourceId;
32 this.name = name;
33 this.size = size;
34 this.publishTime = publishTime;
35 this.author = author;
36 }
37
38 public int getResourceId() {
39 return resourceId;
40 }
41 public void setResourceId(int resourceId) {
42 this.resourceId = resourceId;
43 }
44 public String getName() {
45 return name;
46 }
47 public void setName(String name) {
48 this.name = name;
49 }
50 public double getSize() {
51 return size;
52 }
53 public void setSize(double size) {
54 this.size = size;
55 }
56 public LocalDateTime getPublishTime() {
57 return publishTime;
58 }
59 public void setPublishTime(LocalDateTime publishTime) {
60 this.publishTime = publishTime;
61 }
62 public String getAuthor() {
63 return author;
64 }
65 public void setAuthor(String author) {
66 this.author = author;
67 }
68 public String getDescription() {
69 return description;
70 }
71 public void setDescription(String description) {
72 this.description = description;
73 }
22301102bc6da0a2025-06-02 17:47:29 +080074 public byte[] getTorrentData() {
75 return torrentData;
76 }
77
78 public void setTorrentData(byte[] torrentData) {
79 this.torrentData = torrentData;
80 }
22301102b1084372025-06-01 16:44:23 +080081
Edwardsamaxla78ad0a2025-06-09 21:17:29 +080082 public String getInfo_hash() {
83 return info_hash;
84 }
85
86 public void setInfo_hash(String info_hash) {
87 this.info_hash = info_hash;
88 }
89
22301102b1084372025-06-01 16:44:23 +080090 /*
91 * 重写toString方法,将资源信息以JSON字符串形式返回
92 */
93 @Override
94 public String toString() {
95 return "{" +
96 "\"resourceId\":" + resourceId +
97 ", \"name\":\"" + name + "\"" +
98 ", \"size\":" + size +
99 ", \"publishTime\":\"" + publishTime + "\"" +
100 ", \"author\":\"" + author + "\"" +
101 ", \"description\":\"" + description + "\"" +
102 '}';
103 }
104}