|
@@ -15,11 +15,12 @@ public class UserRegister {
|
|
private String user_password;
|
|
private String user_password;
|
|
private String uuid;
|
|
private String uuid;
|
|
private String user_register_time;
|
|
private String user_register_time;
|
|
|
|
+ private String user_last_login_time;
|
|
private int user_permission_level;
|
|
private int user_permission_level;
|
|
private String[] UserData; // 将UserData数组定义为私有
|
|
private String[] UserData; // 将UserData数组定义为私有
|
|
|
|
|
|
public UserRegister() {
|
|
public UserRegister() {
|
|
- UserData = new String[5];
|
|
|
|
|
|
+ UserData = new String[6];
|
|
// 用户信息初始化
|
|
// 用户信息初始化
|
|
System.out.println("请输入用户名:");
|
|
System.out.println("请输入用户名:");
|
|
this.user_name = scan.nextLine();
|
|
this.user_name = scan.nextLine();
|
|
@@ -52,10 +53,12 @@ public class UserRegister {
|
|
// 获取年月日时分秒的时间戳
|
|
// 获取年月日时分秒的时间戳
|
|
this.user_register_time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
this.user_register_time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
UserData[4] = this.user_register_time;
|
|
UserData[4] = this.user_register_time;
|
|
|
|
+ this.user_last_login_time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
+ UserData[5] = this.user_last_login_time;
|
|
System.out.println("用户名:" + this.user_name + "\n密码:" + this.user_password + "\nuuid:" + this.uuid + "\n注册时间:" + this.user_register_time);
|
|
System.out.println("用户名:" + this.user_name + "\n密码:" + this.user_password + "\nuuid:" + this.uuid + "\n注册时间:" + this.user_register_time);
|
|
insertUserData(UserData);
|
|
insertUserData(UserData);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// 提供一个公共方法来获取UserData数组
|
|
// 提供一个公共方法来获取UserData数组
|
|
public String[] getUserData() {
|
|
public String[] getUserData() {
|
|
return UserData;
|
|
return UserData;
|
|
@@ -63,7 +66,7 @@ public class UserRegister {
|
|
|
|
|
|
public void insertUserData(String[] UserData) {
|
|
public void insertUserData(String[] UserData) {
|
|
String url = "jdbc:sqlite:identifier.sqlite"; // SQLite数据库URL
|
|
String url = "jdbc:sqlite:identifier.sqlite"; // SQLite数据库URL
|
|
- String sql = "INSERT INTO user_data (user_name, user_password, user_uuid, user_permission_level, user_register_time) VALUES (?, ?, ?, ?, ?)";
|
|
|
|
|
|
+ String sql = "INSERT INTO user_data (user_name, user_password, user_uuid, user_permission_level, user_register_time, user_last_login_time) VALUES (?, ?, ?, ?, ?,?)";
|
|
|
|
|
|
try (Connection conn = DriverManager.getConnection(url);
|
|
try (Connection conn = DriverManager.getConnection(url);
|
|
PreparedStatement pstmt = conn.prepareStatement(sql)) {
|
|
PreparedStatement pstmt = conn.prepareStatement(sql)) {
|
|
@@ -73,6 +76,7 @@ public class UserRegister {
|
|
pstmt.setString(3, UserData[2]);
|
|
pstmt.setString(3, UserData[2]);
|
|
pstmt.setInt(4, Integer.parseInt(UserData[3])); // 假设user_permission_level是整数
|
|
pstmt.setInt(4, Integer.parseInt(UserData[3])); // 假设user_permission_level是整数
|
|
pstmt.setString(5, UserData[4]); // 假设user_register_time是字符串形式的年月日时分秒时间戳
|
|
pstmt.setString(5, UserData[4]); // 假设user_register_time是字符串形式的年月日时分秒时间戳
|
|
|
|
+ pstmt.setString(6, UserData[5]);
|
|
|
|
|
|
int affectedRows = pstmt.executeUpdate();
|
|
int affectedRows = pstmt.executeUpdate();
|
|
if (affectedRows > 0) {
|
|
if (affectedRows > 0) {
|