22301102 | b108437 | 2025-06-01 16:44:23 +0800 | [diff] [blame] | 1 | package com.pt.entity; |
| 2 | |
| 3 | import jakarta.persistence.Entity; |
| 4 | import jakarta.persistence.GeneratedValue; |
| 5 | import jakarta.persistence.GenerationType; |
| 6 | import jakarta.persistence.Id; |
| 7 | |
| 8 | import java.time.LocalDateTime; |
| 9 | |
| 10 | @Entity |
| 11 | public class Resource { |
| 12 | |
| 13 | @Id |
| 14 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
| 15 | private int resourceId; |
| 16 | |
| 17 | private String name; |
22301102 | b108437 | 2025-06-01 16:44:23 +0800 | [diff] [blame] | 18 | |
| 19 | private LocalDateTime publishTime; |
| 20 | private String author; |
| 21 | |
| 22 | private String description; |
22301102 | bc6da0a | 2025-06-02 17:47:29 +0800 | [diff] [blame] | 23 | private byte[] torrentData; |
22301102 | b108437 | 2025-06-01 16:44:23 +0800 | [diff] [blame] | 24 | |
| 25 | public Resource() { |
| 26 | } |
| 27 | |
Edwardsamaxl | cba512d | 2025-06-09 21:17:29 +0800 | [diff] [blame^] | 28 | public Resource(int resourceId, String name, LocalDateTime publishTime, String author) { |
22301102 | b108437 | 2025-06-01 16:44:23 +0800 | [diff] [blame] | 29 | this.resourceId = resourceId; |
| 30 | this.name = name; |
22301102 | b108437 | 2025-06-01 16:44:23 +0800 | [diff] [blame] | 31 | 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 | } |
22301102 | b108437 | 2025-06-01 16:44:23 +0800 | [diff] [blame] | 47 | 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 | } |
22301102 | bc6da0a | 2025-06-02 17:47:29 +0800 | [diff] [blame] | 65 | public byte[] getTorrentData() { |
| 66 | return torrentData; |
| 67 | } |
| 68 | |
| 69 | public void setTorrentData(byte[] torrentData) { |
| 70 | this.torrentData = torrentData; |
| 71 | } |
22301102 | b108437 | 2025-06-01 16:44:23 +0800 | [diff] [blame] | 72 | |
22301102 | b108437 | 2025-06-01 16:44:23 +0800 | [diff] [blame] | 73 | /* |
| 74 | * 重写toString方法,将资源信息以JSON字符串形式返回 |
| 75 | */ |
| 76 | @Override |
| 77 | public String toString() { |
| 78 | return "{" + |
| 79 | "\"resourceId\":" + resourceId + |
| 80 | ", \"name\":\"" + name + "\"" + |
22301102 | b108437 | 2025-06-01 16:44:23 +0800 | [diff] [blame] | 81 | ", \"publishTime\":\"" + publishTime + "\"" + |
| 82 | ", \"author\":\"" + author + "\"" + |
| 83 | ", \"description\":\"" + description + "\"" + |
| 84 | '}'; |
| 85 | } |
| 86 | } |