From 5d3b6ec02dca8685baca899c83a1b80834d529af Mon Sep 17 00:00:00 2001 From: chuyan <1047381936@qq.com> Date: Tue, 8 Sep 2020 21:41:00 +0800 Subject: [PATCH] =?UTF-8?q?student=E7=9B=B8=E5=85=B3repository=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=B8=8E=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../codesdream/ase/model/student/Moment.java | 33 ------------------- .../ase/model/student/StudentCourse.java | 7 ++-- .../ase/repository/student/SCRepository.java | 15 +++++++++ 3 files changed, 18 insertions(+), 37 deletions(-) delete mode 100644 src/main/java/com/codesdream/ase/model/student/Moment.java create mode 100644 src/main/java/com/codesdream/ase/repository/student/SCRepository.java diff --git a/src/main/java/com/codesdream/ase/model/student/Moment.java b/src/main/java/com/codesdream/ase/model/student/Moment.java deleted file mode 100644 index bc8de2f..0000000 --- a/src/main/java/com/codesdream/ase/model/student/Moment.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.codesdream.ase.model.student; - -import com.codesdream.ase.model.file.Image; -import lombok.Data; - -import javax.persistence.*; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; - -// 动态/说说 -@Entity -@Table -@Data -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/StudentCourse.java b/src/main/java/com/codesdream/ase/model/student/StudentCourse.java index 8b8d347..0c1c52e 100644 --- a/src/main/java/com/codesdream/ase/model/student/StudentCourse.java +++ b/src/main/java/com/codesdream/ase/model/student/StudentCourse.java @@ -12,15 +12,14 @@ public class StudentCourse { @Id int id; - @OneToOne(cascade = CascadeType.MERGE) - Student student; + String studentId; - @OneToOne(cascade = CascadeType.MERGE) - Course course; + String courseId; @Column(nullable = false) float score; + @Column(nullable = false) boolean isFailed; Date finishedDate; diff --git a/src/main/java/com/codesdream/ase/repository/student/SCRepository.java b/src/main/java/com/codesdream/ase/repository/student/SCRepository.java new file mode 100644 index 0000000..4b170a4 --- /dev/null +++ b/src/main/java/com/codesdream/ase/repository/student/SCRepository.java @@ -0,0 +1,15 @@ +package com.codesdream.ase.repository.student; + +import com.codesdream.ase.model.student.StudentCourse; +import org.springframework.data.domain.Sort; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface SCRepository extends JpaRepository { + + List findByStudentId(String studentId); + List findByStudentId(String studentId, Sort sort); +}