diff --git a/src/main/java/com/codesdream/ase/model/file/Image.java b/src/main/java/com/codesdream/ase/model/file/Image.java new file mode 100644 index 0000000..2b5e6f5 --- /dev/null +++ b/src/main/java/com/codesdream/ase/model/file/Image.java @@ -0,0 +1,15 @@ +package com.codesdream.ase.model.file; + +import javax.persistence.*; + +@Entity +@Table +public class Image { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + int id; + + byte[] data; + + String description; +} diff --git a/src/main/java/com/codesdream/ase/model/mark/Tag.java b/src/main/java/com/codesdream/ase/model/mark/Tag.java new file mode 100644 index 0000000..7185205 --- /dev/null +++ b/src/main/java/com/codesdream/ase/model/mark/Tag.java @@ -0,0 +1,14 @@ +package com.codesdream.ase.model.mark; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table +public class Tag { + @Id + int id; + + String tagName; +} diff --git a/src/main/java/com/codesdream/ase/model/permission/User.java b/src/main/java/com/codesdream/ase/model/permission/User.java index a8d8326..5c43149 100644 --- a/src/main/java/com/codesdream/ase/model/permission/User.java +++ b/src/main/java/com/codesdream/ase/model/permission/User.java @@ -1,14 +1,12 @@ package com.codesdream.ase.model.permission; +import com.codesdream.ase.model.mark.Tag; import lombok.Data; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; import javax.persistence.*; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; +import java.util.*; @Data @Entity @@ -53,6 +51,9 @@ public class User implements UserDetails { @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) private UserAuth userAuth; + @ManyToMany(cascade = CascadeType.MERGE) + List tags; + public User(String username, String password) { this.username = username; diff --git a/src/main/java/com/codesdream/ase/model/student/Comment.java b/src/main/java/com/codesdream/ase/model/student/Comment.java new file mode 100644 index 0000000..c91a476 --- /dev/null +++ b/src/main/java/com/codesdream/ase/model/student/Comment.java @@ -0,0 +1,17 @@ +package com.codesdream.ase.model.student; + +import javax.persistence.*; + +@Entity +@Table +public class Comment { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + int id; + + // 发出此评论的用户 + int userId; + + // 评论内容 + String context; +} diff --git a/src/main/java/com/codesdream/ase/model/student/Honor.java b/src/main/java/com/codesdream/ase/model/student/Honor.java new file mode 100644 index 0000000..cd328cd --- /dev/null +++ b/src/main/java/com/codesdream/ase/model/student/Honor.java @@ -0,0 +1,28 @@ +package com.codesdream.ase.model.student; + +import com.codesdream.ase.model.file.Image; + +import javax.persistence.*; +import java.util.Date; +import java.util.List; + +@Entity +@Table +public class Honor { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + int id; + + // 荣誉描述 + String description; + + // 证明材料 + @OneToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY) + List images; + + // 创建时间 + Date creationDate; + + // 上一次修改时间 + Date lastModification; +} diff --git a/src/main/java/com/codesdream/ase/model/student/Moment.java b/src/main/java/com/codesdream/ase/model/student/Moment.java new file mode 100644 index 0000000..7fcfe90 --- /dev/null +++ b/src/main/java/com/codesdream/ase/model/student/Moment.java @@ -0,0 +1,31 @@ +package com.codesdream.ase.model.student; + +import com.codesdream.ase.model.file.Image; + +import javax.persistence.*; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; + +// 动态/说说 +@Entity +@Table +public class Moment { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + int id; + + int userId; + // 动态内容 + String description; + + // 点赞计数 + AtomicInteger likeCount = new AtomicInteger(0); + + // 评论 + @OneToMany(cascade = CascadeType.ALL) + List comments = new ArrayList<>(); + + @OneToMany(cascade = CascadeType.MERGE) + List images = new ArrayList<>(); +} \ No newline at end of file diff --git a/src/main/java/com/codesdream/ase/model/student/Notification.java b/src/main/java/com/codesdream/ase/model/student/Notification.java new file mode 100644 index 0000000..761d1af --- /dev/null +++ b/src/main/java/com/codesdream/ase/model/student/Notification.java @@ -0,0 +1,18 @@ +package com.codesdream.ase.model.student; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table +public class Notification { + @Id + int id; + + String context; + + String title; + + +} diff --git a/src/main/java/com/codesdream/ase/model/student/Student.java b/src/main/java/com/codesdream/ase/model/student/Student.java new file mode 100644 index 0000000..84ceb34 --- /dev/null +++ b/src/main/java/com/codesdream/ase/model/student/Student.java @@ -0,0 +1,22 @@ +package com.codesdream.ase.model.student; + +import com.codesdream.ase.model.mark.Tag; +import com.codesdream.ase.model.permission.User; + +import javax.annotation.Generated; +import javax.persistence.*; +import java.util.List; + +@Entity +@Table +public class Student extends User { + @Column(nullable = false) + String studentId; + + @Column(nullable = false) + String name; + + String profilePicture; + + +}