refactor: 移除Hibernate依赖并重构代理对象初始化检查逻辑
feat(controller): 新增多个任务类用于合同和客户相关操作 feat(service): 新增ProxyUtils工具类替代Hibernate.isInitialized检查 refactor(controller): 重构多个控制器和皮肤类,使用ProxyUtils替代Hibernate refactor(service): 重构服务类,移除Hibernate依赖并优化方法实现 fix(controller): 修复表格单元格初始化逻辑,确保代理对象正确加载 chore: 更新项目版本号至0.0.58-SNAPSHOT docs: 添加MyProperties类用于管理下载路径配置
This commit is contained in:
@@ -19,18 +19,15 @@ import java.util.NoSuchElementException;
|
||||
import java.util.Objects;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.jdbc.DataSourceBuilder;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.Desktop;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
@@ -78,9 +75,8 @@ public class LoginWidowController implements MessageHolder {
|
||||
return properties.getProperty("server.host");
|
||||
}
|
||||
|
||||
|
||||
public void tryLogin() {
|
||||
// CompletableFuture<ButtonType> future = new CompletableFuture<>();
|
||||
// CompletableFuture<ButtonType> future = new CompletableFuture<>();
|
||||
// 检查配置文件中是否保存用户名和密码
|
||||
String userName = getUserName();
|
||||
if (StringUtils.hasText(userName)) {
|
||||
@@ -99,7 +95,6 @@ public class LoginWidowController implements MessageHolder {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String getPassword() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getPassword'");
|
||||
@@ -133,7 +128,8 @@ public class LoginWidowController implements MessageHolder {
|
||||
// -分割16进制表示法
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < hardwareAddress.length; i++) {
|
||||
sb.append(String.format("%02X%s", hardwareAddress[i], i < hardwareAddress.length - 1 ? "-" : ""));
|
||||
sb.append(
|
||||
String.format("%02X%s", hardwareAddress[i], i < hardwareAddress.length - 1 ? "-" : ""));
|
||||
}
|
||||
|
||||
while (inetAddresses.hasMoreElements()) {
|
||||
@@ -156,40 +152,10 @@ public class LoginWidowController implements MessageHolder {
|
||||
String database = getDatabase();
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("try to connect db server host:{},port:{},database:{},user:{},pwd:{}", host, port, database, userName, "*");
|
||||
logger.debug("try to connect db server host:{},port:{},database:{},user:{},pwd:{}", host, port, database,
|
||||
userName, "*");
|
||||
}
|
||||
|
||||
try (HikariDataSource source = DataSourceBuilder.create()
|
||||
.type(HikariDataSource.class)
|
||||
.url("jdbc:mysql://" + host + ":" + port + "/" + database)
|
||||
.username(userName)
|
||||
.password(password)
|
||||
.driverClassName("com.mysql.cj.jdbc.Driver")
|
||||
.build()) {
|
||||
|
||||
CompletableFuture<List<MacIP>> macAndIP = getMacAndIP();
|
||||
macAndIP.thenAccept(map -> {
|
||||
if (map.isEmpty()) {
|
||||
error("查询本地地址信息失败,请联系管理员或重启应用!");
|
||||
logger.error("查询本地地址信息失败");
|
||||
}
|
||||
});
|
||||
|
||||
try (Connection connection = source.getConnection()) {
|
||||
info("连接到数据库 " + host + ", 请稍后,正在查询账户与本绑定的登录信息...");
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("connection.getClientInfo() = {}", connection.getClientInfo());
|
||||
}
|
||||
|
||||
// 必须要阻塞,否则 connection 会断开
|
||||
EmployeeInfo employeeInfo = tryLoginWithEmployeeBind(connection, macAndIP).get();
|
||||
createSession(connection, employeeInfo);
|
||||
return employeeInfo;
|
||||
} catch (ExecutionException | InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getDatabase() {
|
||||
@@ -262,7 +228,8 @@ public class LoginWidowController implements MessageHolder {
|
||||
}
|
||||
}
|
||||
|
||||
private CompletableFuture<EmployeeInfo> tryLoginWithEmployeeBind(Connection connection, CompletableFuture<List<MacIP>> macAndIP) {
|
||||
private CompletableFuture<EmployeeInfo> tryLoginWithEmployeeBind(Connection connection,
|
||||
CompletableFuture<List<MacIP>> macAndIP) {
|
||||
CompletableFuture<EmployeeInfo> future = new CompletableFuture<>();
|
||||
macAndIP.thenAccept(macIPS -> {
|
||||
if (macIPS.isEmpty()) {
|
||||
@@ -429,8 +396,7 @@ public class LoginWidowController implements MessageHolder {
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(
|
||||
String.format("查询本机绑定信息异常,请联系管理员或重启应用!MAC: %s, IP: %s", macIP.mac, macIP.ip),
|
||||
e
|
||||
);
|
||||
e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@@ -449,7 +415,7 @@ public class LoginWidowController implements MessageHolder {
|
||||
grid.setHgap(10);
|
||||
grid.setVgap(10);
|
||||
// 为整个 GridPane 设置外边距
|
||||
//GridPane.setMargin(grid, new Insets(10));
|
||||
// GridPane.setMargin(grid, new Insets(10));
|
||||
|
||||
// 账户输入框
|
||||
Label userLabel = new Label("账户:");
|
||||
@@ -499,14 +465,12 @@ public class LoginWidowController implements MessageHolder {
|
||||
|
||||
borderPane.setCenter(grid);
|
||||
|
||||
|
||||
// 登录按钮
|
||||
Button loginButton = new Button("登录");
|
||||
loginButton.setDefaultButton(true);
|
||||
borderPane.setBottom(loginButton);
|
||||
BorderPane.setAlignment(loginButton, javafx.geometry.Pos.CENTER);
|
||||
|
||||
|
||||
// 登录按钮点击事件
|
||||
loginButton.setOnAction(event -> {
|
||||
String username = userField.getText();
|
||||
@@ -546,16 +510,14 @@ public class LoginWidowController implements MessageHolder {
|
||||
stage.close();
|
||||
});
|
||||
|
||||
|
||||
// 创建场景并设置到窗口
|
||||
Scene scene = new Scene(borderPane, 400, 260);
|
||||
stage.setScene(scene);
|
||||
// stage.setAlwaysOnTop(true);
|
||||
// stage.setAlwaysOnTop(true);
|
||||
stage.setResizable(false);
|
||||
stage.showAndWait();
|
||||
}
|
||||
|
||||
|
||||
private void logined(EmployeeInfo employeeInfo) {
|
||||
info("欢迎 " + employeeInfo.name.get());
|
||||
if (!SpringApp.isRunning()) {
|
||||
|
||||
Reference in New Issue
Block a user