From 91fea883f8dc07b202c540693de4c0477ed786d1 Mon Sep 17 00:00:00 2001 From: Chenx221 Date: Fri, 9 Jun 2023 13:07:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=88=A0=E9=99=A4=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=B7=B2=E5=AE=8C=E6=88=90*=E9=9D=9E=E7=9C=9F?= =?UTF-8?q?=E6=AD=A3=E6=84=8F=E4=B9=89=E4=B8=8A=E5=88=A0=E9=99=A4=20?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=A2=9E=E5=8A=A0=E6=9C=AA=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Chenx221 --- .../controller/StudentController.class | Bin 5038 -> 5570 bytes .../chenx221/mapper/impl/StudentDaoImpl.class | Bin 2284 -> 2270 bytes .../classes/cyou/chenx221/pojo/Student.class | Bin 3031 -> 3203 bytes .../chenx221/service/StudentService.class | Bin 1672 -> 1677 bytes .../WEB-INF/classes/mapper/StudentMapper.xml | 20 +++++++++- .../WEB-INF/views/studentinfomodv2.jsp | 4 +- .../controller/StudentController.java | 35 +++++++++++++++--- .../java/cyou/chenx221/mapper/StudentDao.java | 3 +- .../chenx221/mapper/impl/StudentDaoImpl.java | 4 +- .../main/java/cyou/chenx221/pojo/Student.java | 10 ++--- .../cyou/chenx221/service/StudentService.java | 4 +- .../main/resources/mapper/StudentMapper.xml | 20 +++++++++- .../web/WEB-INF/views/studentinfomodv2.jsp | 13 +------ 13 files changed, 78 insertions(+), 35 deletions(-) diff --git a/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/cyou/chenx221/controller/StudentController.class b/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/cyou/chenx221/controller/StudentController.class index 7ae77a1f10adda230e6924e57c4f351140d419fa..7e57fc102e88d6c13800169461d2d627743d7443 100644 GIT binary patch delta 1829 zcmcIk-ES0C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Bg7ef5n(g*hu-o#V1s#RB zWZ^Qd$fj`Vs(daQX;&2*1Xpf~oIIja_HMA#o?hGO1oJ6eli!7F&J!x~jZxTNG?plz z?u0zAMIetqO?Z>?#n8z9fw@iH>mUdW!(#6#-Vfmh=L?*za1iJlQ?>2lY|@2V(<_ zY^_>9_HE{C&IvjD$<{>*Y3+T|*8F}05S z+@Po~N7Z6!>ct+W1%AiXHO>mpMIO~`1s-tiA=V>SGjeEa)(p>l)`(zTHM!8-%z!yN kzOfz6JLGOKck?gYxj}9p+xRE;^e?W!Bkg=EemakVpM_LlVgLXD diff --git a/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/cyou/chenx221/pojo/Student.class b/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/cyou/chenx221/pojo/Student.class index c1a05b90c4c004aa36cb97a62d5352bb45fd0ec5..0f30cfe9e539b3de752cb46aab117b8bd41111db 100644 GIT binary patch literal 3203 zcmcJR-BR0D5XV=>lEDa)@Zpq@28SjNH~|&X(58S}LPF!#d;}ARepeV_L~V(YWeV@n zhv-Ew+L?OV=|vx)57p^^kA!3kd3x2%L^?WW&wqcrXV2ol|M~MTB3h;WG$p7nMM;%p zQY5;5qMzwnUAJo5_Q8o!btO_(Ov`i&67|i@R?^f@11U`SLp_gNOY@uVYjsEv0srZdx&q?1N^jF0 ziISGyFeDo3a8q_2)2a!ptV(y;s;_CBv-&$K-J|K&r5WBQ zpB~$m!8`LRJ>;2`&n3~sZp(7bhEXw_=0V+9vn<=yUDLLJyi~HCn$|pJkRu0#KiJOq z+L7%vbXU^@ON|}wL1RO#EJOZOcU{A=BuZc4-`wWr+#zx^P&R9p?zS9+dM}cWm8+o_ zpp?V`R`6Q453%W5$+V2ER^z~M_H@v4#_XzIujr1+-~MFMJvM=VyVUz!A)T%n?(XHW zp|XmYYIaNwVtqY0zL6Qfkir9$D0gMDM;L<;4z)&SBEc_njG69GE>17Qc@Q;^b;1%d zkc&w4_$8OPM*h7($TBc^J>x5OEwexh0$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HDX$H6X78>6u zMl>MIV%&Meh~6Sb^c0flBg``xi}*j^rUe+Hi3kJq0x_b~;p3v1m+&186!QtJEzvTb zD|k~eN*EKR-%0vanBK)RDHgBeGm-2X(8qKSZxXH2eLQ*d21H|QU0Ujr^c!X|;@xSn zdJ_((guz6a$R}fbPKU+z=o) zSD#^r8*UPRCrZ$Ey?l<@T4c^LVbu8uREgH3bCwC`Yzc_VLlC(hIA@QM_sfTu4TGqW zAW!HEZ}Y(6Wy2u%0rFr72p1%SJdFg&g+U%gf;@``$%R4I0J1&=gl`0cY|<8<;VR09 zL7qf{d`a8h=7Egl!yuag*%|`kUP+0bM`olD26-L{@*+ATg)qn~fRu-Ta0}p!DE^gr z?Olm<=?|LXdm6YFSzHgIJ&Myl%KadqnfC8$ntw1sv41sqW$N zDJ^#?TUzN-u2hJ3DPJlix>P6?l3kkZM>dO&M|2313e=A%OJC7ARjEK<(=@$CxBEuW zy>Qiix}xZk+`x*WPx9q2@~fmw!WoZ{J1$3=V8T9z+h}XR ss0)|jR{bin9%sY#*ofR*j;_bRsk!doA+JrLaJkQOu9@nK=7yA|IFaQ7m diff --git a/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/cyou/chenx221/service/StudentService.class b/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/cyou/chenx221/service/StudentService.class index 9ce1077ecc223b4e52ce806bffed8ef7334feea4..709e690c133c470d97d2f6ec03ad981304d851b3 100644 GIT binary patch delta 114 zcmeC+?d9b<^>5cc1_lOO2Ahps$C!kfGE*2C7(E#oIEzb4Q&RIvJX1E`WAb8RG?}c) z>dtKnRLaC)#=yv+IQasr?cn7)^>5cc1_lOO2J4Mn$C&syi%UvVQu9hYQy3W-JvTpQ@?x6&fQ4hSDXRm! o2~ZsqgX!cNRzE1)Z1P1Uwi;WAusK+b1%oA!W@BJvuwq~U0G9j}eE + - + + UPDATE student SET @@ -49,4 +58,11 @@ WHERE id = #{id} + + UPDATE student + SET removed = 1 + WHERE id = #{id} + + + diff --git a/project2/out/artifacts/project2_war_exploded/WEB-INF/views/studentinfomodv2.jsp b/project2/out/artifacts/project2_war_exploded/WEB-INF/views/studentinfomodv2.jsp index edfb498..e81b343 100644 --- a/project2/out/artifacts/project2_war_exploded/WEB-INF/views/studentinfomodv2.jsp +++ b/project2/out/artifacts/project2_war_exploded/WEB-INF/views/studentinfomodv2.jsp @@ -179,7 +179,7 @@ - +
-
+
diff --git a/project2/src/main/java/cyou/chenx221/controller/StudentController.java b/project2/src/main/java/cyou/chenx221/controller/StudentController.java index 4b15c50..d5f6a31 100644 --- a/project2/src/main/java/cyou/chenx221/controller/StudentController.java +++ b/project2/src/main/java/cyou/chenx221/controller/StudentController.java @@ -114,15 +114,38 @@ public class StudentController { return "studentinfomodv2"; } - @PostMapping(value = "/delinfo", produces = "application/x-www-form-urlencoded;charset=UTF-8")//处理学生信息修改请求 + @PostMapping(value = "/delinfo", produces = "application/x-www-form-urlencoded;charset=UTF-8") public String UpdateModInfo(@RequestParam(value = "id", defaultValue = "-1", required = false) int id, Model model) { - Student student; - if (id <= -1) { - model.addAttribute("errorMessage", "ID异常,学生信息修改失败"); + Student temp = studentService.getStudentById(id); + if (id <= 0 || temp == null) { + model.addAttribute("errorMessage", "学生信息删除失败,可能是ID非法或者学生已删除"); } else { - student = new Student(id); - studentService.deleteStudent(student); +// Student student = new Student(id); + studentService.deleteStudent(id); + model.addAttribute("successMessage", "学生信息删除成功"); + } + return "redirect:/student/infomodv2"; + } + + @PostMapping(value = "/addinfo", produces = "application/x-www-form-urlencoded;charset=UTF-8") + public String InsertStudentInfo(@RequestParam(value = "name", defaultValue = "null", required = false) String name, + @RequestParam(value = "birthday", defaultValue = "#{null}", required = false) Date birthday, + @RequestParam(value = "sex", defaultValue = "null", required = false) String sex, + @RequestParam(value = "phone", defaultValue = "null", required = false) String phone, + @RequestParam(value = "classes", defaultValue = "", required = false) String classes, + Model model) { + Student student; + if (name.equals("null")) name = null; + if (sex.equals("null")) sex = null; + if (phone.equals("null")) phone = null; + if (classes.equals("")) classes = null; + + if (id <= -1) { + model.addAttribute("errorMessage", "学生信息修改失败"); + } else { + student = new Student(id, name, sex, birthday, phone, classes); + studentService.updateStudent(student); model.addAttribute("successMessage", "学生信息修改成功"); } return "redirect:/student/modstep1"; diff --git a/project2/src/main/java/cyou/chenx221/mapper/StudentDao.java b/project2/src/main/java/cyou/chenx221/mapper/StudentDao.java index 72c04a9..e35fcab 100644 --- a/project2/src/main/java/cyou/chenx221/mapper/StudentDao.java +++ b/project2/src/main/java/cyou/chenx221/mapper/StudentDao.java @@ -3,13 +3,12 @@ package cyou.chenx221.mapper; import cyou.chenx221.pojo.Student; import org.springframework.stereotype.Repository; -import java.util.Date; import java.util.List; @Repository public interface StudentDao { void insertStudent(Student student); - void deleteStudent(Student student); + void deleteStudent(int id); Student getStudentById(int studentId); List getAllStudents(); diff --git a/project2/src/main/java/cyou/chenx221/mapper/impl/StudentDaoImpl.java b/project2/src/main/java/cyou/chenx221/mapper/impl/StudentDaoImpl.java index 9eb0429..aebe2f4 100644 --- a/project2/src/main/java/cyou/chenx221/mapper/impl/StudentDaoImpl.java +++ b/project2/src/main/java/cyou/chenx221/mapper/impl/StudentDaoImpl.java @@ -32,8 +32,8 @@ public class StudentDaoImpl implements StudentDao { } @Override - public void deleteStudent(Student student) { - sqlSession.delete("deleteStudent", student); + public void deleteStudent(int id) { + sqlSession.update("deleteStudent", id); } @Override diff --git a/project2/src/main/java/cyou/chenx221/pojo/Student.java b/project2/src/main/java/cyou/chenx221/pojo/Student.java index 5311827..d0f63ea 100644 --- a/project2/src/main/java/cyou/chenx221/pojo/Student.java +++ b/project2/src/main/java/cyou/chenx221/pojo/Student.java @@ -2,8 +2,6 @@ package cyou.chenx221.pojo; import org.springframework.format.annotation.DateTimeFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; @@ -17,17 +15,17 @@ public class Student { private String classes; private List classess; - private Integer removed; + private int removed; - public Student(Integer id) { + public Student(int id) { this.id = id; } - public Integer getRemoved() { + public int getRemoved() { return removed; } - public void setRemoved(Integer removed) { + public void setRemoved(int removed) { this.removed = removed; } diff --git a/project2/src/main/java/cyou/chenx221/service/StudentService.java b/project2/src/main/java/cyou/chenx221/service/StudentService.java index e0fda02..45ff4d5 100644 --- a/project2/src/main/java/cyou/chenx221/service/StudentService.java +++ b/project2/src/main/java/cyou/chenx221/service/StudentService.java @@ -19,8 +19,8 @@ public class StudentService { studentDao.insertStudent(student); } - public void deleteStudent(Student student) { - studentDao.deleteStudent(student); + public void deleteStudent(int id) { + studentDao.deleteStudent(id); } public Student getStudentById(int studentId) { diff --git a/project2/src/main/resources/mapper/StudentMapper.xml b/project2/src/main/resources/mapper/StudentMapper.xml index 130a60e..3cb708e 100644 --- a/project2/src/main/resources/mapper/StudentMapper.xml +++ b/project2/src/main/resources/mapper/StudentMapper.xml @@ -4,9 +4,16 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > + - + + UPDATE student SET @@ -49,4 +58,11 @@ WHERE id = #{id} + + UPDATE student + SET removed = 1 + WHERE id = #{id} + + + diff --git a/project2/web/WEB-INF/views/studentinfomodv2.jsp b/project2/web/WEB-INF/views/studentinfomodv2.jsp index edfb498..263cac6 100644 --- a/project2/web/WEB-INF/views/studentinfomodv2.jsp +++ b/project2/web/WEB-INF/views/studentinfomodv2.jsp @@ -179,22 +179,13 @@ - +
-
-
-
- - -
-
-
@@ -256,7 +247,7 @@
- +