Merge remote-tracking branch 'remotes/origin/master' into hechu1

zgl
何楚 6 years ago
commit a4f470b828

@ -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

@ -10,6 +10,7 @@ import utils.Utils;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public interface AccountManagement { public interface AccountManagement {
@ -41,15 +42,24 @@ public interface AccountManagement {
try { try {
if(!rs.getString(2).equals(password)) if(!rs.getString(2).equals(password))
throw new GExcptAccount("password wrong"); throw new GExcptAccount("password wrong");
return createUser(userType,rs); List<String> necessaryInfo = new ArrayList<>();
for(int i=0;i<4;i++){
necessaryInfo.add(rs.getString(i));
}
return createUser(userType,necessaryInfo);
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;
} }
static User register(List<String> necessaryInfo, String User){ static User register(String userType, List<String> necessaryInfo) throws GExcptSQL {
//todo String sql = "INSERT INTO "+userType+" VALUES(\'";
return null; 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){ static void logout(User user){
//todo //todo
@ -59,7 +69,7 @@ public interface AccountManagement {
} }
static User getUser(String userType){ static User getUser(String userType){
try { 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) { } catch (InstantiationException e) {
e.printStackTrace(); e.printStackTrace();
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
@ -73,16 +83,12 @@ public interface AccountManagement {
} }
return null; return null;
} }
static User createUser(String userType, ResultSet rs) { static User createUser(String userType, List<String> necessaryInfo) {
User user = getUser(userType); User user = getUser(userType);
try { user.setId(necessaryInfo.get(0));
user.setId(rs.getString("id")); user.setName(necessaryInfo.get(1));
user.setName(rs.getString("name")); user.setE_mail_location(necessaryInfo.get(2));
user.setE_mail_location(rs.getString("e_mail_location")); user.setPhone_number(necessaryInfo.get(3));
user.setPhone_number(rs.getString("phone_number"));
} catch (SQLException e) {
e.printStackTrace();
}
return user; return user;
} }
} }

@ -1,6 +1,8 @@
package init; package init;
import core.user.utils.AccountManagement;
import dao.DBManagement; import dao.DBManagement;
import error.GExcptSQL;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet; import javax.servlet.annotation.WebServlet;
@ -8,6 +10,8 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@WebServlet(name = "Init") @WebServlet(name = "Init")
public class Init extends HttpServlet { public class Init extends HttpServlet {

Loading…
Cancel
Save