mirror of
https://github.com/FatttSnake/ClassroomInteraction.git
synced 2026-04-06 03:51:26 +08:00
TeacherUI:Almost completed and the test of DateBase didn't happen problem.But the test with ggb will not start.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.cfive.classroom.teacher.Attend">
|
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.cfive.classroom.teacher.Attend">
|
||||||
<grid id="27dc6" binding="rootPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
<grid id="27dc6" binding="rootPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
<margin top="0" left="0" bottom="0" right="0"/>
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<xy x="20" y="20" width="500" height="400"/>
|
<xy x="20" y="20" width="500" height="400"/>
|
||||||
@@ -58,6 +58,14 @@
|
|||||||
</scrollpane>
|
</scrollpane>
|
||||||
</children>
|
</children>
|
||||||
</tabbedpane>
|
</tabbedpane>
|
||||||
|
<component id="49582" class="javax.swing.JButton" binding="bt_refresh">
|
||||||
|
<constraints>
|
||||||
|
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="刷新"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</grid>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -6,13 +6,18 @@ import com.cfive.classroom.library.database.bean.Attendance;
|
|||||||
import com.cfive.classroom.library.database.util.DependenciesNotFoundException;
|
import com.cfive.classroom.library.database.util.DependenciesNotFoundException;
|
||||||
import com.cfive.classroom.library.database.util.NoConfigException;
|
import com.cfive.classroom.library.database.util.NoConfigException;
|
||||||
import com.cfive.classroom.library.net.TeacherNet;
|
import com.cfive.classroom.library.net.TeacherNet;
|
||||||
|
import com.cfive.classroom.library.net.util.MessageObject;
|
||||||
|
import com.cfive.classroom.library.net.util.MessageType;
|
||||||
|
import com.cfive.classroom.library.net.util.ReceiveListener;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.event.ListSelectionEvent;
|
import javax.swing.event.TableModelEvent;
|
||||||
import javax.swing.event.ListSelectionListener;
|
import javax.swing.event.TableModelListener;
|
||||||
import javax.swing.table.*;
|
import javax.swing.table.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@@ -20,7 +25,6 @@ import java.time.LocalDateTime;
|
|||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
public class Attend {
|
public class Attend {
|
||||||
private static final Attend attend = new Attend();
|
private static final Attend attend = new Attend();
|
||||||
@@ -31,16 +35,18 @@ public class Attend {
|
|||||||
private final Object[] t2_columnTitle = {"考勤号", "学号", "姓名", "签到状态"};
|
private final Object[] t2_columnTitle = {"考勤号", "学号", "姓名", "签到状态"};
|
||||||
private JTable table_already;
|
private JTable table_already;
|
||||||
private JTable table_undo;
|
private JTable table_undo;
|
||||||
|
private JButton bt_refresh;
|
||||||
private TeacherNet teacherNet;
|
private TeacherNet teacherNet;
|
||||||
private String courseID;
|
private String courseID;
|
||||||
private final List<Attendance> attendancesList = new ArrayList<>();
|
private final List<Attendance> attendancesList = new ArrayList<>();
|
||||||
private final List<Attendance> alreadyList = new ArrayList<>();
|
private final List<Attendance> alreadyList = new ArrayList<>();
|
||||||
private final List<Attendance> undoList = new ArrayList<>();
|
private final List<Attendance> undoList = new ArrayList<>();
|
||||||
|
private DefaultTableModel undoTableModel,alreadyTableModel;
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
|
||||||
public Attend() {
|
public Attend() {
|
||||||
//学生签到信息监听
|
//学生签到信息监听
|
||||||
/*
|
if(teacherNet!=null){
|
||||||
teacherNet.setOnReceiveListener(new ReceiveListener() {
|
teacherNet.setOnReceiveListener(new ReceiveListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(MessageObject messageObject) {
|
public void onReceive(MessageObject messageObject) {
|
||||||
@@ -48,7 +54,7 @@ public class Attend {
|
|||||||
if (messageObject.getMessageType() == MessageType.CheckIn && messageObject.getAttStatus() == AttStatus.signed) {
|
if (messageObject.getMessageType() == MessageType.CheckIn && messageObject.getAttStatus() == AttStatus.signed) {
|
||||||
try {
|
try {
|
||||||
//将学生签到状态修改进数据表中
|
//将学生签到状态修改进数据表中
|
||||||
DatabaseHelper.updateAttendance(messageObject.getStuNo(), messageObject.getAttStatus());
|
DatabaseHelper.updateAttendance(messageObject.getStuNo(), messageObject.getAttStatus(),messageObject.getLocalDateTime());
|
||||||
} catch (NoConfigException e) {
|
} catch (NoConfigException e) {
|
||||||
JOptionPane.showMessageDialog(null, "没有数据库配置文件", "警告", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null, "没有数据库配置文件", "警告", JOptionPane.ERROR_MESSAGE);
|
||||||
LOGGER.error("No configuration", e);
|
LOGGER.error("No configuration", e);
|
||||||
@@ -61,7 +67,7 @@ public class Attend {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
*/
|
}
|
||||||
|
|
||||||
//未签表格的鼠标点击事件
|
//未签表格的鼠标点击事件
|
||||||
table_undo.addMouseListener(new MouseAdapter() {
|
table_undo.addMouseListener(new MouseAdapter() {
|
||||||
@@ -75,13 +81,9 @@ public class Attend {
|
|||||||
Object[] options = {AttStatus.absence, AttStatus.signed, AttStatus.leave_early, AttStatus.late, AttStatus.personal_leave, AttStatus.public_holiday, AttStatus.sick_leave, AttStatus.not_signed};
|
Object[] options = {AttStatus.absence, AttStatus.signed, AttStatus.leave_early, AttStatus.late, AttStatus.personal_leave, AttStatus.public_holiday, AttStatus.sick_leave, AttStatus.not_signed};
|
||||||
AttStatus attStatus = (AttStatus) JOptionPane.showInputDialog(null, "选择您所要修改的签到状态", "提示",
|
AttStatus attStatus = (AttStatus) JOptionPane.showInputDialog(null, "选择您所要修改的签到状态", "提示",
|
||||||
JOptionPane.PLAIN_MESSAGE, null, options, options[0]);
|
JOptionPane.PLAIN_MESSAGE, null, options, options[0]);
|
||||||
LOGGER.debug("attStatus: " + attStatus);
|
|
||||||
if (attStatus == null) {
|
if (attStatus != null) {
|
||||||
LOGGER.debug("test: " + table_undo.getModel().getValueAt(row, col));
|
|
||||||
table_undo.getModel().setValueAt(AttStatus.not_signed, row, col);
|
|
||||||
}
|
|
||||||
String modifyStat = String.valueOf(attStatus);
|
String modifyStat = String.valueOf(attStatus);
|
||||||
if (modifyStat != null) {
|
|
||||||
//将修改后的状态显示出来
|
//将修改后的状态显示出来
|
||||||
table_undo.getModel().setValueAt(modifyStat, row, col);
|
table_undo.getModel().setValueAt(modifyStat, row, col);
|
||||||
//将修改在数据库中更改
|
//将修改在数据库中更改
|
||||||
@@ -98,13 +100,82 @@ public class Attend {
|
|||||||
JOptionPane.showMessageDialog(null, "未查询到该数据", "错误", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null, "未查询到该数据", "错误", JOptionPane.ERROR_MESSAGE);
|
||||||
LOGGER.error("DependenciesNotFoundException", e);
|
LOGGER.error("DependenciesNotFoundException", e);
|
||||||
}
|
}
|
||||||
} else {
|
bt_refresh.doClick();
|
||||||
JOptionPane.showMessageDialog(null, "您未进行选择", "提示", JOptionPane.INFORMATION_MESSAGE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
//刷新按钮的监听
|
||||||
|
bt_refresh.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
//清空列表
|
||||||
|
((DefaultTableModel)table_already.getModel()).setRowCount(0);
|
||||||
|
((DefaultTableModel)table_undo.getModel()).setRowCount(0);
|
||||||
|
attendancesList.clear();
|
||||||
|
alreadyList.clear();
|
||||||
|
undoList.clear();
|
||||||
|
//重新加载
|
||||||
|
try {
|
||||||
|
attendancesList.addAll(DatabaseHelper.selectAttendanceByCourse(Long.parseLong(courseID))); //导入该课程考勤名单
|
||||||
|
for (Attendance attendance : attendancesList) {
|
||||||
|
if (attendance.getAttStatus() == AttStatus.signed) { //筛选出已签到的考勤列表
|
||||||
|
alreadyList.add(attendance);
|
||||||
|
} else {
|
||||||
|
undoList.add(attendance);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} catch (DependenciesNotFoundException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
} catch (NoConfigException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
//已签考勤表格
|
||||||
|
alreadyTableModel = new DefaultTableModel(t1_columnTitle, 0) {
|
||||||
|
@Override
|
||||||
|
public boolean isCellEditable(int row, int column) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (alreadyList != null) {
|
||||||
|
for (Attendance attendance : alreadyList) {
|
||||||
|
String stuID = String.valueOf(attendance.getStudent().getStuID());
|
||||||
|
String stuName = String.valueOf(attendance.getStudent().getStuName());
|
||||||
|
LocalDateTime attTime = attendance.getAttTime();
|
||||||
|
String attTime1 = attTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||||
|
Object row[] = {stuID, stuName, attTime1};
|
||||||
|
alreadyTableModel.addRow(row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
attend.table_already.setModel(alreadyTableModel);
|
||||||
|
|
||||||
|
//未签考勤表格
|
||||||
|
undoTableModel = new DefaultTableModel(t2_columnTitle, 0);
|
||||||
|
for (Attendance attendance : undoList) {
|
||||||
|
String attID = attendance.getAttID();
|
||||||
|
String stuID = String.valueOf(attendance.getStudent().getStuID());
|
||||||
|
String stuName = String.valueOf(attendance.getStudent().getStuName());
|
||||||
|
AttStatus attStatus = attendance.getAttStatus();
|
||||||
|
Object row[] = {attID, stuID, stuName, String.valueOf(attStatus)};
|
||||||
|
undoTableModel.addRow(row);
|
||||||
|
}
|
||||||
|
attend.table_undo.setModel(undoTableModel);
|
||||||
|
//设置第一列隐藏
|
||||||
|
TableColumn tableColumn = attend.table_undo.getColumnModel().getColumn(0);
|
||||||
|
tableColumn.setWidth(0);
|
||||||
|
tableColumn.setMinWidth(0);
|
||||||
|
tableColumn.setPreferredWidth(0);
|
||||||
|
tableColumn.setMaxWidth(0);
|
||||||
|
attend.table_undo.getTableHeader().getColumnModel().getColumn(0).setMaxWidth(0);
|
||||||
|
attend.table_undo.getTableHeader().getColumnModel().getColumn(0).setMinWidth(0);
|
||||||
|
attend.table_undo.setCellSelectionEnabled(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
frame.setContentPane(attend.rootPanel);
|
frame.setContentPane(attend.rootPanel);
|
||||||
@@ -143,7 +214,7 @@ public class Attend {
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
//已签考勤表格
|
//已签考勤表格
|
||||||
DefaultTableModel alreadyTableModel = new DefaultTableModel(t1_columnTitle, 0) {
|
alreadyTableModel = new DefaultTableModel(t1_columnTitle, 0) {
|
||||||
@Override
|
@Override
|
||||||
public boolean isCellEditable(int row, int column) {
|
public boolean isCellEditable(int row, int column) {
|
||||||
return false;
|
return false;
|
||||||
@@ -162,9 +233,13 @@ public class Attend {
|
|||||||
attend.table_already.setModel(alreadyTableModel);
|
attend.table_already.setModel(alreadyTableModel);
|
||||||
|
|
||||||
//未签考勤表格
|
//未签考勤表格
|
||||||
DefaultTableModel undoTableModel = new DefaultTableModel(t2_columnTitle, 0);
|
undoTableModel = new DefaultTableModel(t2_columnTitle, 0){
|
||||||
|
@Override
|
||||||
|
public boolean isCellEditable(int row, int column) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
for (Attendance attendance : undoList) {
|
for (Attendance attendance : undoList) {
|
||||||
LOGGER.debug(attendance.getAttID());
|
|
||||||
String attID = attendance.getAttID();
|
String attID = attendance.getAttID();
|
||||||
String stuID = String.valueOf(attendance.getStudent().getStuID());
|
String stuID = String.valueOf(attendance.getStudent().getStuID());
|
||||||
String stuName = String.valueOf(attendance.getStudent().getStuName());
|
String stuName = String.valueOf(attendance.getStudent().getStuName());
|
||||||
@@ -181,10 +256,8 @@ public class Attend {
|
|||||||
tableColumn.setMaxWidth(0);
|
tableColumn.setMaxWidth(0);
|
||||||
attend.table_undo.getTableHeader().getColumnModel().getColumn(0).setMaxWidth(0);
|
attend.table_undo.getTableHeader().getColumnModel().getColumn(0).setMaxWidth(0);
|
||||||
attend.table_undo.getTableHeader().getColumnModel().getColumn(0).setMinWidth(0);
|
attend.table_undo.getTableHeader().getColumnModel().getColumn(0).setMinWidth(0);
|
||||||
|
|
||||||
LOGGER.debug(table_undo.getColumnModel().getColumnCount());
|
|
||||||
LOGGER.debug(undoTableModel.getColumnCount());
|
|
||||||
attend.table_undo.setCellSelectionEnabled(true);
|
attend.table_undo.setCellSelectionEnabled(true);
|
||||||
|
|
||||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public class CheckIn {
|
|||||||
number = n1 + n2 + n3 + n4;
|
number = n1 + n2 + n3 + n4;
|
||||||
if (number != null) {
|
if (number != null) {
|
||||||
LOGGER.info(number);
|
LOGGER.info(number);
|
||||||
teacherNet.sendAllMessage(new MessageObject(null, null, number, null, null, null, MessageType.CheckIn));
|
teacherNet.sendAllMessage(new MessageObject(null, null, number, null, null, null,null,MessageType.CheckIn));
|
||||||
JOptionPane.showMessageDialog(null, "签到码发布成功", "消息", JOptionPane.INFORMATION_MESSAGE);
|
JOptionPane.showMessageDialog(null, "签到码发布成功", "消息", JOptionPane.INFORMATION_MESSAGE);
|
||||||
frame.dispose();
|
frame.dispose();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ public class Main {
|
|||||||
}
|
}
|
||||||
JOptionPane.showMessageDialog(null, "恭喜以下同学被选中:\n\t\n" + count);
|
JOptionPane.showMessageDialog(null, "恭喜以下同学被选中:\n\t\n" + count);
|
||||||
//将选人结果群发出去
|
//将选人结果群发出去
|
||||||
teacherNet.sendAllMessage(new MessageObject(null, null, null, null, count, null, MessageType.Select));
|
teacherNet.sendAllMessage(new MessageObject(null, null, null, null, count, null, null,MessageType.Select));
|
||||||
} else {
|
} else {
|
||||||
JOptionPane.showMessageDialog(null, "学生名单未导入", "错误", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null, "学生名单未导入", "错误", JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
@@ -152,6 +152,7 @@ public class Main {
|
|||||||
});
|
});
|
||||||
|
|
||||||
//主界面线程监听
|
//主界面线程监听
|
||||||
|
if(teacherNet!=null){
|
||||||
teacherNet.setOnReceiveListener(new ReceiveListener() {
|
teacherNet.setOnReceiveListener(new ReceiveListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(MessageObject messageObject) {
|
public void onReceive(MessageObject messageObject) {
|
||||||
@@ -167,6 +168,8 @@ public class Main {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
frame.setContentPane(main.rootPanel);
|
frame.setContentPane(main.rootPanel);
|
||||||
frame.pack();
|
frame.pack();
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import java.time.format.DateTimeFormatter;
|
|||||||
public class SendMessage {
|
public class SendMessage {
|
||||||
private static final SendMessage sendMessage=new SendMessage();
|
private static final SendMessage sendMessage=new SendMessage();
|
||||||
|
|
||||||
private static JFrame frame = new JFrame("SendMessage");
|
private static JFrame frame = new JFrame("发送消息");
|
||||||
private JPanel rootPanel;
|
private JPanel rootPanel;
|
||||||
private JTextArea messageInput;
|
private JTextArea messageInput;
|
||||||
private JButton bt_sendMessage;
|
private JButton bt_sendMessage;
|
||||||
@@ -48,7 +48,7 @@ public class SendMessage {
|
|||||||
if(messageToAll!=null){
|
if(messageToAll!=null){
|
||||||
LocalDateTime sendTime = LocalDateTime.now();
|
LocalDateTime sendTime = LocalDateTime.now();
|
||||||
messageShow.append("@所有人: "+sendTime.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH时mm分ss秒"))+'\n'+messageToAll+'\n');
|
messageShow.append("@所有人: "+sendTime.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH时mm分ss秒"))+'\n'+messageToAll+'\n');
|
||||||
MessageObject messageObject = new MessageObject(null,null,null,"@所有人:"+messageToAll,null,null,MessageType.ChatToAll);
|
MessageObject messageObject = new MessageObject(null,null,null,"@所有人:"+messageToAll,null,null,null,MessageType.ChatToAll);
|
||||||
teacherNet.sendAllMessage(messageObject);
|
teacherNet.sendAllMessage(messageObject);
|
||||||
messageInput.setText("");
|
messageInput.setText("");
|
||||||
}else {
|
}else {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.net.NoRouteToHostException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.spec.InvalidKeySpecException;
|
import java.security.spec.InvalidKeySpecException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@@ -25,6 +26,7 @@ public class SignIn {
|
|||||||
private JPasswordField password_input;
|
private JPasswordField password_input;
|
||||||
private String workerNo,password;
|
private String workerNo,password;
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
private static boolean isConnectedToDatabase = false;
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
FlatLightLaf.setup();
|
FlatLightLaf.setup();
|
||||||
|
|
||||||
@@ -49,6 +51,7 @@ public class SignIn {
|
|||||||
} else {
|
} else {
|
||||||
JOptionPane.showMessageDialog(null, "密码错误,请重新输入", "错误!!", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null, "密码错误,请重新输入", "错误!!", JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
|
isConnectedToDatabase = true;
|
||||||
} catch (NoConfigException ex) {
|
} catch (NoConfigException ex) {
|
||||||
JOptionPane.showMessageDialog(null, "没有数据库配置文件", "警告", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null, "没有数据库配置文件", "警告", JOptionPane.ERROR_MESSAGE);
|
||||||
LOGGER.error("No configuration", e);
|
LOGGER.error("No configuration", e);
|
||||||
@@ -62,6 +65,11 @@ public class SignIn {
|
|||||||
LOGGER.error("NoSuchAlgorithmException", e);
|
LOGGER.error("NoSuchAlgorithmException", e);
|
||||||
} catch (InvalidKeySpecException ex) {
|
} catch (InvalidKeySpecException ex) {
|
||||||
LOGGER.error("InvalidKeySpecException", e);
|
LOGGER.error("InvalidKeySpecException", e);
|
||||||
|
} finally {
|
||||||
|
if (!isConnectedToDatabase) {
|
||||||
|
JOptionPane.showMessageDialog(null, "无法连接到数据库", "错误", JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
isConnectedToDatabase = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.cfive.classroom.teacher;
|
||||||
|
|
||||||
|
import com.cfive.classroom.library.database.DatabaseHelper;
|
||||||
|
import com.cfive.classroom.library.database.util.DependenciesNotFoundException;
|
||||||
|
import com.cfive.classroom.library.database.util.NoConfigException;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.spec.InvalidKeySpecException;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class TeacherTest {
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
@Test
|
||||||
|
void modifyPw(){
|
||||||
|
try {
|
||||||
|
DatabaseHelper.changePasswdInTeacher(Long.valueOf("1002"),"10021002");
|
||||||
|
} catch (NoConfigException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (DependenciesNotFoundException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (InvalidKeySpecException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user