Signed-off-by: Chenx221 <chenx221@yandex.com>
This commit is contained in:
Chenx221 2023-06-13 09:13:43 +08:00
parent 11443413a1
commit eb0e715540
16 changed files with 476 additions and 44 deletions

View File

@ -11,7 +11,6 @@
WHERE invalid = 0; WHERE invalid = 0;
</select> </select>
<!-- 定义结果映射 -->
<resultMap id="ScoreResultMap" type="cyou.chenx221.pojo.Score"> <resultMap id="ScoreResultMap" type="cyou.chenx221.pojo.Score">
<id property="ScoreID" column="ScoreID"/> <id property="ScoreID" column="ScoreID"/>
<result property="score" column="Score"/> <result property="score" column="Score"/>
@ -25,5 +24,36 @@
</association> </association>
</resultMap> </resultMap>
<select id="getQueryScores" parameterType="cyou.chenx221.pojo.Score" resultMap="ScoreResultMap">
SELECT ScoreID, Score, st.id as student_id, st.name as name, c.CourseID, c.CourseName
FROM score s
JOIN student st ON s.StudentID = st.id
JOIN course c ON s.CourseID = c.CourseID
WHERE invalid = 0
<trim prefix="AND" prefixOverrides="AND | OR">
<if test="student !=null">
<if test="student.id != null">
AND st.id = #{student.id}
</if>
<if test="student.name != null">
AND st.name = #{student.name}
</if>
</if>
<if test="course !=null">
<if test="course.CourseID != null">
AND c.CourseID = #{course.courseID}
</if>
<if test="course.CourseName != null">
AND c.CourseName LIKE CONCAT('%', #{course.courseName}, '%')
</if>
</if>
<if test="ScoreID != null">
AND ScoreID = #{scoreID}
</if>
<if test="min != null and max != null">
AND Score BETWEEN #{min} AND #{max}
</if>
</trim>
</select>
</mapper> </mapper>

View File

@ -0,0 +1,179 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
<meta http-equiv="x-ua-compatible" content="ie=edge"/>
<title>成绩信息查询结果页</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"/>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700;900&display=swap"
rel="stylesheet">
<link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/mdb.min.css"/>
<style>
.table-container {
min-width: 80vw; /* 设置最小宽度为视窗宽度的80% */
min-height: 80vh; /* 设置最小高度为视窗高度的80% */
/*display: flex;*/
align-items: center;
justify-content: center;
}
.table-container table {
width: 100%;
height: 100%;
}
</style>
</head>
<body style="font-family: 'Noto Sans SC Regular',serif">
<!--Main Navigation-->
<header>
<nav class="navbar navbar-expand-lg navbar-light bg-light" style="z-index: 1;min-height: 58.59px">
<div class="container">
<button class="navbar-toggler" type="button" data-mdb-toggle="collapse"
data-mdb-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<i class="fas fa-bars"></i>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<a class="navbar-brand mt-2 mt-lg-0" href="#">
<i class="fas fa-chalkboard-user me-2"></i>
教务管理系统
</a>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">首页</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown1" role="button"
data-mdb-toggle="dropdown" aria-expanded="false">
学生管理
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown1">
<li><a class="dropdown-item" href="#">学生信息查询</a></li>
<li><a class="dropdown-item" href="#">学生信息管理</a></li>
<li><a class="dropdown-item" href="#">学生信息管理</a></li>
<li>
<hr class="dropdown-divider"/>
</li>
<li><a class="dropdown-item" href="#">学生成绩管理</a></li>
<li><a class="dropdown-item" href="#">学生成绩管理</a></li>
<li><a class="dropdown-item" href="#">学生成绩管理</a></li>
<li>
<hr class="dropdown-divider"/>
</li>
<li><a class="dropdown-item" href="#">学生选课管理</a></li>
<li><a class="dropdown-item" href="#">学生选课管理</a></li>
<li><a class="dropdown-item" href="#">学生选课管理</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown2" role="button"
data-mdb-toggle="dropdown" aria-expanded="false">
教师管理
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown2">
<li><a class="dropdown-item" href="#">教师信息管理</a></li>
<li><a class="dropdown-item" href="#">教师课程管理</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown3" role="button"
data-mdb-toggle="dropdown" aria-expanded="false">
课程管理
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown3">
<li><a class="dropdown-item" href="#">课程信息管理</a></li>
<li><a class="dropdown-item" href="#">课程安排管理</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown4" role="button"
data-mdb-toggle="dropdown" aria-expanded="false">
系统管理
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown4">
<li><a class="dropdown-item" href="#">个人设定</a></li>
<li><a class="dropdown-item" href="#">用户管理</a></li>
<li><a class="dropdown-item" href="#">日志管理</a></li>
<li><a class="dropdown-item" href="#">版本信息</a></li>
</ul>
</li>
</ul>
</div>
<div class="dropdown">
<a class="dropdown-toggle d-flex align-items-center hidden-arrow" href="#"
id="navbarDropdownMenuAvatar" role="button" data-mdb-toggle="dropdown" aria-expanded="false">
<i class="fas fa-circle-user fa-lg me-1"></i>
${username}
</a>
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdownMenuAvatar">
<li>
<a class="dropdown-item" href="${pageContext.request.contextPath}/logout">登出</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<!--Main Navigation-->
<!--Main layout-->
<main>
<div class="bg-image shadow-2-strong vh-100"
style="background-image: url('${pageContext.request.contextPath}/resources/img/jason-blackeye-nyL-rzwP-Mk-unsplash.jpg'); margin-top: -58.59px;">
<div class="mask d-flex align-items-center h-100" style="background-color: hsla(0, 0%, 100%, 0.5);">
<div class="container d-flex justify-content-center">
<button type="button" class="btn btn-primary" onclick="location.href='../dashboard'">返回</button>
<div class="table-container rounded-4 shadow-3-strong"
style="background-color: rgba(255,255,255,0.9); overflow-y: auto; max-height: 400px;">
<table class="table table-striped table-hover border-primary">
<thead>
<tr>
<th scope="col">成绩ID</th>
<th scope="col">学号</th>
<th scope="col">学生姓名</th>
<th scope="col">课程ID</th>
<th scope="col">课程名</th>
<th scope="col">成绩</th>
</tr>
</thead>
<tbody>
<c:forEach var="score" items="${scores}">
<tr>
<td>${score.scoreID}</td>
<td>${score.student.id}</td>
<td>${score.student.name}</td>
<td>${score.course.courseID}</td>
<td>${score.course.courseName}</td>
<td>${score.score}</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</div>
</div>
</div>
</main>
<!--Main layout-->
<!-- Footer -->
<footer class="bg-link text-center text-lg-start ">
</footer>
<!-- Footer -->
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/js/mdb.min.js"></script>
</body>
</html>

View File

@ -258,7 +258,7 @@
<div class="row mb-2"> <div class="row mb-2">
<div class="col-12"> <div class="col-12">
<div class="form-check"> <div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="range_enabler" name="range_enabler" /> <input class="form-check-input" type="checkbox" value="true" id="range_enabler" name="range_enabler" />
<label class="form-check-label" for="range_enabler">设定成绩范围</label> <label class="form-check-label" for="range_enabler">设定成绩范围</label>
</div> </div>
</div> </div>

View File

@ -50,42 +50,46 @@ public class ScoreController {
return "scoreopv2"; return "scoreopv2";
} }
// @PostMapping(value = "/query", produces = "application/x-www-form-urlencoded;charset=UTF-8")//学生信息查询带条件 @PostMapping(value = "/query", produces = "application/x-www-form-urlencoded;charset=UTF-8")//学生信息查询带条件
// public String getQueryCourses(@RequestParam(value = "name", defaultValue = "null", required = false) String name,//学生姓名 public String getQueryCourses(@RequestParam(value = "name", defaultValue = "null", required = false) String name,//学生姓名
// @RequestParam(value = "coursename", defaultValue = "null", required = false) String course_name,//课程名 @RequestParam(value = "coursename", defaultValue = "null", required = false) String course_name,//课程名
// @RequestParam(value = "scoreid", defaultValue = "-1", required = false) int score_id,//成绩ID @RequestParam(value = "scoreid", defaultValue = "-1", required = false) int score_id,//成绩ID
// @RequestParam(value = "studentid", defaultValue = "-1", required = false) int student_id,//学号 @RequestParam(value = "studentid", defaultValue = "-1", required = false) int student_id,//学号
// @RequestParam(value = "courseid", defaultValue = "-1", required = false) int course_id,//课程ID @RequestParam(value = "courseid", defaultValue = "-1", required = false) int course_id,//课程ID
// @RequestParam(value = "min", required = false) int min,//最低分 @RequestParam(value = "min", defaultValue = "-1", required = false) int min,//最低分
// @RequestParam(value = "max", required = false) int max,//最高分 @RequestParam(value = "max", defaultValue = "-1", required = false) int max,//最高分
// @RequestParam(value = "range_enabler", defaultValue = "false", required = false) boolean range_enabler,//是否启用分数范围 @RequestParam(value = "range_enabler", defaultValue = "false", required = false) boolean range_enabler,//是否启用分数范围
// Model model) { Model model) {
//
// //username helper start //username helper start
// String username = new UsernameHelper().getCurrentUsername(); String username = new UsernameHelper().getCurrentUsername();
// if (username != null) { if (username != null) {
// model.addAttribute("username", username); model.addAttribute("username", username);
// } }
// //username helper end //username helper end
//
// if (name.equals("null")) { if (name.equals("null")) {
// name = null; name = null;
// } }
// if (course_name.equals("null")) { if (course_name.equals("null")) {
// course_name = null; course_name = null;
// } }
// if (score_id == -1 && student_id == -1 && course_id == -1 && !range_enabler) { // System.out.println("name: " + name + " course_name: " + course_name + " score_id: " + score_id + " student_id: " + student_id + " course_id: " + course_id + " min: " + min + " max: " + max + " range_enabler: " + range_enabler);
// model.addAttribute("errorMessage", "查询条件不可全为空"); if (score_id == -1 && student_id == -1 && course_id == -1 && !range_enabler && course_name == null && name == null) {
// return "redirect:/score/infomodv2"; model.addAttribute("errorMessage", "查询条件不可全为空");
// } return "redirect:/score/infomodv2";
// List<Score> scores; }
// Score score;
// List<Score> scores;
// score = new Score((score_id == -1? null:score_id), ((student_id==-1&&name==null)==null?null:(new Student(student_id,name))), null, null, min, max); Score score;
// course = new Course((id == -1 ? null : id), name, description);
//// System.out.println("id:" + id + " name:" + name + " description:" + description); score = new Score((score_id == -1 ? null : score_id), ((student_id == -1 && name == null) ? null : (new Student((student_id == -1 ? null : student_id), name))), (course_id == -1 && course_name == null) ? null : (new Course((course_id == -1 ? null : course_id), course_name)), range_enabler ? (min == -1 ? null : min) : null, range_enabler ? (max == -1 ? null : max) : null);
scores = scoreService.getQueryScores(score);
//TODO: query result download(csv)
// courses = courseService.getQueryCourses(course); // courses = courseService.getQueryCourses(course);
// model.addAttribute("courses", courses); // model.addAttribute("score", score);
// return "courseQueryResult"; model.addAttribute("scores", scores);
// } return "scoreQueryResult";
}
} }

