refactor(service): 修改IEntityService泛型为VO类型并优化缓存策略
重构所有注解@CacheConfig的Service类,将IEntityService泛型从实体类改为VO类 实现实体与VO之间的转换逻辑,使用VO替代实体进行缓存以避免序列化问题 更新相关依赖组件和测试用例,确保功能完整性和系统兼容性 优化Redis缓存配置,清理旧缓存数据并验证新缓存策略有效性
This commit is contained in:
@@ -11,12 +11,14 @@ import java.util.Properties;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.Desktop;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.MyProperties;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@@ -56,11 +58,11 @@ public class OkHttpLoginController implements MessageHolder {
|
||||
@Setter
|
||||
private Stage primaryStage;
|
||||
@Setter
|
||||
private Properties properties;
|
||||
private MyProperties properties;
|
||||
@Setter
|
||||
private OkHttpClient httpClient;
|
||||
private WebSocket webSocket;
|
||||
private String serverUrl;
|
||||
private SimpleStringProperty serverUrl = new SimpleStringProperty();
|
||||
private String webSocketUrl;
|
||||
|
||||
public OkHttpLoginController() {
|
||||
@@ -91,9 +93,9 @@ public class OkHttpLoginController implements MessageHolder {
|
||||
}
|
||||
|
||||
private void initServerUrls() {
|
||||
String host = properties.getProperty("server.host", "localhost");
|
||||
String port = properties.getProperty("server.port", "8080");
|
||||
this.serverUrl = "http://" + host + ":" + port;
|
||||
String host = properties.getServerHost();
|
||||
String port = properties.getServerPort();
|
||||
serverUrl.set("http://" + host + ":" + port);
|
||||
this.webSocketUrl = "ws://" + host + ":" + port + "/ws";
|
||||
}
|
||||
|
||||
@@ -117,11 +119,11 @@ public class OkHttpLoginController implements MessageHolder {
|
||||
}
|
||||
|
||||
private String getUserName() {
|
||||
return properties.getProperty("user.name", "");
|
||||
return properties.getUserName();
|
||||
}
|
||||
|
||||
private String getPassword() {
|
||||
return properties.getProperty("user.password", "");
|
||||
return properties.getPassword();
|
||||
}
|
||||
|
||||
private void showLoginDialog() {
|
||||
@@ -138,6 +140,14 @@ public class OkHttpLoginController implements MessageHolder {
|
||||
grid.setHgap(10);
|
||||
grid.setVgap(15);
|
||||
|
||||
Label hostLabel = new Label("服务器:");
|
||||
TextField hostField = new TextField();
|
||||
{
|
||||
hostField.textProperty().bindBidirectional(serverUrl);
|
||||
grid.add(hostLabel, 0, 0);
|
||||
grid.add(hostField, 1, 0);
|
||||
}
|
||||
|
||||
// 账户输入框
|
||||
Label userLabel = new Label("用户名:");
|
||||
TextField userField = new TextField();
|
||||
@@ -146,8 +156,8 @@ public class OkHttpLoginController implements MessageHolder {
|
||||
if (StringUtils.hasText(username)) {
|
||||
userField.setText(username);
|
||||
}
|
||||
grid.add(userLabel, 0, 0);
|
||||
grid.add(userField, 1, 0);
|
||||
grid.add(userLabel, 0, 1);
|
||||
grid.add(userField, 1, 1);
|
||||
}
|
||||
|
||||
// 密码输入框
|
||||
@@ -158,25 +168,25 @@ public class OkHttpLoginController implements MessageHolder {
|
||||
if (StringUtils.hasText(password)) {
|
||||
passwordField.setText(password);
|
||||
}
|
||||
grid.add(passwordLabel, 0, 1);
|
||||
grid.add(passwordField, 1, 1);
|
||||
grid.add(passwordLabel, 0, 2);
|
||||
grid.add(passwordField, 1, 2);
|
||||
}
|
||||
|
||||
// 记住密码复选框
|
||||
CheckBox rememberCheckBox = new CheckBox("记住密码");
|
||||
{
|
||||
String property = properties.getProperty("remember.password", "false");
|
||||
if (Boolean.parseBoolean(property)) {
|
||||
boolean remember = properties.isRememberPassword();
|
||||
if (remember) {
|
||||
rememberCheckBox.setSelected(true);
|
||||
}
|
||||
}
|
||||
grid.add(rememberCheckBox, 1, 2);
|
||||
grid.add(rememberCheckBox, 1, 3);
|
||||
|
||||
// 错误消息提示
|
||||
Label errorLabel = new Label();
|
||||
errorLabel.setStyle("-fx-text-fill: red;");
|
||||
errorLabel.setVisible(false);
|
||||
grid.add(errorLabel, 0, 3);
|
||||
grid.add(errorLabel, 0, 4);
|
||||
GridPane.setColumnSpan(errorLabel, 2);
|
||||
|
||||
borderPane.setCenter(grid);
|
||||
@@ -204,14 +214,16 @@ public class OkHttpLoginController implements MessageHolder {
|
||||
errorLabel.setVisible(false);
|
||||
|
||||
// 保存配置
|
||||
properties.setProperty("user.name", username);
|
||||
if (remember) {
|
||||
properties.setProperty("user.password", password);
|
||||
properties.setProperty("remember.password", "true");
|
||||
properties.setUserName(username);
|
||||
properties.setPassword(password);
|
||||
properties.setRememberPassword(true);
|
||||
} else {
|
||||
properties.setProperty("user.password", "");
|
||||
properties.setProperty("remember.password", "false");
|
||||
properties.setUserName(username);
|
||||
properties.setPassword("");
|
||||
properties.setRememberPassword(false);
|
||||
}
|
||||
properties.save();
|
||||
|
||||
// 执行登录
|
||||
login(username, password).whenComplete((v, e) -> {
|
||||
@@ -240,8 +252,8 @@ public class OkHttpLoginController implements MessageHolder {
|
||||
|
||||
private CompletableFuture<Void> login(String username, String password) {
|
||||
// 添加详细日志,记录服务器URL和请求准备情况
|
||||
info("正在连接服务器: " + serverUrl);
|
||||
logger.debug("login方法被调用,用户名: " + username);
|
||||
info("正在连接服务器: " + serverUrl.get());
|
||||
logger.debug("用户名: {}", username);
|
||||
CompletableFuture<Void> future = new CompletableFuture<>();
|
||||
|
||||
try {
|
||||
@@ -268,7 +280,7 @@ public class OkHttpLoginController implements MessageHolder {
|
||||
RequestBody body = RequestBody.create(objectNode.toString(), JSON);
|
||||
|
||||
// 构建并记录完整的请求URL
|
||||
String loginUrl = serverUrl + "/api/login";
|
||||
String loginUrl = serverUrl.get() + "/api/login";
|
||||
logger.debug("构建登录请求URL: " + loginUrl);
|
||||
Request request = new Request.Builder()
|
||||
.url(loginUrl)
|
||||
|
||||
Reference in New Issue
Block a user