From 9c033d0104f7c46bfd93183c8632cc745a10c5fd Mon Sep 17 00:00:00 2001 From: xingyu4j Date: Wed, 9 Nov 2022 12:43:54 +0800 Subject: [PATCH] DateUtils ==> LocalDateTime --- .../yudao/framework/common/util/date/DateUtils.java | 2 -- .../service/oauth2/OAuth2ApproveServiceImpl.java | 10 +++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/DateUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/DateUtils.java index b2b7e3bc3..674dfb049 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/DateUtils.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/DateUtils.java @@ -5,11 +5,9 @@ import cn.hutool.core.date.LocalDateTimeUtil; import java.time.Duration; import java.time.Instant; -import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZonedDateTime; -import java.time.temporal.ChronoUnit; import java.util.Calendar; import java.util.Date; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2ApproveServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2ApproveServiceImpl.java index 4099eacb0..29f0f11b0 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2ApproveServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2ApproveServiceImpl.java @@ -45,9 +45,9 @@ public class OAuth2ApproveServiceImpl implements OAuth2ApproveService { Assert.notNull(clientDO, "客户端不能为空"); // 防御性编程 if (CollUtil.containsAll(clientDO.getAutoApproveScopes(), requestedScopes)) { // gh-877 - if all scopes are auto approved, approvals still need to be added to the approval store. - Date expireTime = DateUtils.addDate(Calendar.SECOND, TIMEOUT); + LocalDateTime expireTime = LocalDateTime.now().plusSeconds(TIMEOUT); for (String scope : requestedScopes) { - saveApprove(userId, userType, clientId, scope, true, DateUtils.dateToLocalDateTime(expireTime)); + saveApprove(userId, userType, clientId, scope, true, expireTime); } return true; } @@ -69,12 +69,12 @@ public class OAuth2ApproveServiceImpl implements OAuth2ApproveService { // 更新批准的信息 boolean success = false; // 需要至少有一个同意 - Date expireTime = DateUtils.addDate(Calendar.SECOND, TIMEOUT); - for (Map.Entry entry :requestedScopes.entrySet()) { + LocalDateTime expireTime = LocalDateTime.now().plusSeconds(TIMEOUT); + for (Map.Entry entry : requestedScopes.entrySet()) { if (entry.getValue()) { success = true; } - saveApprove(userId, userType, clientId, entry.getKey(), entry.getValue(), DateUtils.dateToLocalDateTime(expireTime)); + saveApprove(userId, userType, clientId, entry.getKey(), entry.getValue(), expireTime); } return success; }