View File

@ -8,4 +8,6 @@ import java.util.List;
@Repository @Repository
public interface ScoreDao { public interface ScoreDao {
List<Score> getAllScore(); List<Score> getAllScore();
List<Score> getQueryScores(Score score);
} }

View File

@ -13,7 +13,7 @@ public class ScoreDaoImpl implements ScoreDao {
private SqlSession sqlSession; private SqlSession sqlSession;
@Autowired @Autowired
public ScoreDaoImpl(SqlSession sqlSession){ public ScoreDaoImpl(SqlSession sqlSession) {
this.sqlSession = sqlSession; this.sqlSession = sqlSession;
} }
@ -21,4 +21,9 @@ public class ScoreDaoImpl implements ScoreDao {
public List<Score> getAllScore() { public List<Score> getAllScore() {
return sqlSession.selectList("getAllScore"); return sqlSession.selectList("getAllScore");
} }
@Override
public List<Score> getQueryScores(Score score) {
return sqlSession.selectList("getQueryScores", score);
}
} }

View File

@ -23,11 +23,10 @@ public class Score {
this.score = score; this.score = score;
} }
public Score(Integer scoreID, Student student, Course course, Integer score, Integer min, Integer max) { public Score(Integer scoreID, Student student, Course course, Integer min, Integer max) {
ScoreID = scoreID; ScoreID = scoreID;
this.student = student; this.student = student;
this.course = course; this.course = course;
this.score = score;
this.min = min; this.min = min;
this.max = max; this.max = max;
} }

