Commit 9c033d0104f7c46bfd93183c8632cc745a10c5fd

Authored by xingyu4j
1 parent cb006ddf

DateUtils ==> LocalDateTime

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; @@ -5,11 +5,9 @@ import cn.hutool.core.date.LocalDateTimeUtil;
5 5
6 import java.time.Duration; 6 import java.time.Duration;
7 import java.time.Instant; 7 import java.time.Instant;
8 -import java.time.LocalDate;  
9 import java.time.LocalDateTime; 8 import java.time.LocalDateTime;
10 import java.time.ZoneId; 9 import java.time.ZoneId;
11 import java.time.ZonedDateTime; 10 import java.time.ZonedDateTime;
12 -import java.time.temporal.ChronoUnit;  
13 import java.util.Calendar; 11 import java.util.Calendar;
14 import java.util.Date; 12 import java.util.Date;
15 13
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 { @@ -45,9 +45,9 @@ public class OAuth2ApproveServiceImpl implements OAuth2ApproveService {
45 Assert.notNull(clientDO, "客户端不能为空"); // 防御性编程 45 Assert.notNull(clientDO, "客户端不能为空"); // 防御性编程
46 if (CollUtil.containsAll(clientDO.getAutoApproveScopes(), requestedScopes)) { 46 if (CollUtil.containsAll(clientDO.getAutoApproveScopes(), requestedScopes)) {
47 // gh-877 - if all scopes are auto approved, approvals still need to be added to the approval store. 47 // gh-877 - if all scopes are auto approved, approvals still need to be added to the approval store.
48 - Date expireTime = DateUtils.addDate(Calendar.SECOND, TIMEOUT); 48 + LocalDateTime expireTime = LocalDateTime.now().plusSeconds(TIMEOUT);
49 for (String scope : requestedScopes) { 49 for (String scope : requestedScopes) {
50 - saveApprove(userId, userType, clientId, scope, true, DateUtils.dateToLocalDateTime(expireTime)); 50 + saveApprove(userId, userType, clientId, scope, true, expireTime);
51 } 51 }
52 return true; 52 return true;
53 } 53 }
@@ -69,12 +69,12 @@ public class OAuth2ApproveServiceImpl implements OAuth2ApproveService { @@ -69,12 +69,12 @@ public class OAuth2ApproveServiceImpl implements OAuth2ApproveService {
69 69
70 // 更新批准的信息 70 // 更新批准的信息
71 boolean success = false; // 需要至少有一个同意 71 boolean success = false; // 需要至少有一个同意
72 - Date expireTime = DateUtils.addDate(Calendar.SECOND, TIMEOUT);  
73 - for (Map.Entry<String, Boolean> entry :requestedScopes.entrySet()) { 72 + LocalDateTime expireTime = LocalDateTime.now().plusSeconds(TIMEOUT);
  73 + for (Map.Entry<String, Boolean> entry : requestedScopes.entrySet()) {
74 if (entry.getValue()) { 74 if (entry.getValue()) {
75 success = true; 75 success = true;
76 } 76 }
77 - saveApprove(userId, userType, clientId, entry.getKey(), entry.getValue(), DateUtils.dateToLocalDateTime(expireTime)); 77 + saveApprove(userId, userType, clientId, entry.getKey(), entry.getValue(), expireTime);
78 } 78 }
79 return success; 79 return success;
80 } 80 }