This commit is contained in:
Saturneric 2020-04-04 18:51:35 +08:00
commit 2b5274c47d
7 changed files with 250 additions and 0 deletions

View File

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

View File

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

View File

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

View File

@ -0,0 +1,43 @@
package com.codesdream.ase.model.achievement;
import com.codesdream.ase.model.activity.Period;
import lombok.Data;
import javax.persistence.*;
@Data
@Entity
@Table(name = "exam_result")
public class ExamResult {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
// 课程名称
@Column(name = "subject", nullable = false)
private String subject = "";
// 课程学分
@Column(name = "credit", nullable = false)
private float credit;
// 课程成绩
@Column(name = "score", nullable = true)
private int score;
// 课程绩点
@Column(name = "grade_point", nullable = true)
private float gradePoint;
public float getCredit() {
return credit;
}
public int getScore() {
return score;
}
}

View File

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

View File

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

View File

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