完成部分帖子相关功能,同时完善了一些用户功能
Change-Id: Ie9d22bcceec197930d48f578d8b9a749ce7a3382
diff --git a/src/main/java/com/pt/entity/Admin.java b/src/main/java/com/pt/entity/Admin.java
new file mode 100644
index 0000000..856924d
--- /dev/null
+++ b/src/main/java/com/pt/entity/Admin.java
@@ -0,0 +1,46 @@
+package com.pt.entity;
+
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+
+@Entity
+public class Admin {
+
+ @Id
+ private String id;
+
+ private String username;
+ private String password;
+
+ public Admin() {
+ }
+ public Admin(String id, String username, String password) {
+ this.id = id;
+ this.username = username;
+ this.password = password;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String adminId) {
+ this.id = adminId;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+}
diff --git a/src/main/java/com/pt/entity/Post.java b/src/main/java/com/pt/entity/Post.java
new file mode 100644
index 0000000..ef36c5c
--- /dev/null
+++ b/src/main/java/com/pt/entity/Post.java
@@ -0,0 +1,71 @@
+package com.pt.entity;
+
+import jakarta.persistence.Entity;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.GenerationType;
+import jakarta.persistence.Id;
+
+import java.time.LocalDate;
+
+@Entity
+public class Post {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private int pid;
+
+ private String title;
+ private String content;
+ private String author;
+ private LocalDate publishDate;
+
+ public Post() {
+ }
+
+ public Post(String title, String content, String author) {
+ this.title = title;
+ this.content = content;
+ this.author = author;
+ this.publishDate = LocalDate.now();
+ }
+
+ public int getPid() {
+ return pid;
+ }
+
+ public void setPid(int pid) {
+ this.pid = pid;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+ public String getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
+ public LocalDate getPublishDate() {
+ return publishDate;
+ }
+
+ public void setPublishDate(LocalDate publishDate) {
+ this.publishDate = publishDate;
+ }
+}
diff --git a/src/main/java/com/pt/entity/User.java b/src/main/java/com/pt/entity/User.java
index a2f462d..9caab3e 100644
--- a/src/main/java/com/pt/entity/User.java
+++ b/src/main/java/com/pt/entity/User.java
@@ -60,4 +60,16 @@
public void setPoints(int points) {
this.points = points;
}
+
+ @Override
+ public String toString() {
+ return "{" +
+ "uid:'" + uid + '\'' +
+ ",\nusername:'" + username + '\'' +
+ ",\npassword:'" + password + '\'' +
+ ",\nemail:'" + email + '\'' +
+ ",\nlevel:" + level +
+ ",\npoints:" + points +
+ '}';
+ }
}