简单学生管理系统
This commit is contained in:
parent
2510bdae27
commit
2833d5e64c
|
@ -23,4 +23,5 @@ public interface CourseMapper {
|
|||
|
||||
// 查询课程学生选课情况
|
||||
List<Enrollment> getEnrollmentsByCourseId(String courseId);
|
||||
|
||||
}
|
|
@ -5,7 +5,7 @@ spring.jackson.time-zone=Asia/Shanghai
|
|||
spring.devtools.restart.exclude=static/**
|
||||
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.url=jdbc:mysql://10.33.66.120/MB
|
||||
spring.datasource.url=jdbc:mysql://10.33.66.120/mb202201090152
|
||||
spring.datasource.username=mb202201090152
|
||||
spring.datasource.password=GGQTSM233759
|
||||
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
<resultMap id="EnrollmentResult" type="Enrollment">
|
||||
<id column="student_id" property="studentId" />
|
||||
<result column="student_name" property="studentName" />
|
||||
<id column="course_id" property="courseId" />
|
||||
<result column="course_id" property="courseId" />
|
||||
<result column="course_name" property="courseName" />
|
||||
</resultMap>
|
||||
|
||||
|
|
|
@ -10,14 +10,14 @@
|
|||
where s.id = #{id} and s.id = sc.student_id and c.id = sc.course_id
|
||||
</select>
|
||||
<resultMap id="StudentWithScores" type="StudentScore">
|
||||
<id column="sid" property="student.id"></id>
|
||||
<id column="sid" property="student.id"/>
|
||||
<result column="sname" property="student.name"/>
|
||||
<collection property="scores" ofType="Score">
|
||||
<id column="scid" property="id"/>
|
||||
<id column="score" property="score" />
|
||||
<result column="score" property="score"/>
|
||||
<association property="course" javaType="Course">
|
||||
<id column="cid" property="id"/>
|
||||
<id column="cname" property="name"/>
|
||||
<result column="cname" property="name"/>
|
||||
</association>
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
package edu.gjq;
|
||||
|
||||
import edu.gjq.mapper.AccountMapper;
|
||||
import edu.gjq.mapper.ScoreMapper;
|
||||
import edu.gjq.mapper.StudentScoreMapper;
|
||||
import edu.gjq.mapper.StudentMapper;
|
||||
import edu.gjq.pojo.Account;
|
||||
import edu.gjq.pojo.Score;
|
||||
import edu.gjq.pojo.Student;
|
||||
import edu.gjq.pojo.StudentScore;
|
||||
import edu.gjq.mapper.*;
|
||||
import edu.gjq.pojo.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
@ -28,6 +23,8 @@ class ApplicationTests {
|
|||
private StudentScoreMapper studentScoreMapper;
|
||||
@Autowired
|
||||
private AccountMapper accountMapper;
|
||||
@Autowired
|
||||
private CourseMapper courseMapper;
|
||||
|
||||
@Test
|
||||
public void testGetAll(){
|
||||
|
@ -61,24 +58,25 @@ class ApplicationTests {
|
|||
account.setCreateTime(now);
|
||||
accountMapper.insertAccount(account);
|
||||
}
|
||||
@Test
|
||||
public void testInsertStudent(){
|
||||
Student student = new Student();
|
||||
student.setId("12143");
|
||||
student.setName("陆展博");
|
||||
student.setGender(1);
|
||||
student.setBirthday(LocalDate.of(2002,10,14));
|
||||
student.setCreateBy(1);
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
student.setCreateTime(now);
|
||||
studentMapper.insertStudent(student);
|
||||
}
|
||||
// @Test
|
||||
// public void testInsertStudent() {
|
||||
// Student student = new Student();
|
||||
// student.setId("12149");
|
||||
// student.setName("小星星");
|
||||
// student.setGender(0);
|
||||
// student.setBirthday(LocalDate.of(2014, 6, 4));
|
||||
// student.setCreateBy(1);
|
||||
// LocalDateTime now = LocalDateTime.now();
|
||||
// student.setCreateTime(now);
|
||||
// studentMapper.insertStudent(student);
|
||||
//
|
||||
// }
|
||||
@Test
|
||||
public void testInsertScore(){
|
||||
Score score = new Score();
|
||||
score.setStudentId("12142");
|
||||
score.setCourseId("102");
|
||||
score.setScore(90);
|
||||
score.setCourseId("106");
|
||||
score.setScore(60);
|
||||
score.setCreateBy(1);
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
score.setCreateTime(now);
|
||||
|
@ -137,7 +135,8 @@ class ApplicationTests {
|
|||
System.out.println(score);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 根据学号输出学生所有的课程成绩
|
||||
@Test
|
||||
public void testStudentGrade2(){
|
||||
StudentScore studentScore = studentScoreMapper.getByNo("12138");
|
||||
|
@ -171,5 +170,31 @@ class ApplicationTests {
|
|||
}
|
||||
|
||||
*/
|
||||
@Test
|
||||
public void testGetAllCourses() {
|
||||
List<Course> courses = courseMapper.getAll();
|
||||
System.out.println(courses);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInsertCourse() {
|
||||
Course course = new Course();
|
||||
course.setId(107);
|
||||
course.setName("新课程");
|
||||
courseMapper.insertCourse(course);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateCourse() {
|
||||
Course course = new Course();
|
||||
course.setId(107);
|
||||
course.setName("更新课程");
|
||||
courseMapper.update(course);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteCourse() {
|
||||
courseMapper.deleteById("107");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue