Browse Source

DateUtils ==> LocalDateTime

xingyu4j 2 years ago
parent
commit
9c033d0104

+ 0 - 2
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;
 

+ 5 - 5
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<String, Boolean> entry :requestedScopes.entrySet()) {
+        LocalDateTime expireTime = LocalDateTime.now().plusSeconds(TIMEOUT);
+        for (Map.Entry<String, Boolean> 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;
     }