From d71f1fd267230873dcf78d812695e7704ef5d87c Mon Sep 17 00:00:00 2001 From: Chenx221 Date: Tue, 13 Jun 2023 13:16:02 +0800 Subject: [PATCH] Score Manage completed Signed-off-by: Chenx221 --- .../controller/CourseController.class | Bin 5291 -> 5310 bytes .../chenx221/controller/ScoreController.class | Bin 4745 -> 6824 bytes .../cyou/chenx221/helper/CsvHelper.class | Bin 5957 -> 6719 bytes .../cyou/chenx221/mapper/ScoreDao.class | Bin 471 -> 631 bytes .../chenx221/mapper/impl/ScoreDaoImpl.class | Bin 1258 -> 1991 bytes .../classes/cyou/chenx221/pojo/Score.class | Bin 3016 -> 3218 bytes .../cyou/chenx221/service/ScoreService.class | Bin 1012 -> 1497 bytes .../WEB-INF/classes/mapper/ScoreMapper.xml | 26 +++++- .../WEB-INF/classes/spring-security.xml | 1 + .../WEB-INF/views/scoreopv2.jsp | 14 +++- .../chenx221/controller/CourseController.java | 2 +- .../chenx221/controller/ScoreController.java | 78 ++++++++++++++++-- .../java/cyou/chenx221/mapper/ScoreDao.java | 8 ++ .../chenx221/mapper/impl/ScoreDaoImpl.java | 20 +++++ .../main/java/cyou/chenx221/pojo/Score.java | 6 ++ .../cyou/chenx221/service/ScoreService.java | 16 ++++ .../src/main/resources/mapper/ScoreMapper.xml | 26 +++++- project2/web/WEB-INF/views/scoreopv2.jsp | 14 +++- 18 files changed, 191 insertions(+), 20 deletions(-) diff --git a/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/cyou/chenx221/controller/CourseController.class b/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/cyou/chenx221/controller/CourseController.class index b148a0beee579f127fb6d2099b51fabd00df2427..661bae220b0a3953d86b22cc6b15a4b3b5868b0f 100644 GIT binary patch delta 150 zcmZ3jxlfbp)W2Q(7#J9A88&X@QsNR7a7oQcElG9GFD)ug^~_7lXJjzem^^{oWO5PL z4{qMjf|SIPRNwp*&&{da(^;99GpyMBU%;D@aph!hArHP)3{#>QrUH#)WT*hjEEJl~ n$haCLqXm~?Vps!|XJS~(&;+D~fUI>udOc7_Z!`mAF~bG`QF1Em delta 124 zcmdm|xmuI!)W2Q(7#J9A88&R>QsUy`4J}AXEJ^jvPuXnAWx}|*mU|K_^K^#gn}r0u z85vhhjuZ0WTgfmbieV~H6C*&V3=_j@pga@98ipnyEd*q(1=8z) NI(nlS7>gO!0{|o9AlCo@ diff --git a/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/cyou/chenx221/controller/ScoreController.class b/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/cyou/chenx221/controller/ScoreController.class index 3fb6a87f74cc4bf2e9e8729dac17a065421e94d3..209f116da6c8fbbf1f2ad4f90f3f16d73ea3b82b 100644 GIT binary patch delta 2690 zcmZuz=~t9x6#u=mFf+`sje+7oW{b`c9I}*5b2+%=gmzAw9<@@G5l|Lmz|@p+Nkhej zMhy)RcT5owWf28iT(ZTiKcEjeBYvvWw+gG@^Sm>|Nb`Yt?|bike)qY*yS(gprfEX- z?SC%!0+@oI+oA__bB$Q6VEDbh^Zxzaz7uWz7f=3nrP?|3L4AY2{eThgDzFVP`l`13 z545Td(U^!O7U;25fy3_oSDQX!nFY&{r@&mXIxn}}_2%-@GM9o>ySKqOa;d{<#0mu# z71Cd|&$si45d{jy4h^!mrGM*He{BnW?)RLz*R|W%T&sF3KrJ`dTrcth7gs=J3{ryMog~cF>N9MF9qS<$4i?6H8h_$5E-`V5a*%;!S zSiZfTLEhIhpCJzYExq@fb_FkO#D)kMqBK)NwV94eQ5%nfB>UWzxodJWi*ifyGo2;n zu6$S7WXJqy%tEE8;TGYyRlz*F_m=k6`NA>^+bq~FD_L0Lc9p4A8&NeRG4+HyyGZbg6TR_KkG~w{7QHi${JYC@ z%PZVVmY3$Sl{AGcwlTA~G_O#eiJLiC9TnvTdk7>=SMDlaE&N$S)j!@T)0t6PQRa53 z2PQCV=!nUfnVToEy}y{wcnna;%`RwA&9Rxyr-skyv`#2#&t8I|jc*$4=5H*t{2d7$ zY%n1Od-#^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C&dJw|jKGy2s6$BP0bMp z3MV54+GSX^xt-z7UX+VT4gcU@H!kYfi%Z6y>`?(@RZfM-Ft+7XIh^ug+jB}b5nf{` zv^};HWjGFnfB`22n~VJk&O982T&)^{=%=Azl)ZEV`8dg5w*v4IUgk{T6`Vo_P7LJb zCWII@#_}GC%dm%$js3{P7+z(16E@;Cyv~zO;ToLA8*qswaN|vSHE}gsa0YKd6;ABI z+c--P#9sRdX`N%7!1W@4cW5c_2tVGXm4QCIkN4OdtoUhsfDhqZi%C3+k7&B^F|Sg~ zW38)9wRRYK0t#jnLj==5DC~^#9 z`7mmIeup$y`ut8gKIQYfTKus0f+$P)y+05}%bi&P|xWsPBl&iaJkB7r2@Ow|MRzCVbr%_Kp%tJy?#52~VwB#4to=jiNQo{s1*`Sd zkfQ5NVeQ5J*5^RQ12ecel+BN+lsm}*L!WQzf-V(@DK%m;xCRW^ZsVLEaZ1j MgAj^v2p5X}1NT{cUjP6A diff --git a/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/cyou/chenx221/mapper/ScoreDao.class b/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/cyou/chenx221/mapper/ScoreDao.class index 905e96b1f0ac55df070eeaec3977b5cc005eeb80..29e9e0db11ee307ae6e0645ad15f3c5b9b0e4934 100644 GIT binary patch delta 212 zcmcc4{GEmC)W2Q(7#J9A8N@eosWH}bmlmWXmZSzJ=NF|iGRSK9BvL+KU=2aLO z8R{40XXWdIC9O3*85wxeQ%k@+r%KNhkaAB=+!`1exKmPdQsIWP096Cc;Lgk|PA!5M z!#G)=v5=8%@~sK$?$%A504{2!d%LkT?SqgD{vBVGsq{s5Pb=SwmnV@EgN<;{7YbKWmMGhYX@-+q7k4B#F%kF(FIoQ6rr z9lmV3p4i%b(G@uuuyl;!JYgWz31xqQrg}~q69l~_yr6RFwbRVvA}(o|)G>uJVQAky za_zR;Y1vN46D`ptXh&}QP&A$qN)=~%qpzYaJ5KAUVup}85N)yRH9CS&t0aoIysp1V zRv}_1h9YiZaVqsitdMjG=h>~#)AH=I^>xu)ZKkSo+R+03lt;q|rc=jy+8kXz{j5Zc_!D9p)5&MimPlUUYyH_-EuLcJ$^6 yRZ&od_Vn$2(OsSC@m~pj1&c$wzErbJr}8()|IP6+z>po&j@TP%&iFTQ0(<}&=NEMV diff --git a/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/cyou/chenx221/pojo/Score.class b/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/cyou/chenx221/pojo/Score.class index 01c2858644a23c0057f4667ec6aa21f0d5afc235..ee6c73210cacf61904877b9660744e105c72aa09 100644 GIT binary patch delta 523 zcmXZYOD{t~6bJDC+}mM#ODWaH!Xw;Lr6}rM&#G7Ju^?h^MWQ0sK7zz7Z0*IOkwzk6 zWg#}~B@*95#Q#p4n>#b-%x}(_%vUjDmHXcF8K-qG5sUk9XEe^dVEo=#kT&IN22K=Tk|C@CHf)I&8jD`;Nu)l zJVGS;%VZ!Q~i%tM#L$c$jzFSvo>4C&Rzef^gjq!pWd$$S zfI8UB4j>7kUDYM}^rvdE2Qj42{9%2rLNduNgZkcy>RYAkVI=jPaz)CxRMq{`rRl~! z7ieQu!Ec0i%eAg`0vI{X3m++mvd%j5c`PA&++RUfD*dT($I#N+P#>pNgUxggcA$P zsH@+=NSvy7y&7l5{w$kTqjV$A)~>wDrW;{+(~9lw9!HA57SUTE&u=k diff --git a/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/cyou/chenx221/service/ScoreService.class b/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/cyou/chenx221/service/ScoreService.class index 343d84887684a670e6046db1b00849b7d1744775..0ff5fbf836a3f4a58b0ca46be904f7b63b232c54 100644 GIT binary patch literal 1497 zcmaizZBG+H5Xb*p3Z?DwsG<}BMZ~rsC-|6v7#~7x(rC1%?~m(R7O%I>-5%QSx8C2E%Bm z%@>YjSgf87XgTdR4`P3E*vexZ6B$fen8Gx}{6KGpe1m&jag&ZAU96NUnsCv=CCo5b zO|Hz{vreT!G`dgZZ_5K2XE&*@SeQkDxD@!*^Sa#WVyS9miIni{stA>FzG`6}3k>7r z{3hZ-$GC?KYsLOq&Lmy4a2-pOHflGV<8tN)VN9LN7H*n2;gj-lsnnBXTvFsxowRx` z8=PUHDt!JbYVGmhowMiB$#hk^j#qaAq3!NrTI~xeY&lWaS?%6pNC^^~Rbu`B$w=YZ znrQltiULZr-lOSu0)C=3I|LmL^-si5=@njeP1d^3F%X%#i|UNcGwPt-+Ui9E&fpkAM8-^fJ@bB(}2XY zu|<6!r2zy;H9b+Z%g}xpE41DsYnRUTeXjfiti1XinXhD}P^5JnL$r<|O}i{6P$Fw4 z_C^`2WKo=7@Gd*5?U>8#O zl7P*e16xOdlIv>k8Mv;NUUr1btcO)FEQ|bfZE=;h$#;j&Xdb(yQ#Gz0VXpUC3w@ro wflWfi(7Uvw(WF&BF9}`j6>e!Dl<9fx1G~`+TNwyTkzBfK_wj(fx^EAGzi;3xVgLXD delta 311 zcmYk0O-{m46otQ6w2gg563~KwSbj~~DGZH_7`PC(!N3)mZbSpdz@Q6o2eJ;wg!5WL z$V=|K=iYO_oIm>?gulB@0X*~c5f*u3hW=H=HF5rGX8G26|7sD9yL?u1L{S;i)S4wThsDRS><_rlFJ@*SrU5MSJ1v7gAzZC7^(5K G8p9r178+gv diff --git a/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/mapper/ScoreMapper.xml b/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/mapper/ScoreMapper.xml index 840fe21..a858bc5 100644 --- a/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/mapper/ScoreMapper.xml +++ b/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/mapper/ScoreMapper.xml @@ -55,5 +55,29 @@ - + + UPDATE score + + + Score = #{score} + + + WHERE ScoreID = #{scoreID}; + + + + UPDATE score + SET invalid = 1 + WHERE ScoreID = #{id}; + + + INSERT INTO score (Score, StudentID, CourseID) + VALUES (#{score}, #{student.id}, #{course.courseID}); + \ No newline at end of file diff --git a/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/spring-security.xml b/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/spring-security.xml index 55b44eb..af4a99b 100644 --- a/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/spring-security.xml +++ b/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/spring-security.xml @@ -25,6 +25,7 @@ +
+ <%-- 查询--%>
@@ -258,8 +259,10 @@
- - + +
@@ -276,6 +279,7 @@
+ <%-- 修改--%>
@@ -292,9 +296,9 @@
- - +
@@ -310,6 +314,7 @@
+ <%-- 删除--%>
@@ -334,6 +339,7 @@
+ <%-- 添加--%>
diff --git a/project2/src/main/java/cyou/chenx221/controller/CourseController.java b/project2/src/main/java/cyou/chenx221/controller/CourseController.java index ee2c862..bc37fac 100644 --- a/project2/src/main/java/cyou/chenx221/controller/CourseController.java +++ b/project2/src/main/java/cyou/chenx221/controller/CourseController.java @@ -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) { diff --git a/project2/src/main/java/cyou/chenx221/controller/ScoreController.java b/project2/src/main/java/cyou/chenx221/controller/ScoreController.java index c1588da..cc60157 100644 --- a/project2/src/main/java/cyou/chenx221/controller/ScoreController.java +++ b/project2/src/main/java/cyou/chenx221/controller/ScoreController.java @@ -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"; + } } diff --git a/project2/src/main/java/cyou/chenx221/mapper/ScoreDao.java b/project2/src/main/java/cyou/chenx221/mapper/ScoreDao.java index 563e492..53a9202 100644 --- a/project2/src/main/java/cyou/chenx221/mapper/ScoreDao.java +++ b/project2/src/main/java/cyou/chenx221/mapper/ScoreDao.java @@ -10,4 +10,12 @@ public interface ScoreDao { List getAllScore(); List getQueryScores(Score score); + + int updateScore(Score score); + + Score getScoreById(int id); + + int deleteScore(int id); + + int insertScore(Score score); } diff --git a/project2/src/main/java/cyou/chenx221/mapper/impl/ScoreDaoImpl.java b/project2/src/main/java/cyou/chenx221/mapper/impl/ScoreDaoImpl.java index ac44ab7..c3d9c5a 100644 --- a/project2/src/main/java/cyou/chenx221/mapper/impl/ScoreDaoImpl.java +++ b/project2/src/main/java/cyou/chenx221/mapper/impl/ScoreDaoImpl.java @@ -26,4 +26,24 @@ public class ScoreDaoImpl implements ScoreDao { public List 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); + } } diff --git a/project2/src/main/java/cyou/chenx221/pojo/Score.java b/project2/src/main/java/cyou/chenx221/pojo/Score.java index 837b881..f7ae8e3 100644 --- a/project2/src/main/java/cyou/chenx221/pojo/Score.java +++ b/project2/src/main/java/cyou/chenx221/pojo/Score.java @@ -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; } diff --git a/project2/src/main/java/cyou/chenx221/service/ScoreService.java b/project2/src/main/java/cyou/chenx221/service/ScoreService.java index bf4e9ef..02bcda4 100644 --- a/project2/src/main/java/cyou/chenx221/service/ScoreService.java +++ b/project2/src/main/java/cyou/chenx221/service/ScoreService.java @@ -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 getAllScores() { return scoreDao.getAllScore(); } @@ -21,4 +29,12 @@ public class ScoreService { public List 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); + } } diff --git a/project2/src/main/resources/mapper/ScoreMapper.xml b/project2/src/main/resources/mapper/ScoreMapper.xml index 840fe21..a858bc5 100644 --- a/project2/src/main/resources/mapper/ScoreMapper.xml +++ b/project2/src/main/resources/mapper/ScoreMapper.xml @@ -55,5 +55,29 @@ - + + UPDATE score + + + Score = #{score} + + + WHERE ScoreID = #{scoreID}; + + + + UPDATE score + SET invalid = 1 + WHERE ScoreID = #{id}; + + + INSERT INTO score (Score, StudentID, CourseID) + VALUES (#{score}, #{student.id}, #{course.courseID}); + \ No newline at end of file diff --git a/project2/web/WEB-INF/views/scoreopv2.jsp b/project2/web/WEB-INF/views/scoreopv2.jsp index bd04123..3eb60cd 100644 --- a/project2/web/WEB-INF/views/scoreopv2.jsp +++ b/project2/web/WEB-INF/views/scoreopv2.jsp @@ -186,6 +186,7 @@
+ <%-- 查询--%>
@@ -258,8 +259,10 @@
- - + +
@@ -276,6 +279,7 @@
+ <%-- 修改--%>
@@ -292,9 +296,9 @@
- - +
@@ -310,6 +314,7 @@
+ <%-- 删除--%>
@@ -334,6 +339,7 @@
+ <%-- 添加--%>