♻️ Refactoring code. close #I60453 令牌管理 时间格式化

This commit is contained in:
lbw 2022-11-08 17:57:42 +08:00
parent 6d9713ec0e
commit 57d3aa9bbf
2 changed files with 12 additions and 6 deletions

View File

@ -16,6 +16,8 @@
package com.pig4cloud.pig.auth.endpoint; package com.pig4cloud.pig.auth.endpoint;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.TemporalAccessorUtil;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -213,8 +215,14 @@ public class PigTokenEndpoint {
tokenVo.setUsername(authorization.getPrincipalName()); tokenVo.setUsername(authorization.getPrincipalName());
OAuth2Authorization.Token<OAuth2AccessToken> accessToken = authorization.getAccessToken(); OAuth2Authorization.Token<OAuth2AccessToken> accessToken = authorization.getAccessToken();
tokenVo.setAccessToken(accessToken.getToken().getTokenValue()); tokenVo.setAccessToken(accessToken.getToken().getTokenValue());
tokenVo.setExpiresAt(accessToken.getToken().getExpiresAt());
tokenVo.setIssuedAt(accessToken.getToken().getIssuedAt()); String expiresAt = TemporalAccessorUtil.format(accessToken.getToken().getExpiresAt(),
DatePattern.NORM_DATETIME_PATTERN);
tokenVo.setExpiresAt(expiresAt);
String issuedAt = TemporalAccessorUtil.format(accessToken.getToken().getIssuedAt(),
DatePattern.NORM_DATETIME_PATTERN);
tokenVo.setIssuedAt(issuedAt);
return tokenVo; return tokenVo;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
result.setRecords(tokenVoList); result.setRecords(tokenVoList);

View File

@ -2,8 +2,6 @@ package com.pig4cloud.pig.admin.api.vo;
import lombok.Data; import lombok.Data;
import java.time.Instant;
/** /**
* 前端展示令牌管理 * 前端展示令牌管理
* *
@ -23,8 +21,8 @@ public class TokenVo {
private String accessToken; private String accessToken;
private Instant issuedAt; private String issuedAt;
private Instant expiresAt; private String expiresAt;
} }