feat(auth): 实现登录接口调用与结果处理
新增 LoginUserVO 类用于接收登录成功后的用户信息,包括租户 ID 和各平台评价接口地址。 修改 LoginView 页面逻辑,调用登录接口并解析返回结果,失败时弹窗提示错误信息。登录成功后将返回的租户 ID 及平台接口地址存储至全局配置中,供后续使用。新增 UpdateUserCookieDTO 类用于更新用户 Cookie 信息,支持多平台标识。调整 application.yml 中服务端口从8080 修改为8000。 ```
This commit is contained in:
28
src/main/java/com/fantaibao/model/LoginUserVO.java
Normal file
28
src/main/java/com/fantaibao/model/LoginUserVO.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.fantaibao.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class LoginUserVO {
|
||||
|
||||
/**
|
||||
* 租户Id
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 美团点评评价接口地址
|
||||
*/
|
||||
private String mtDianPingInterfaceAddress;
|
||||
|
||||
/**
|
||||
* 美团大众点评评价接口地址
|
||||
*/
|
||||
private String mtDaZhInterfaceAddress;
|
||||
|
||||
/**
|
||||
* 抖音评价接口地址
|
||||
*/
|
||||
private String dyPingJiaInterfaceAddress;
|
||||
|
||||
}
|
||||
18
src/main/java/com/fantaibao/model/UpdateUserCookieDTO.java
Normal file
18
src/main/java/com/fantaibao/model/UpdateUserCookieDTO.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.fantaibao.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: peng.hao
|
||||
* @create: 2025/7/30
|
||||
*/
|
||||
@Data
|
||||
public class UpdateUserCookieDTO {
|
||||
private String tenantId;
|
||||
/**
|
||||
* 平台0美团,1抖音,2饿了么商家端3美团外卖商家版4京东5大众点评
|
||||
*/
|
||||
private Integer platform;
|
||||
|
||||
private String cookie;
|
||||
}
|
||||
@@ -2,11 +2,14 @@ package com.fantaibao.page;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fantaibao.config.GlobalConfig;
|
||||
import com.fantaibao.model.LoginUserDTO;
|
||||
import com.fantaibao.model.LoginUserVO;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.PasswordField;
|
||||
@@ -60,17 +63,28 @@ public class LoginView {
|
||||
loginUserDTO.setAccount(account);
|
||||
loginUserDTO.setPassword(password);
|
||||
String result = HttpUtil.post(GlobalConfig.loginInterfaceAddress, JSON.toJSONString(loginUserDTO));
|
||||
System.out.println(result);
|
||||
|
||||
// 这里可以添加实际的登录验证逻辑
|
||||
// 当前简化处理,直接跳转到平台选择页面
|
||||
// 解析返回结果
|
||||
JSONObject jsonResultObject = JSON.parseObject(result);
|
||||
if (jsonResultObject.getInteger("code") != 200) {
|
||||
// 显示错误提示弹窗
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||
alert.setTitle("登录失败");
|
||||
alert.setHeaderText(null);
|
||||
alert.setContentText(jsonResultObject.getString("msg"));
|
||||
alert.showAndWait();
|
||||
return;
|
||||
}
|
||||
LoginUserVO loginUserVO = jsonResultObject.getObject("data", LoginUserVO.class);
|
||||
// 网络地址
|
||||
GlobalConfig.tenantId = loginUserVO.getTenantId();
|
||||
GlobalConfig.mtDianPingInterfaceAddress = loginUserVO.getMtDianPingInterfaceAddress();
|
||||
GlobalConfig.mtDaZhInterfaceAddress = loginUserVO.getMtDaZhInterfaceAddress();
|
||||
GlobalConfig.dyPingJiaInterfaceAddress = loginUserVO.getDyPingJiaInterfaceAddress();
|
||||
navigateToPlatformSelection(primaryStage);
|
||||
});
|
||||
|
||||
// 添加组件到主容器
|
||||
root.getChildren().addAll(titleLabel, infoLabel, new Label("账号"), accountField,
|
||||
new Label("密码"), passwordField, loginButton);
|
||||
|
||||
// 设置场景并显示窗口
|
||||
Scene scene = new Scene(root, 400, 600);
|
||||
primaryStage.setScene(scene);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.fantaibao.page;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.fantaibao.base.FtbCrawlNetBase;
|
||||
import com.fantaibao.config.GlobalConfig;
|
||||
import com.fantaibao.config.SpringContext;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
|
||||
@@ -13,4 +13,4 @@ spring:
|
||||
banner-mode: console
|
||||
|
||||
server:
|
||||
port: 8080
|
||||
port: 8000
|
||||
Reference in New Issue
Block a user