From e9b258bd4979fb89a2226615c675447a17868cdc Mon Sep 17 00:00:00 2001 From: wan <2499498893@qq.com> Date: Wed, 9 Jan 2019 19:32:45 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- documents/GDMS_DB_Design .txt | 135 ++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 documents/GDMS_DB_Design .txt diff --git a/documents/GDMS_DB_Design .txt b/documents/GDMS_DB_Design .txt new file mode 100644 index 0000000..5cc8f24 --- /dev/null +++ b/documents/GDMS_DB_Design .txt @@ -0,0 +1,135 @@ +id char 20 +password char 256 +name varchar 50 +e_mail_location varchar 50 +phonenumber varchar 30 +url varchar 256 + +administrator + id + password + name + e_mail_location + phonenumber + + +profession_info + profession_code char 8 + college varchar 256 + department varchar 256 + profession varchar 256 + +student + id + password + name + e_mail_location + phonenumber + profession_code char 8 + grade char 4 + +teacher + id + password + name + e_mail_location + phonenumber + profession_code char 8 + job_title varchar 256 + education varchar 256 + + +graduation_design + id + student_id + teacher_id + chinese_name varchar 256 + english_name varchar 256 + type_of_topic char 3 + source_of_design char 1 + nature_of_design char 1 + description_of_topic text + + +graduation_design_opening_report + id + opening_report_date date + opening_report_location varchar 256 + opening_report_url + opening_report_teacher_leader_team_id + opening_report_secretary_leader_team_id + estimated_word_count int + +graduation_design_opening_report_opinion_record + id + mentor_opinion text + mentor_opinion_date date + secretary_record text + secretary_record_date date + report_teacher_team_opinion text + report_teacher_team_opinion_date date + college_opinion text + college_opinion_date date + +opening_report_teacher_team + leader_teacher_id + teacher1_id + teacher2_id + +opening_report_secretary_team + leader_student_id + student1_id + student2_id + +graduation_design_finished_product + id + word_count int + final_date date + graduation_design_url + chinese_abstract text + chinese_key_words text + english_abstract text + english_key_words text + + +graduation_design_finished_product_mentor_score + id + +graduation_design_finished_product_reviewer_score + id + score int + opinion text + reviewer_score_date date + +graduation_design_reply + id + reply_date date + reply_location varchar 256 + reply_teacher_team_leader_id + reply_secretary_team_leader_id + +graduation_design_reply_opinion_record_score + id + mentor_opinion text + mentor_opinion_date date + secretary_record text + secretary_record_date date + reply_teacher_team_opinion text + reply_teacher_team_score int + reply_teacher_team_opinion_date date + college_opinion text + college_score int + college_opinion_date date + school_opinion text + school_score int + school_opinion_date date + +reply_teacher_team + leader_teacher_id + teacher1_id + teacher2_id + +reply_secretary_team + leader_student_id + student1_id + student2_id From c8746f9e729bb92cf7de4fe03646c3799a8291e2 Mon Sep 17 00:00:00 2001 From: zhai_lw Date: Thu, 10 Jan 2019 21:16:34 +0800 Subject: [PATCH 2/2] =?UTF-8?q?1,=E5=90=8E=E7=AB=AF=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/user/utils/AccountManagement.java | 34 +++++++++++++--------- src/init/Init.java | 4 +++ 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/core/user/utils/AccountManagement.java b/src/core/user/utils/AccountManagement.java index e9f934c..23b738d 100644 --- a/src/core/user/utils/AccountManagement.java +++ b/src/core/user/utils/AccountManagement.java @@ -10,6 +10,7 @@ import utils.Utils; import java.lang.reflect.InvocationTargetException; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; import java.util.List; public interface AccountManagement { @@ -41,15 +42,24 @@ public interface AccountManagement { try { if(!rs.getString(2).equals(password)) throw new GExcptAccount("password wrong"); - return createUser(userType,rs); + List necessaryInfo = new ArrayList<>(); + for(int i=0;i<4;i++){ + necessaryInfo.add(rs.getString(i)); + } + return createUser(userType,necessaryInfo); } catch (SQLException e) { e.printStackTrace(); } return null; } - static User register(List necessaryInfo, String User){ - //todo - return null; + static User register(String userType, List necessaryInfo) throws GExcptSQL { + String sql = "INSERT INTO "+userType+" VALUES(\'"; + for(String info:necessaryInfo){ + sql+=info+"\', \'"; + } + sql =sql.substring(0,sql.length()-3)+")"; + DBManagement.update(sql); + return createUser(userType, necessaryInfo); } static void logout(User user){ //todo @@ -59,7 +69,7 @@ public interface AccountManagement { } static User getUser(String userType){ try { - return (Administrator)Class.forName("core.user."+ Utils.toUpperFristChar(userType)).getDeclaredConstructor().newInstance(); + return (User) Class.forName("core.user."+ Utils.toUpperFristChar(userType)).getDeclaredConstructor().newInstance(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { @@ -73,16 +83,12 @@ public interface AccountManagement { } return null; } - static User createUser(String userType, ResultSet rs) { + static User createUser(String userType, List necessaryInfo) { User user = getUser(userType); - try { - user.setId(rs.getString("id")); - user.setName(rs.getString("name")); - user.setE_mail_location(rs.getString("e_mail_location")); - user.setPhone_number(rs.getString("phone_number")); - } catch (SQLException e) { - e.printStackTrace(); - } + user.setId(necessaryInfo.get(0)); + user.setName(necessaryInfo.get(1)); + user.setE_mail_location(necessaryInfo.get(2)); + user.setPhone_number(necessaryInfo.get(3)); return user; } } diff --git a/src/init/Init.java b/src/init/Init.java index 0e284b7..8654112 100644 --- a/src/init/Init.java +++ b/src/init/Init.java @@ -1,6 +1,8 @@ package init; +import core.user.utils.AccountManagement; import dao.DBManagement; +import error.GExcptSQL; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; @@ -8,6 +10,8 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; @WebServlet(name = "Init") public class Init extends HttpServlet {