student相关repository修改与完善

This commit is contained in:
chuyan 2020-09-08 21:41:00 +08:00
parent ccb1cb3682
commit 5d3b6ec02d
3 changed files with 18 additions and 37 deletions

View File

@ -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<Comment> comments = new ArrayList<>();
@OneToMany(cascade = CascadeType.MERGE)
List<Image> images = new ArrayList<>();
}

View File

@ -12,15 +12,14 @@ public class StudentCourse {
@Id @Id
int id; int id;
@OneToOne(cascade = CascadeType.MERGE) String studentId;
Student student;
@OneToOne(cascade = CascadeType.MERGE) String courseId;
Course course;
@Column(nullable = false) @Column(nullable = false)
float score; float score;
@Column(nullable = false)
boolean isFailed; boolean isFailed;
Date finishedDate; Date finishedDate;

View File

@ -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<StudentCourse, Integer> {
List<StudentCourse> findByStudentId(String studentId);
List<StudentCourse> findByStudentId(String studentId, Sort sort);
}