Score Manage completed
Signed-off-by: Chenx221 <chenx221@yandex.com>
This commit is contained in:
parent
83735978db
commit
d71f1fd267
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -55,5 +55,29 @@
|
||||
</if>
|
||||
</trim>
|
||||
</select>
|
||||
|
||||
<update id="updateScore" parameterType="cyou.chenx221.pojo.Score">
|
||||
UPDATE score
|
||||
<set>
|
||||
<if test="score != null">
|
||||
Score = #{score}
|
||||
</if>
|
||||
</set>
|
||||
WHERE ScoreID = #{scoreID};
|
||||
</update>
|
||||
<select id="getScoreById" parameterType="int" 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 AND ScoreID = #{id};
|
||||
</select>
|
||||
<update id="deleteScore" parameterType="int">
|
||||
UPDATE score
|
||||
SET invalid = 1
|
||||
WHERE ScoreID = #{id};
|
||||
</update>
|
||||
<insert id="insertScore" parameterType="cyou.chenx221.pojo.Score">
|
||||
INSERT INTO score (Score, StudentID, CourseID)
|
||||
VALUES (#{score}, #{student.id}, #{course.courseID});
|
||||
</insert>
|
||||
</mapper>
|
@ -25,6 +25,7 @@
|
||||
<security:intercept-url pattern="/course/**" access="hasRole('admin')"/>
|
||||
<security:intercept-url pattern="/score/**" access="hasRole('admin')"/>
|
||||
<security:intercept-url pattern="/output/**" access="hasRole('admin')"/>
|
||||
<security:intercept-url pattern="/system/**" access="hasRole('admin')"/>
|
||||
<!-- 未登录状态下会自动跳转到/login登录页-->
|
||||
<security:form-login login-page="/login"
|
||||
default-target-url="/dashboard"
|
||||
|
@ -186,6 +186,7 @@
|
||||
<hr class="hr" style="margin: 1px"/>
|
||||
<!-- Tabs content -->
|
||||
<div class="tab-content" id="ex1-content">
|
||||
<%-- 查询--%>
|
||||
<div class="tab-pane fade show active" id="ex1-tabs-1" role="tabpanel"
|
||||
aria-labelledby="ex1-tab-1">
|
||||
<div class="card-body" style="min-width: 175px">
|
||||
@ -258,8 +259,10 @@
|
||||
<div class="row mb-2">
|
||||
<div class="col-12">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" value="true" id="range_enabler" name="range_enabler" />
|
||||
<label class="form-check-label" for="range_enabler">设定成绩范围</label>
|
||||
<input class="form-check-input" type="checkbox" value="true"
|
||||
id="range_enabler" name="range_enabler"/>
|
||||
<label class="form-check-label"
|
||||
for="range_enabler">设定成绩范围</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -276,6 +279,7 @@
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<%-- 修改--%>
|
||||
<div class="tab-pane fade" id="ex1-tabs-2" role="tabpanel"
|
||||
aria-labelledby="ex1-tab-2">
|
||||
<div class="card-body" style="min-width: 175px">
|
||||
@ -292,9 +296,9 @@
|
||||
<div class="row mb-2">
|
||||
<div class="col-12">
|
||||
<div class="form-outline">
|
||||
<input type="number" id="typeText7" class="form-control"
|
||||
<input type="number" id="typeText7" class="form-control" required
|
||||
name="score"/>
|
||||
<label class="form-label" for="typeText7">成绩</label>
|
||||
<label class="form-label" for="typeText7">成绩 (必填)</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -310,6 +314,7 @@
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<%-- 删除--%>
|
||||
<div class="tab-pane fade" id="ex1-tabs-3" role="tabpanel" aria-labelledby="ex1-tab-3">
|
||||
<div class="card-body" style="min-width: 175px">
|
||||
<form action="delinfo" method="post">
|
||||
@ -334,6 +339,7 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<%-- 添加--%>
|
||||
<div class="tab-pane fade" id="ex1-tabs-4" role="tabpanel" aria-labelledby="ex1-tab-4">
|
||||
<!-- <h5 class="card-header">信息添加</h5> -->
|
||||
<div class="card-body" style="min-width: 175px">
|
||||
|
@ -52,7 +52,7 @@ public class CourseController {
|
||||
}
|
||||
|
||||
@PostMapping(value = "/delinfo", produces = "application/x-www-form-urlencoded;charset=UTF-8")
|
||||
public String UpdateModInfo(@RequestParam(value = "id") int id,
|
||||
public String DeleteCourseInfo(@RequestParam(value = "id") int id,
|
||||
Model model) {
|
||||
Course temp = courseService.getCourseById(id);
|
||||
if (id <= 0 || temp == null) {
|
||||
|
@ -53,15 +53,15 @@ public class ScoreController {
|
||||
}
|
||||
|
||||
@PostMapping(value = "/query", produces = "application/x-www-form-urlencoded;charset=UTF-8")//学生信息查询(带条件)
|
||||
public String getQueryCourses(@RequestParam(value = "name", defaultValue = "null", required = false) String name,//学生姓名
|
||||
@RequestParam(value = "coursename", defaultValue = "null", required = false) String course_name,//课程名
|
||||
@RequestParam(value = "scoreid", defaultValue = "-1", required = false) int score_id,//成绩ID
|
||||
@RequestParam(value = "studentid", defaultValue = "-1", required = false) int student_id,//学号
|
||||
@RequestParam(value = "courseid", defaultValue = "-1", required = false) int course_id,//课程ID
|
||||
@RequestParam(value = "min", defaultValue = "-1", required = false) int min,//最低分
|
||||
@RequestParam(value = "max", defaultValue = "-1", required = false) int max,//最高分
|
||||
@RequestParam(value = "range_enabler", defaultValue = "false", required = false) boolean range_enabler,//是否启用分数范围
|
||||
Model model) throws IOException {
|
||||
public String getQueryScores(@RequestParam(value = "name", defaultValue = "null", required = false) String name,//学生姓名
|
||||
@RequestParam(value = "coursename", defaultValue = "null", required = false) String course_name,//课程名
|
||||
@RequestParam(value = "scoreid", defaultValue = "-1", required = false) int score_id,//成绩ID
|
||||
@RequestParam(value = "studentid", defaultValue = "-1", required = false) int student_id,//学号
|
||||
@RequestParam(value = "courseid", defaultValue = "-1", required = false) int course_id,//课程ID
|
||||
@RequestParam(value = "min", defaultValue = "-1", required = false) int min,//最低分
|
||||
@RequestParam(value = "max", defaultValue = "-1", required = false) int max,//最高分
|
||||
@RequestParam(value = "range_enabler", defaultValue = "false", required = false) boolean range_enabler,//是否启用分数范围
|
||||
Model model) throws IOException {
|
||||
|
||||
//username helper start
|
||||
String username = new UsernameHelper().getCurrentUsername();
|
||||
@ -93,4 +93,64 @@ public class ScoreController {
|
||||
model.addAttribute("scores", scores);
|
||||
return "scoreQueryResult";
|
||||
}
|
||||
|
||||
@PostMapping(value = "/modinfo", produces = "application/x-www-form-urlencoded;charset=UTF-8")
|
||||
public String UpdateScoreInfo(@RequestParam(value = "score", defaultValue = "-1", required = false) int score,
|
||||
@RequestParam(value = "id", defaultValue = "-1", required = false) int id,//成绩ID
|
||||
Model model) {
|
||||
if (id <= 0) {
|
||||
model.addAttribute("errorMessage", "修改失败,ID非法");
|
||||
} else if (score > 100 || score < 0) {
|
||||
model.addAttribute("errorMessage", "修改失败,分数非法");
|
||||
} else {
|
||||
Score score1 = new Score(id, score);
|
||||
int status_code = scoreService.updateScore(score1);
|
||||
if (status_code == 1) {
|
||||
model.addAttribute("successMessage", "修改成功");
|
||||
} else {
|
||||
model.addAttribute("errorMessage", "修改失败,可能是成绩不存在");
|
||||
}
|
||||
}
|
||||
return "redirect:/score/infomodv2";
|
||||
}
|
||||
|
||||
@PostMapping(value = "/delinfo", produces = "application/x-www-form-urlencoded;charset=UTF-8")
|
||||
public String DeleteScoreInfo(@RequestParam(value = "id") int id, //成绩ID
|
||||
Model model) {
|
||||
Score temp = scoreService.getScoreById(id);
|
||||
if (id <= 0 || temp == null) {
|
||||
model.addAttribute("errorMessage", "成绩信息删除失败,可能是ID非法或者成绩已删除");
|
||||
} else {
|
||||
int status_code = scoreService.deleteScore(id);
|
||||
if (status_code == 1) {
|
||||
model.addAttribute("successMessage", "学生信息删除成功");
|
||||
} else {
|
||||
model.addAttribute("errorMessage", "学生信息删除异常");
|
||||
}
|
||||
}
|
||||
return "redirect:/score/infomodv2";
|
||||
}
|
||||
|
||||
@PostMapping(value = "/addinfo", produces = "application/x-www-form-urlencoded;charset=UTF-8")
|
||||
public String InsertCourseInfo(@RequestParam(value = "studentid", defaultValue = "-1", required = false) int studentid,
|
||||
@RequestParam(value = "courseid", defaultValue = "-1", required = false) int courseid,
|
||||
@RequestParam(value = "score", defaultValue = "-1", required = false) int score,
|
||||
Model model) {
|
||||
if(studentid<=0){
|
||||
model.addAttribute("errorMessage", "添加失败,学号非法");
|
||||
} else if (courseid<=0) {
|
||||
model.addAttribute("errorMessage", "添加失败,课程ID非法");
|
||||
} else if(score>100||score<0){
|
||||
model.addAttribute("errorMessage", "添加失败,分数非法");
|
||||
} else {
|
||||
Score score1 = new Score(new Student(studentid), new Course(courseid), score);
|
||||
int status_code = scoreService.insertScore(score1);
|
||||
if (status_code == 1) {
|
||||
model.addAttribute("successMessage", "学生信息添加成功");
|
||||
} else {
|
||||
model.addAttribute("errorMessage", "学生信息添加失败");
|
||||
}
|
||||
}
|
||||
return "redirect:/score/infomodv2";
|
||||
}
|
||||
}
|
||||
|
@ -10,4 +10,12 @@ public interface ScoreDao {
|
||||
List<Score> getAllScore();
|
||||
|
||||
List<Score> getQueryScores(Score score);
|
||||
|
||||
int updateScore(Score score);
|
||||
|
||||
Score getScoreById(int id);
|
||||
|
||||
int deleteScore(int id);
|
||||
|
||||
int insertScore(Score score);
|
||||
}
|
||||
|
@ -26,4 +26,24 @@ public class ScoreDaoImpl implements ScoreDao {
|
||||
public List<Score> getQueryScores(Score score) {
|
||||
return sqlSession.selectList("getQueryScores", score);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateScore(Score score) {
|
||||
return sqlSession.update("updateScore", score);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Score getScoreById(int id) {
|
||||
return sqlSession.selectOne("getScoreById",id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteScore(int id) {
|
||||
return sqlSession.update("deleteScore", id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertScore(Score score) {
|
||||
return sqlSession.insert("insertScore", score);
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,12 @@ public class Score {
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
public Score(Student student, Course course, Integer score) {
|
||||
this.student = student;
|
||||
this.course = course;
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
public Integer getMin() {
|
||||
return min;
|
||||
}
|
||||
|
@ -14,6 +14,14 @@ public class ScoreService {
|
||||
this.scoreDao = scoreDao;
|
||||
}
|
||||
|
||||
public int deleteScore(int id) {
|
||||
return scoreDao.deleteScore(id);
|
||||
}
|
||||
|
||||
public Score getScoreById(int id) {
|
||||
return scoreDao.getScoreById(id);
|
||||
}
|
||||
|
||||
public List<Score> getAllScores() {
|
||||
return scoreDao.getAllScore();
|
||||
}
|
||||
@ -21,4 +29,12 @@ public class ScoreService {
|
||||
public List<Score> getQueryScores(Score score) {
|
||||
return scoreDao.getQueryScores(score);
|
||||
}
|
||||
|
||||
public int updateScore(Score score) {
|
||||
return scoreDao.updateScore(score);
|
||||
}
|
||||
|
||||
public int insertScore(Score score) {
|
||||
return scoreDao.insertScore(score);
|
||||
}
|
||||
}
|
||||
|
@ -55,5 +55,29 @@
|
||||
</if>
|
||||
</trim>
|
||||
</select>
|
||||
|
||||
<update id="updateScore" parameterType="cyou.chenx221.pojo.Score">
|
||||
UPDATE score
|
||||
<set>
|
||||
<if test="score != null">
|
||||
Score = #{score}
|
||||
</if>
|
||||
</set>
|
||||
WHERE ScoreID = #{scoreID};
|
||||
</update>
|
||||
<select id="getScoreById" parameterType="int" 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 AND ScoreID = #{id};
|
||||
</select>
|
||||
<update id="deleteScore" parameterType="int">
|
||||
UPDATE score
|
||||
SET invalid = 1
|
||||
WHERE ScoreID = #{id};
|
||||
</update>
|
||||
<insert id="insertScore" parameterType="cyou.chenx221.pojo.Score">
|
||||
INSERT INTO score (Score, StudentID, CourseID)
|
||||
VALUES (#{score}, #{student.id}, #{course.courseID});
|
||||
</insert>
|
||||
</mapper>
|
@ -186,6 +186,7 @@
|
||||
<hr class="hr" style="margin: 1px"/>
|
||||
<!-- Tabs content -->
|
||||
<div class="tab-content" id="ex1-content">
|
||||
<%-- 查询--%>
|
||||
<div class="tab-pane fade show active" id="ex1-tabs-1" role="tabpanel"
|
||||
aria-labelledby="ex1-tab-1">
|
||||
<div class="card-body" style="min-width: 175px">
|
||||
@ -258,8 +259,10 @@
|
||||
<div class="row mb-2">
|
||||
<div class="col-12">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" value="true" id="range_enabler" name="range_enabler" />
|
||||
<label class="form-check-label" for="range_enabler">设定成绩范围</label>
|
||||
<input class="form-check-input" type="checkbox" value="true"
|
||||
id="range_enabler" name="range_enabler"/>
|
||||
<label class="form-check-label"
|
||||
for="range_enabler">设定成绩范围</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -276,6 +279,7 @@
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<%-- 修改--%>
|
||||
<div class="tab-pane fade" id="ex1-tabs-2" role="tabpanel"
|
||||
aria-labelledby="ex1-tab-2">
|
||||
<div class="card-body" style="min-width: 175px">
|
||||
@ -292,9 +296,9 @@
|
||||
<div class="row mb-2">
|
||||
<div class="col-12">
|
||||
<div class="form-outline">
|
||||
<input type="number" id="typeText7" class="form-control"
|
||||
<input type="number" id="typeText7" class="form-control" required
|
||||
name="score"/>
|
||||
<label class="form-label" for="typeText7">成绩</label>
|
||||
<label class="form-label" for="typeText7">成绩 (必填)</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -310,6 +314,7 @@
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<%-- 删除--%>
|
||||
<div class="tab-pane fade" id="ex1-tabs-3" role="tabpanel" aria-labelledby="ex1-tab-3">
|
||||
<div class="card-body" style="min-width: 175px">
|
||||
<form action="delinfo" method="post">
|
||||
@ -334,6 +339,7 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<%-- 添加--%>
|
||||
<div class="tab-pane fade" id="ex1-tabs-4" role="tabpanel" aria-labelledby="ex1-tab-4">
|
||||
<!-- <h5 class="card-header">信息添加</h5> -->
|
||||
<div class="card-body" style="min-width: 175px">
|
||||
|
Reference in New Issue
Block a user