View File

@ -17,4 +17,8 @@ public class ScoreService {
public List<Score> getAllScores() { public List<Score> getAllScores() {
return scoreDao.getAllScore(); return scoreDao.getAllScore();
} }
public List<Score> getQueryScores(Score score) {
return scoreDao.getQueryScores(score);
}
} }

View File

@ -11,7 +11,6 @@
WHERE invalid = 0; WHERE invalid = 0;
</select> </select>
<!-- 定义结果映射 -->
<resultMap id="ScoreResultMap" type="cyou.chenx221.pojo.Score"> <resultMap id="ScoreResultMap" type="cyou.chenx221.pojo.Score">
<id property="ScoreID" column="ScoreID"/> <id property="ScoreID" column="ScoreID"/>
<result property="score" column="Score"/> <result property="score" column="Score"/>
@ -25,5 +24,36 @@
</association> </association>
</resultMap> </resultMap>
<select id="getQueryScores" parameterType="cyou.chenx221.pojo.Score" resultMap="ScoreResultMap">
SELECT ScoreID, Score, st.id as student_id, st.name as name, c.CourseID, c.CourseName
FROM score s
JOIN student st ON s.StudentID = st.id
JOIN course c ON s.CourseID = c.CourseID
WHERE invalid = 0
<trim prefix="AND" prefixOverrides="AND | OR">
<if test="student !=null">
<if test="student.id != null">
AND st.id = #{student.id}
</if>
<if test="student.name != null">
AND st.name = #{student.name}
</if>
</if>
<if test="course !=null">
<if test="course.CourseID != null">
AND c.CourseID = #{course.courseID}
</if>
<if test="course.CourseName != null">
AND c.CourseName LIKE CONCAT('%', #{course.courseName}, '%')
</if>
</if>
<if test="ScoreID != null">
AND ScoreID = #{scoreID}
</if>
<if test="min != null and max != null">
AND Score BETWEEN #{min} AND #{max}
</if>
</trim>
</select>
</mapper> </mapper>

View File

@ -0,0 +1,179 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
<meta http-equiv="x-ua-compatible" content="ie=edge"/>
<title>成绩信息查询结果页</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"/>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700;900&display=swap"
rel="stylesheet">
<link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/mdb.min.css"/>
<style>
.table-container {
min-width: 80vw; /* 设置最小宽度为视窗宽度的80% */
min-height: 80vh; /* 设置最小高度为视窗高度的80% */
/*display: flex;*/
align-items: center;
justify-content: center;
}
.table-container table {
width: 100%;
height: 100%;
}
</style>
</head>
<body style="font-family: 'Noto Sans SC Regular',serif">
<!--Main Navigation-->
<header>
<nav class="navbar navbar-expand-lg navbar-light bg-light" style="z-index: 1;min-height: 58.59px">
<div class="container">
<button class="navbar-toggler" type="button" data-mdb-toggle="collapse"
data-mdb-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<i class="fas fa-bars"></i>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<a class="navbar-brand mt-2 mt-lg-0" href="#">
<i class="fas fa-chalkboard-user me-2"></i>
教务管理系统
</a>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">首页</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown1" role="button"
data-mdb-toggle="dropdown" aria-expanded="false">
学生管理
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown1">
<li><a class="dropdown-item" href="#">学生信息查询</a></li>
<li><a class="dropdown-item" href="#">学生信息管理</a></li>
<li><a class="dropdown-item" href="#">学生信息管理</a></li>
<li>
<hr class="dropdown-divider"/>
</li>
<li><a class="dropdown-item" href="#">学生成绩管理</a></li>
<li><a class="dropdown-item" href="#">学生成绩管理</a></li>
<li><a class="dropdown-item" href="#">学生成绩管理</a></li>
<li>
<hr class="dropdown-divider"/>
</li>
<li><a class="dropdown-item" href="#">学生选课管理</a></li>
<li><a class="dropdown-item" href="#">学生选课管理</a></li>
<li><a class="dropdown-item" href="#">学生选课管理</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown2" role="button"
data-mdb-toggle="dropdown" aria-expanded="false">
教师管理
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown2">
<li><a class="dropdown-item" href="#">教师信息管理</a></li>
<li><a class="dropdown-item" href="#">教师课程管理</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown3" role="button"
data-mdb-toggle="dropdown" aria-expanded="false">
课程管理
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown3">
<li><a class="dropdown-item" href="#">课程信息管理</a></li>
<li><a class="dropdown-item" href="#">课程安排管理</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown4" role="button"
data-mdb-toggle="dropdown" aria-expanded="false">
系统管理
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown4">
<li><a class="dropdown-item" href="#">个人设定</a></li>
<li><a class="dropdown-item" href="#">用户管理</a></li>
<li><a class="dropdown-item" href="#">日志管理</a></li>
<li><a class="dropdown-item" href="#">版本信息</a></li>
</ul>
</li>
</ul>
</div>
<div class="dropdown">
<a class="dropdown-toggle d-flex align-items-center hidden-arrow" href="#"
id="navbarDropdownMenuAvatar" role="button" data-mdb-toggle="dropdown" aria-expanded="false">
<i class="fas fa-circle-user fa-lg me-1"></i>
${username}
</a>
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdownMenuAvatar">
<li>
<a class="dropdown-item" href="${pageContext.request.contextPath}/logout">登出</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<!--Main Navigation-->
<!--Main layout-->
<main>
<div class="bg-image shadow-2-strong vh-100"
style="background-image: url('${pageContext.request.contextPath}/resources/img/jason-blackeye-nyL-rzwP-Mk-unsplash.jpg'); margin-top: -58.59px;">
<div class="mask d-flex align-items-center h-100" style="background-color: hsla(0, 0%, 100%, 0.5);">
<div class="container d-flex justify-content-center">
<button type="button" class="btn btn-primary" onclick="location.href='../dashboard'">返回</button>
<div class="table-container rounded-4 shadow-3-strong"
style="background-color: rgba(255,255,255,0.9); overflow-y: auto; max-height: 400px;">
<table class="table table-striped table-hover border-primary">
<thead>
<tr>
<th scope="col">成绩ID</th>
<th scope="col">学号</th>
<th scope="col">学生姓名</th>
<th scope="col">课程ID</th>
<th scope="col">课程名</th>
<th scope="col">成绩</th>
</tr>
</thead>
<tbody>
<c:forEach var="score" items="${scores}">
<tr>
<td>${score.scoreID}</td>
<td>${score.student.id}</td>
<td>${score.student.name}</td>
<td>${score.course.courseID}</td>
<td>${score.course.courseName}</td>
<td>${score.score}</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</div>
</div>
</div>
</main>
<!--Main layout-->
<!-- Footer -->
<footer class="bg-link text-center text-lg-start ">
</footer>
<!-- Footer -->
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/js/mdb.min.js"></script>
</body>
</html>

View File

@ -258,7 +258,7 @@
<div class="row mb-2"> <div class="row mb-2">
<div class="col-12"> <div class="col-12">
<div class="form-check"> <div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="range_enabler" name="range_enabler" /> <input class="form-check-input" type="checkbox" value="true" id="range_enabler" name="range_enabler" />
<label class="form-check-label" for="range_enabler">设定成绩范围</label> <label class="form-check-label" for="range_enabler">设定成绩范围</label>
</div> </div>
</div> </div>