2
0

feat: 用户登录绑定门户跳转参数

This commit is contained in:
TsMask
2024-12-06 21:50:15 +08:00
parent 91dd6fad8e
commit 735c181fc8
4 changed files with 149 additions and 11 deletions

View File

@@ -13,6 +13,7 @@ import org.wfc.common.core.utils.JwtUtils;
import org.wfc.common.core.utils.StringUtils; import org.wfc.common.core.utils.StringUtils;
import org.wfc.common.core.web.form.LoginBody; import org.wfc.common.core.web.form.LoginBody;
import org.wfc.common.core.web.form.RegisterBody; import org.wfc.common.core.web.form.RegisterBody;
import org.wfc.common.core.web.form.WANFiRedirectParams;
import org.wfc.common.security.auth.AuthUtil; import org.wfc.common.security.auth.AuthUtil;
import org.wfc.common.security.service.TokenService; import org.wfc.common.security.service.TokenService;
import org.wfc.common.security.utils.SecurityUtils; import org.wfc.common.security.utils.SecurityUtils;
@@ -40,8 +41,13 @@ public class TokenController {
@PostMapping("login") @PostMapping("login")
public R<?> login(@RequestBody LoginBody form) { public R<?> login(@RequestBody LoginBody form) {
if ("u".equals(form.getAuthType())) { if ("u".equals(form.getAuthType())) {
WANFiRedirectParams wanFiRedirectParams = form.getWanfiRedirectParams();
if (wanFiRedirectParams == null) {
return R.fail("Invalid Login Parameter");
}
// 用户登录 // 用户登录
LoginUser<UUser> userInfo = uLoginService.login(form.getUsername(), form.getPassword()); LoginUser<UUser> userInfo = uLoginService.login(form.getUsername(), form.getPassword());
userInfo.setWanFiRedirectParams(wanFiRedirectParams);
// 获取登录token // 获取登录token
return R.ok(tokenService.createToken(userInfo)); return R.ok(tokenService.createToken(userInfo));
} }

View File

@@ -1,4 +1,6 @@
package org.wfc.common.core.domain; package org.wfc.common.core.domain;
import org.wfc.common.core.web.form.WANFiRedirectParams;
import java.io.Serializable; import java.io.Serializable;
import java.util.Set; import java.util.Set;
@@ -56,6 +58,11 @@ public class LoginUser<T> implements Serializable
*/ */
private T user; private T user;
/**
* Wifi客户端重定向参数
*/
private WANFiRedirectParams wanFiRedirectParams;
public String getToken() public String getToken()
{ {
return token; return token;
@@ -145,4 +152,12 @@ public class LoginUser<T> implements Serializable
{ {
this.user = user; this.user = user;
} }
public WANFiRedirectParams getWanFiRedirectParams() {
return wanFiRedirectParams;
}
public void setWanFiRedirectParams(WANFiRedirectParams wanFiRedirectParams) {
this.wanFiRedirectParams = wanFiRedirectParams;
}
} }

View File

@@ -2,11 +2,10 @@ package org.wfc.common.core.web.form;
/** /**
* 用户登录对象 * 用户登录对象
* *
* @author wfc * @author wfc
*/ */
public class LoginBody public class LoginBody {
{
/** /**
* 用户名 * 用户名
*/ */
@@ -22,23 +21,24 @@ public class LoginBody
*/ */
private String authType; private String authType;
public String getUsername() /**
{ * Wifi客户端重定向参数
*/
private WANFiRedirectParams wanfiRedirectParams;
public String getUsername() {
return username; return username;
} }
public void setUsername(String username) public void setUsername(String username) {
{
this.username = username; this.username = username;
} }
public String getPassword() public String getPassword() {
{
return password; return password;
} }
public void setPassword(String password) public void setPassword(String password) {
{
this.password = password; this.password = password;
} }
@@ -49,4 +49,12 @@ public class LoginBody
public void setAuthType(String authType) { public void setAuthType(String authType) {
this.authType = authType; this.authType = authType;
} }
public WANFiRedirectParams getWanfiRedirectParams() {
return wanfiRedirectParams;
}
public void setWanfiRedirectParams(WANFiRedirectParams wanfiRedirectParams) {
this.wanfiRedirectParams = wanfiRedirectParams;
}
} }

View File

@@ -0,0 +1,109 @@
package org.wfc.common.core.web.form;
/**
* WANFi门户重定向参数
*
* @author wfc
*/
public class WANFiRedirectParams {
/**
* 用戶的MAC
*/
private String clientMac;
/**
* 用戶的IP
*/
private String clientIp;
/**
* 這裡的單位為microsecond
*/
private long t;
/**
*
* 站點名稱
*/
private String site;
/**
* 成功驗證後要訪問的URL可以在登入頁面中設定。
*/
private String redirectUrl;
/**
* 用戶連接的EAP MAC
*/
private String apMac;
/**
* 用戶連接的SSID名稱
*/
private String ssidName;
/**
* 用戶連接頻段的Radio ID0代表2.4G、1代表5G。
*/
private int radioId;
// Getters and Setters
public String getClientMac() {
return clientMac;
}
public void setClientMac(String clientMac) {
this.clientMac = clientMac;
}
public String getClientIp() {
return clientIp;
}
public void setClientIp(String clientIp) {
this.clientIp = clientIp;
}
public long getT() {
return t;
}
public void setT(long t) {
this.t = t;
}
public String getSite() {
return site;
}
public void setSite(String site) {
this.site = site;
}
public String getRedirectUrl() {
return redirectUrl;
}
public void setRedirectUrl(String redirectUrl) {
this.redirectUrl = redirectUrl;
}
public String getApMac() {
return apMac;
}
public void setApMac(String apMac) {
this.apMac = apMac;
}
public String getSsidName() {
return ssidName;
}
public void setSsidName(String ssidName) {
this.ssidName = ssidName;
}
public int getRadioId() {
return radioId;
}
public void setRadioId(int radioId) {
this.radioId = radioId;
}
}