又一次完成成绩管理子系统的第一版数据模型
This commit is contained in:
parent
217c20ea3b
commit
418017a844
@ -0,0 +1,42 @@
|
||||
package com.codesdream.ase.model.achievement;
|
||||
|
||||
import com.codesdream.ase.model.activity.Period;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "accumulated_gpa")
|
||||
|
||||
public class AccumulatedGPA {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private int id;
|
||||
|
||||
// 课程-得分集合
|
||||
@OneToMany(cascade = {CascadeType.MERGE, CascadeType.DETACH}, fetch = FetchType.LAZY)
|
||||
private Set<ExamResult> examResults = new HashSet<>();
|
||||
|
||||
// 个人学分积
|
||||
@JoinColumn(nullable = true)
|
||||
private float accumulatedGPA;
|
||||
|
||||
|
||||
//除数为零exception待加
|
||||
public AccumulatedGPA(Set<ExamResult> initExamResults) {
|
||||
int totalProduct = 0, totalCredit = 0;
|
||||
for(ExamResult er : initExamResults){
|
||||
totalProduct += er.getCredit() * er.getScore();
|
||||
totalCredit += er.getCredit();
|
||||
}
|
||||
this.accumulatedGPA = totalProduct / totalCredit;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.codesdream.ase.model.achievement;
|
||||
|
||||
import com.codesdream.ase.model.permission.User;
|
||||
import com.codesdream.ase.model.permission.UserDetail;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "award")
|
||||
|
||||
public class Award {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private int id;
|
||||
|
||||
// 标题
|
||||
private String title = "";
|
||||
|
||||
// 描述
|
||||
private String description = "";
|
||||
|
||||
// 分类
|
||||
private String type = "";
|
||||
|
||||
// 加分
|
||||
private int bonus;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.codesdream.ase.model.achievement;
|
||||
|
||||
import com.codesdream.ase.model.permission.User;
|
||||
import com.codesdream.ase.model.permission.UserDetail;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "comprehensive_evaluation")
|
||||
|
||||
public class ComprehensiveEvaluation {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private int id;
|
||||
|
||||
// 学分积
|
||||
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
private AccumulatedGPA accumulatedGPA;
|
||||
|
||||
// G2项得分
|
||||
private int g2;
|
||||
|
||||
// G3项得分
|
||||
private int g3;
|
||||
|
||||
// G4项得分
|
||||
private int g4;
|
||||
|
||||
// G5项得分
|
||||
private int g5;
|
||||
|
||||
// G6项得分
|
||||
private int g6;
|
||||
|
||||
// 获奖
|
||||
@OneToMany(cascade = {CascadeType.MERGE, CascadeType.DETACH}, fetch = FetchType.LAZY)
|
||||
private Set<Award> awards = new HashSet<>();
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.codesdream.ase.model.achievement;
|
||||
|
||||
import com.codesdream.ase.model.activity.Period;
|
||||
import com.codesdream.ase.model.permission.Tag;
|
||||
import com.codesdream.ase.model.permission.User;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "student_score_report")
|
||||
|
||||
public class StudentScoreReport {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private int id;
|
||||
|
||||
// 课程-得分集合
|
||||
@OneToMany(cascade = {CascadeType.MERGE, CascadeType.DETACH}, fetch = FetchType.LAZY)
|
||||
private Set<ExamResult> examResults = new HashSet<>();
|
||||
|
||||
// 个人学分积
|
||||
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@JoinColumn(nullable = true)
|
||||
private AccumulatedGPA accumulatedGPA;
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.codesdream.ase.service;
|
||||
|
||||
import com.codesdream.ase.component.auth.ASEPasswordEncoder;
|
||||
import com.codesdream.ase.component.auth.ASEUsernameEncoder;
|
||||
import com.codesdream.ase.component.permission.UserRolesListGenerator;
|
||||
import com.codesdream.ase.exception.badrequest.UserInformationIllegalException;
|
||||
import com.codesdream.ase.exception.notfound.UserNotFoundException;
|
||||
import com.codesdream.ase.exception.badrequest.UsernameAlreadyExistException;
|
||||
import com.codesdream.ase.model.information.BaseStudentInfo;
|
||||
import com.codesdream.ase.model.permission.User;
|
||||
import com.codesdream.ase.repository.permission.UserRepository;
|
||||
import javafx.util.Pair;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
public class AchievementService {
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.codesdream.ase.test;
|
||||
|
||||
import com.codesdream.ase.model.activity.Activity;
|
||||
import com.codesdream.ase.model.activity.Report;
|
||||
import com.codesdream.ase.model.permission.User;
|
||||
import com.codesdream.ase.service.AchievementService;
|
||||
import com.codesdream.ase.service.ActivityService;
|
||||
import com.codesdream.ase.service.UserService;
|
||||
import javafx.util.Pair;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 成绩管理子系统单元测试
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@ActiveProfiles("test")
|
||||
|
||||
public class AchievementServiceTest {
|
||||
|
||||
@Resource
|
||||
private AchievementService achievementService;
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user