blob: 175d96f7e654fb227619719a65e2e903f63734d7 [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;
22301102b1084372025-06-01 16:44:23 +080018
19 private LocalDateTime publishTime;
20 private String author;
21
22 private String description;
22301102bc6da0a2025-06-02 17:47:29 +080023 private byte[] torrentData;
22301102b1084372025-06-01 16:44:23 +080024
Edwardsamaxl25305242025-06-09 21:17:29 +080025 private String title;
26
22301102b1084372025-06-01 16:44:23 +080027 public Resource() {
28 }
29
Edwardsamaxlcba512d2025-06-09 21:17:29 +080030 public Resource(int resourceId, String name, LocalDateTime publishTime, String author) {
22301102b1084372025-06-01 16:44:23 +080031 this.resourceId = resourceId;
32 this.name = name;
22301102b1084372025-06-01 16:44:23 +080033 this.publishTime = publishTime;
34 this.author = author;
35 }
36
37 public int getResourceId() {
38 return resourceId;
39 }
40 public void setResourceId(int resourceId) {
41 this.resourceId = resourceId;
42 }
43 public String getName() {
44 return name;
45 }
46 public void setName(String name) {
47 this.name = name;
48 }
22301102b1084372025-06-01 16:44:23 +080049 public LocalDateTime getPublishTime() {
50 return publishTime;
51 }
52 public void setPublishTime(LocalDateTime publishTime) {
53 this.publishTime = publishTime;
54 }
55 public String getAuthor() {
56 return author;
57 }
58 public void setAuthor(String author) {
59 this.author = author;
60 }
61 public String getDescription() {
62 return description;
63 }
64 public void setDescription(String description) {
65 this.description = description;
66 }
22301102bc6da0a2025-06-02 17:47:29 +080067 public byte[] getTorrentData() {
68 return torrentData;
69 }
70
71 public void setTorrentData(byte[] torrentData) {
72 this.torrentData = torrentData;
73 }
Edwardsamaxl25305242025-06-09 21:17:29 +080074 public String getTitle() {
75 return title;
76 }
77 public void setTitle(String title) {
78 this.title = title;
79 }
22301102b1084372025-06-01 16:44:23 +080080
22301102b1084372025-06-01 16:44:23 +080081 /*
82 * 重写toString方法,将资源信息以JSON字符串形式返回
83 */
84 @Override
85 public String toString() {
86 return "{" +
87 "\"resourceId\":" + resourceId +
88 ", \"name\":\"" + name + "\"" +
22301102b1084372025-06-01 16:44:23 +080089 ", \"publishTime\":\"" + publishTime + "\"" +
90 ", \"author\":\"" + author + "\"" +
91 ", \"description\":\"" + description + "\"" +
Edwardsamaxl25305242025-06-09 21:17:29 +080092 ", \"title\":\"" + title + "\"" +
22301102b1084372025-06-01 16:44:23 +080093 '}';
94 }
95}