feat(oauth2): 为 CodeModel、AccessTokenModel、RefreshTokenModel、ClientTokenModel 添加 createTime 字段,以记录该数据的创建时间

This commit is contained in:
click33 2024-11-26 19:46:42 +08:00
parent a8851cf54d
commit d6b5975bdf
4 changed files with 100 additions and 22 deletions

View File

@ -74,9 +74,15 @@ public class AccessTokenModel implements Serializable {
*/
public Map<String, Object> extraData;
/**
* 创建时间13位时间戳
*/
public long createTime;
public AccessTokenModel() {}
public AccessTokenModel() {
this.createTime = System.currentTimeMillis();
}
/**
* 构建一个
@ -86,7 +92,7 @@ public class AccessTokenModel implements Serializable {
* @param loginId 对应的账号id
*/
public AccessTokenModel(String accessToken, String clientId, Object loginId, List<String> scopes) {
super();
this();
this.accessToken = accessToken;
this.clientId = clientId;
this.loginId = loginId;
@ -175,6 +181,15 @@ public class AccessTokenModel implements Serializable {
return this;
}
public long getCreateTime() {
return createTime;
}
public AccessTokenModel setCreateTime(long createTime) {
this.createTime = createTime;
return this;
}
@Override
public String toString() {
return "AccessTokenModel{" +
@ -187,6 +202,7 @@ public class AccessTokenModel implements Serializable {
", scopes=" + scopes +
", tokenType='" + tokenType + '\'' +
", extraData=" + extraData +
", createTime=" + createTime +
'}';
}

View File

@ -59,6 +59,27 @@ public class ClientTokenModel implements Serializable {
*/
public Map<String, Object> extraData;
/**
* 创建时间13位时间戳
*/
public long createTime;
public ClientTokenModel(){
this.createTime = System.currentTimeMillis();
}
/**
* 构建一个 ClientTokenModel
* @param clientToken clientToken
* @param clientId 应用id
* @param scopes 请求授权范围
*/
public ClientTokenModel(String clientToken, String clientId, List<String> scopes) {
this();
this.clientToken = clientToken;
this.clientId = clientId;
this.scopes = scopes;
}
public String getClientToken() {
return clientToken;
@ -114,19 +135,13 @@ public class ClientTokenModel implements Serializable {
return this;
}
public ClientTokenModel() {}
/**
* 构建一个
* @param clientToken clientToken
* @param clientId 应用id
* @param scopes 请求授权范围
*/
public ClientTokenModel(String clientToken, String clientId, List<String> scopes) {
super();
this.clientToken = clientToken;
this.clientId = clientId;
this.scopes = scopes;
public long getCreateTime() {
return createTime;
}
public ClientTokenModel setCreateTime(long createTime) {
this.createTime = createTime;
return this;
}
@Override
@ -138,6 +153,7 @@ public class ClientTokenModel implements Serializable {
", scopes=" + scopes +
", tokenType=" + tokenType +
", extraData=" + extraData +
", createTime=" + createTime +
'}';
}

View File

@ -57,12 +57,17 @@ public class CodeModel implements Serializable {
* 随机数
*/
public String nonce;
/**
* 创建时间13位时间戳
*/
public long createTime;
/**
* 构建一个
*/
public CodeModel() {
this.createTime = System.currentTimeMillis();
}
/**
* 构建一个
@ -73,7 +78,7 @@ public class CodeModel implements Serializable {
* @param redirectUri 重定向地址
*/
public CodeModel(String code, String clientId, List<String> scopes, Object loginId, String redirectUri, String nonce) {
super();
this();
this.code = code;
this.clientId = clientId;
this.scopes = scopes;
@ -136,10 +141,26 @@ public class CodeModel implements Serializable {
return this;
}
public long getCreateTime() {
return createTime;
}
public CodeModel setCreateTime(long createTime) {
this.createTime = createTime;
return this;
}
@Override
public String toString() {
return "CodeModel [code=" + code + ", clientId=" + clientId + ", scopes=" + scopes + ", loginId=" + loginId
+ ", redirectUri=" + redirectUri + ", nonce=" + nonce + " ]";
return "CodeModel{" +
"code='" + code + '\'' +
", clientId='" + clientId + '\'' +
", scopes=" + scopes +
", loginId=" + loginId +
", redirectUri='" + redirectUri + '\'' +
", nonce='" + nonce + '\'' +
", createTime=" + createTime +
'}';
}
}

View File

@ -59,6 +59,15 @@ public class RefreshTokenModel implements Serializable {
*/
public Map<String, Object> extraData;
/**
* 创建时间13位时间戳
*/
public long createTime;
public RefreshTokenModel() {
this.createTime = System.currentTimeMillis();
}
public String getRefreshToken() {
return refreshToken;
@ -114,10 +123,26 @@ public class RefreshTokenModel implements Serializable {
return this;
}
public long getCreateTime() {
return createTime;
}
public RefreshTokenModel setCreateTime(long createTime) {
this.createTime = createTime;
return this;
}
@Override
public String toString() {
return "RefreshTokenModel [refreshToken=" + refreshToken + ", expiresTime=" + expiresTime
+ ", clientId=" + clientId + ", loginId=" + loginId + ", scopes=" + scopes + ", extraData=" + extraData + "]";
return "RefreshTokenModel [" +
"refreshToken=" + refreshToken +
", expiresTime=" + expiresTime +
", clientId=" + clientId +
", loginId=" + loginId +
", scopes=" + scopes +
", extraData=" + extraData +
", createTime=" + createTime +
"]";
}
/**