student实体初步构建
This commit is contained in:
parent
b496b0317d
commit
437cab45dc
15
src/main/java/com/codesdream/ase/model/file/Image.java
Normal file
15
src/main/java/com/codesdream/ase/model/file/Image.java
Normal file
@ -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;
|
||||
}
|
14
src/main/java/com/codesdream/ase/model/mark/Tag.java
Normal file
14
src/main/java/com/codesdream/ase/model/mark/Tag.java
Normal file
@ -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;
|
||||
}
|
@ -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<Tag> tags;
|
||||
|
||||
|
||||
public User(String username, String password) {
|
||||
this.username = username;
|
||||
|
17
src/main/java/com/codesdream/ase/model/student/Comment.java
Normal file
17
src/main/java/com/codesdream/ase/model/student/Comment.java
Normal file
@ -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;
|
||||
}
|
28
src/main/java/com/codesdream/ase/model/student/Honor.java
Normal file
28
src/main/java/com/codesdream/ase/model/student/Honor.java
Normal file
@ -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<Image> images;
|
||||
|
||||
// 创建时间
|
||||
Date creationDate;
|
||||
|
||||
// 上一次修改时间
|
||||
Date lastModification;
|
||||
}
|
31
src/main/java/com/codesdream/ase/model/student/Moment.java
Normal file
31
src/main/java/com/codesdream/ase/model/student/Moment.java
Normal file
@ -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<Comment> comments = new ArrayList<>();
|
||||
|
||||
@OneToMany(cascade = CascadeType.MERGE)
|
||||
List<Image> images = new ArrayList<>();
|
||||
}
|
@ -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;
|
||||
|
||||
|
||||
}
|
22
src/main/java/com/codesdream/ase/model/student/Student.java
Normal file
22
src/main/java/com/codesdream/ase/model/student/Student.java
Normal file
@ -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;
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user