From 14734623170897c56465b149d16cf5bcebe94707 Mon Sep 17 00:00:00 2001 From: zhai_lw Date: Tue, 15 Jan 2019 16:04:53 +0800 Subject: [PATCH] Merge remote-tracking branch 'remotes/origin/hechu1' # Conflicts: # src/core/process/C_TeacherSearchStudent.java # web/jsFile/upload_action.js --- src/core/process/C_StudentSearchTeacher.java | 19 +++++++++++++++++++ src/core/process/C_StudentSelectTeacher.java | 19 +++++++++++++++++++ src/core/process/C_TeacherSearchStudent.java | 11 ++--------- src/core/process/C_TeacherSelectStudent.java | 19 +++++++++++++++++++ src/core/process/Utils.java | 18 ++++++++++++++++++ src/filter/OnlineCheck.java | 2 +- src/gdms/Configuration.java | 2 +- src/servlet/S_StudentSelectTeacher.java | 1 + .../S_StudentUploadFinishedProduct.java | 13 +++++-------- web/jsFile/upload_action.js | 2 +- 10 files changed, 86 insertions(+), 20 deletions(-) create mode 100644 src/core/process/Utils.java diff --git a/src/core/process/C_StudentSearchTeacher.java b/src/core/process/C_StudentSearchTeacher.java index 65931e4..a519a53 100644 --- a/src/core/process/C_StudentSearchTeacher.java +++ b/src/core/process/C_StudentSearchTeacher.java @@ -36,6 +36,25 @@ public class C_StudentSearchTeacher extends TempProcess{ TeacherInfo.put("phone_number",s[4]); return TeacherInfo; } + public List> _search() throws Exception{ + if(!check()) throw new GExcptInit("teacherId Attrs init error!"); + Search search = new Search() ; + search.setOptions(new HashMap<>()); + search.addOptions("table",table); + List fields = new ArrayList<>(); + fields.add("*"); + search.addOptions("field",fields); + Map limits = new HashMap<>(); + limits.put("id",this.getTeacherID()); + search.addOptions("limits",limits); + search.addOptions("start",0); + search.addOptions("end",10); + Map options = search.execute(null); + List result = (List) options.get("result"); + List> teachersInfo = new ArrayList<>(); + core.process.Utils.formatResult(result, teachersInfo); + return teachersInfo; + } protected boolean check() { if(this.getTeacherID()==null) diff --git a/src/core/process/C_StudentSelectTeacher.java b/src/core/process/C_StudentSelectTeacher.java index ee8ada0..596ca94 100644 --- a/src/core/process/C_StudentSelectTeacher.java +++ b/src/core/process/C_StudentSelectTeacher.java @@ -1,5 +1,6 @@ package core.process; +import core.operation.Search; import core.operation.Select; import error.GExcptInit; @@ -20,6 +21,24 @@ public class C_StudentSelectTeacher extends TempProcess { select.addOptions("teacher_id",this.getTeacherId()); Map options=select.execute(null); } + public List> search(String teacherId) throws Exception{ + Search search = new Search() ; + search.setOptions(new HashMap<>()); + search.addOptions("table","teacher"); + List fields = new ArrayList<>(); + fields.add("*"); + search.addOptions("field",fields); + Map limits = new HashMap<>(); + limits.put("id",teacherId); + search.addOptions("limits",limits); + search.addOptions("start",0); + search.addOptions("end",10); + Map options = search.execute(null); + List result = (List) options.get("result"); + List> teachersInfo = new ArrayList<>(); + core.process.Utils.formatResult(result, teachersInfo); + return teachersInfo; + } protected boolean check() { if(this.getStudentId()==null||this.getTeacherId()==null) return false; diff --git a/src/core/process/C_TeacherSearchStudent.java b/src/core/process/C_TeacherSearchStudent.java index c915c93..5696b8b 100644 --- a/src/core/process/C_TeacherSearchStudent.java +++ b/src/core/process/C_TeacherSearchStudent.java @@ -48,18 +48,11 @@ public class C_TeacherSearchStudent extends TempProcess { limits.put("id",this.getStudentId()); search.addOptions("limits",limits); search.addOptions("start",0); - search.addOptions("end",1); + search.addOptions("end",10); Map options = search.execute(null); List result = (List) options.get("result"); List> studentsInfo = new ArrayList<>(); - for(String[] s:result){ - Map studentInfo = new HashMap<>(); - studentInfo.put("id",s[0]); - studentInfo.put("name",s[2]); - studentInfo.put("e_mail_location",s[3]); - studentInfo.put("phone_number",s[4]); - studentsInfo.add(studentInfo); - } + core.process.Utils.formatResult(result, studentsInfo); return studentsInfo; } protected boolean check() { diff --git a/src/core/process/C_TeacherSelectStudent.java b/src/core/process/C_TeacherSelectStudent.java index 643b493..42624c6 100644 --- a/src/core/process/C_TeacherSelectStudent.java +++ b/src/core/process/C_TeacherSelectStudent.java @@ -1,5 +1,6 @@ package core.process; +import core.operation.Search; import core.operation.Select; import error.GExcptInit; @@ -20,6 +21,24 @@ public class C_TeacherSelectStudent extends TempProcess { select.addOptions("student_id",this.getStudentId()); Map options=select.execute(null); } + public List> search(String studentId) throws Exception{ + Search search = new Search() ; + search.setOptions(new HashMap<>()); + search.addOptions("table","student"); + List fields = new ArrayList<>(); + fields.add("*"); + search.addOptions("field",fields); + Map limits = new HashMap<>(); + limits.put("id",studentId); + search.addOptions("limits",limits); + search.addOptions("start",0); + search.addOptions("end",10); + Map options = search.execute(null); + List result = (List) options.get("result"); + List> studentsInfo = new ArrayList<>(); + core.process.Utils.formatResult(result, studentsInfo); + return studentsInfo; + } protected boolean check() { if(this.getStudentId()==null||this.getTeacherId()==null) return false; diff --git a/src/core/process/Utils.java b/src/core/process/Utils.java new file mode 100644 index 0000000..9c1fc12 --- /dev/null +++ b/src/core/process/Utils.java @@ -0,0 +1,18 @@ +package core.process; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public interface Utils { + static void formatResult(List result, List> studentsInfo) { + for(String[] s:result){ + Map studentInfo = new HashMap<>(); + studentInfo.put("id",s[0]); + studentInfo.put("name",s[2]); + studentInfo.put("e_mail_location",s[3]); + studentInfo.put("phone_number",s[4]); + studentsInfo.add(studentInfo); + } + } +} diff --git a/src/filter/OnlineCheck.java b/src/filter/OnlineCheck.java index e6e1ec4..7ebadb6 100644 --- a/src/filter/OnlineCheck.java +++ b/src/filter/OnlineCheck.java @@ -6,7 +6,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -@WebFilter(filterName = "OnlineCheck",urlPatterns = "/home.jsp") +@WebFilter(filterName = "OnlineCheck",urlPatterns = "/home*") public class OnlineCheck implements Filter { public void destroy() { } diff --git a/src/gdms/Configuration.java b/src/gdms/Configuration.java index 4128db3..3143a95 100644 --- a/src/gdms/Configuration.java +++ b/src/gdms/Configuration.java @@ -2,7 +2,7 @@ package gdms; public interface Configuration { //file - String filePath = "/"; + String filePath = "C:/Users/zhai_/Desktop/"; //database String dbUrl="jdbc:mariadb://localhost:3306/gdms"; String dbUsername="gdms"; diff --git a/src/servlet/S_StudentSelectTeacher.java b/src/servlet/S_StudentSelectTeacher.java index 69b8893..95a8fce 100644 --- a/src/servlet/S_StudentSelectTeacher.java +++ b/src/servlet/S_StudentSelectTeacher.java @@ -26,4 +26,5 @@ public class S_StudentSelectTeacher extends HttpServlet { response.sendRedirect("/op_fail.jsp"); } } + } diff --git a/src/servlet/S_StudentUploadFinishedProduct.java b/src/servlet/S_StudentUploadFinishedProduct.java index b7271e4..393a567 100644 --- a/src/servlet/S_StudentUploadFinishedProduct.java +++ b/src/servlet/S_StudentUploadFinishedProduct.java @@ -8,22 +8,19 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -@WebServlet("/student-upload-finished-product") +@WebServlet("/home/student-upload-finished-product") @MultipartConfig public class S_StudentUploadFinishedProduct extends HttpServlet { static String fileType = "graduation_design_finished_product"; protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - String id = "000"; - //String files = request.getParameter("file"); - System.out.print("123"); - System.out.print( request.getPart("file")); - System.out.print("123"); + String id = request.getParameter("id"); + String fileURL; try { - String fileURL = servlet.Utils.saveFile(request, fileType); + fileURL = servlet.Utils.saveFile(request, fileType); }catch (Exception e) { System.out.print(e); + response.sendRedirect("/op_fail.jsp"); } - System.out.print("222"); } } diff --git a/web/jsFile/upload_action.js b/web/jsFile/upload_action.js index 866ac3a..7f0de15 100644 --- a/web/jsFile/upload_action.js +++ b/web/jsFile/upload_action.js @@ -5,7 +5,7 @@ $(document).ready(function () { }) function sendFile() { var fileData =new FormData(); - var Url4='student-upload-finished-product'; + var Url4='/student-upload-finished-product'; var file=$('#select')[0].files[0]; if($('.true-select').val()=='') {