From 217c20ea3bfbed3c014978594c3ab0038d6ab166 Mon Sep 17 00:00:00 2001 From: MusingZone Date: Sat, 4 Apr 2020 15:12:48 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=88=90=E7=BB=A9?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=AD=90=E7=B3=BB=E7=BB=9F=E7=9A=84=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E7=89=88=E6=95=B0=E6=8D=AE=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ase/model/achievement/ExamResult.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/main/java/com/codesdream/ase/model/achievement/ExamResult.java diff --git a/src/main/java/com/codesdream/ase/model/achievement/ExamResult.java b/src/main/java/com/codesdream/ase/model/achievement/ExamResult.java new file mode 100644 index 0000000..2543fca --- /dev/null +++ b/src/main/java/com/codesdream/ase/model/achievement/ExamResult.java @@ -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; + } + +} From 418017a844c141c20390dda35339804800e05dae Mon Sep 17 00:00:00 2001 From: MusingZone Date: Sat, 4 Apr 2020 15:19:55 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=8F=88=E4=B8=80=E6=AC=A1=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E6=88=90=E7=BB=A9=E7=AE=A1=E7=90=86=E5=AD=90=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E7=9A=84=E7=AC=AC=E4=B8=80=E7=89=88=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ase/model/achievement/AccumulatedGPA.java | 42 ++++++++++++++++++ .../ase/model/achievement/Award.java | 34 ++++++++++++++ .../achievement/ComprehensiveEvaluation.java | 44 +++++++++++++++++++ .../model/achievement/StudentScoreReport.java | 33 ++++++++++++++ .../ase/service/AchievementService.java | 23 ++++++++++ .../ase/test/AchievementServiceTest.java | 31 +++++++++++++ 6 files changed, 207 insertions(+) create mode 100644 src/main/java/com/codesdream/ase/model/achievement/AccumulatedGPA.java create mode 100644 src/main/java/com/codesdream/ase/model/achievement/Award.java create mode 100644 src/main/java/com/codesdream/ase/model/achievement/ComprehensiveEvaluation.java create mode 100644 src/main/java/com/codesdream/ase/model/achievement/StudentScoreReport.java create mode 100644 src/main/java/com/codesdream/ase/service/AchievementService.java create mode 100644 src/test/java/com/codesdream/ase/test/AchievementServiceTest.java diff --git a/src/main/java/com/codesdream/ase/model/achievement/AccumulatedGPA.java b/src/main/java/com/codesdream/ase/model/achievement/AccumulatedGPA.java new file mode 100644 index 0000000..aa89fcf --- /dev/null +++ b/src/main/java/com/codesdream/ase/model/achievement/AccumulatedGPA.java @@ -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 examResults = new HashSet<>(); + + // 个人学分积 + @JoinColumn(nullable = true) + private float accumulatedGPA; + + + //除数为零exception待加 + public AccumulatedGPA(Set initExamResults) { + int totalProduct = 0, totalCredit = 0; + for(ExamResult er : initExamResults){ + totalProduct += er.getCredit() * er.getScore(); + totalCredit += er.getCredit(); + } + this.accumulatedGPA = totalProduct / totalCredit; + } + + +} diff --git a/src/main/java/com/codesdream/ase/model/achievement/Award.java b/src/main/java/com/codesdream/ase/model/achievement/Award.java new file mode 100644 index 0000000..8a6026c --- /dev/null +++ b/src/main/java/com/codesdream/ase/model/achievement/Award.java @@ -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; + + +} diff --git a/src/main/java/com/codesdream/ase/model/achievement/ComprehensiveEvaluation.java b/src/main/java/com/codesdream/ase/model/achievement/ComprehensiveEvaluation.java new file mode 100644 index 0000000..0393edd --- /dev/null +++ b/src/main/java/com/codesdream/ase/model/achievement/ComprehensiveEvaluation.java @@ -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 awards = new HashSet<>(); + +} diff --git a/src/main/java/com/codesdream/ase/model/achievement/StudentScoreReport.java b/src/main/java/com/codesdream/ase/model/achievement/StudentScoreReport.java new file mode 100644 index 0000000..32550ba --- /dev/null +++ b/src/main/java/com/codesdream/ase/model/achievement/StudentScoreReport.java @@ -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 examResults = new HashSet<>(); + + // 个人学分积 + @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JoinColumn(nullable = true) + private AccumulatedGPA accumulatedGPA; + +} diff --git a/src/main/java/com/codesdream/ase/service/AchievementService.java b/src/main/java/com/codesdream/ase/service/AchievementService.java new file mode 100644 index 0000000..e768cb8 --- /dev/null +++ b/src/main/java/com/codesdream/ase/service/AchievementService.java @@ -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 { + +} diff --git a/src/test/java/com/codesdream/ase/test/AchievementServiceTest.java b/src/test/java/com/codesdream/ase/test/AchievementServiceTest.java new file mode 100644 index 0000000..381f586 --- /dev/null +++ b/src/test/java/com/codesdream/ase/test/AchievementServiceTest.java @@ -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; + + +}