student实体初步构建

This commit is contained in:
chuyan 2020-09-03 18:47:11 +08:00
parent b496b0317d
commit 437cab45dc
8 changed files with 150 additions and 4 deletions

View 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;
}

View 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;
}

View File

@ -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;

View 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;
}

View 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;
}

View 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<>();
}

View File

@ -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;
}

View 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;
}