blob: 073dbbba838e688aa9eb70cb9343aa0272c2e738 [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
25 public Resource() {
26 }
27
Edwardsamaxlcba512d2025-06-09 21:17:29 +080028 public Resource(int resourceId, String name, LocalDateTime publishTime, String author) {
22301102b1084372025-06-01 16:44:23 +080029 this.resourceId = resourceId;
30 this.name = name;
22301102b1084372025-06-01 16:44:23 +080031 this.publishTime = publishTime;
32 this.author = author;
33 }
34
35 public int getResourceId() {
36 return resourceId;
37 }
38 public void setResourceId(int resourceId) {
39 this.resourceId = resourceId;
40 }
41 public String getName() {
42 return name;
43 }
44 public void setName(String name) {
45 this.name = name;
46 }
22301102b1084372025-06-01 16:44:23 +080047 public LocalDateTime getPublishTime() {
48 return publishTime;
49 }
50 public void setPublishTime(LocalDateTime publishTime) {
51 this.publishTime = publishTime;
52 }
53 public String getAuthor() {
54 return author;
55 }
56 public void setAuthor(String author) {
57 this.author = author;
58 }
59 public String getDescription() {
60 return description;
61 }
62 public void setDescription(String description) {
63 this.description = description;
64 }
22301102bc6da0a2025-06-02 17:47:29 +080065 public byte[] getTorrentData() {
66 return torrentData;
67 }
68
69 public void setTorrentData(byte[] torrentData) {
70 this.torrentData = torrentData;
71 }
22301102b1084372025-06-01 16:44:23 +080072
22301102b1084372025-06-01 16:44:23 +080073 /*
74 * 重写toString方法,将资源信息以JSON字符串形式返回
75 */
76 @Override
77 public String toString() {
78 return "{" +
79 "\"resourceId\":" + resourceId +
80 ", \"name\":\"" + name + "\"" +
22301102b1084372025-06-01 16:44:23 +080081 ", \"publishTime\":\"" + publishTime + "\"" +
82 ", \"author\":\"" + author + "\"" +
83 ", \"description\":\"" + description + "\"" +
84 '}';
85 }
86}