fix(项目设置): 时间比较修改

--user=郭雨琦 时间比较修改
This commit is contained in:
guoyuqi 2022-02-15 18:21:32 +08:00 committed by xiaomeinvG
parent b4480e0ba6
commit e606ce895a
3 changed files with 19 additions and 8 deletions

View File

@ -534,14 +534,14 @@ public class ShareInfoService {
millisCheck(shareInfo,1000 * 60 * 60 * 24);
}else {
String expr= projectApplication.getShareReportExpr();
long timeMills = getTimeMills(expr);
long timeMills = getTimeMills(shareInfo.getUpdateTime(),expr);
millisCheck(shareInfo,timeMills);
}
}
}
private void millisCheck(ShareInfo shareInfo, long millis) {
if (System.currentTimeMillis() - shareInfo.getUpdateTime() > millis) {
if (shareInfo.getUpdateTime()<millis) {
shareInfoMapper.deleteByPrimaryKey(shareInfo.getId());
MSException.throwException("连接已失效,请重新获取!");
}

View File

@ -1,10 +1,8 @@
package io.metersphere.api.service.utils;
import org.apache.commons.lang3.StringUtils;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.*;
public class ShareUtill {
@ -13,8 +11,10 @@ public class ShareUtill {
private static final String UNIT_MONTH = "M";
private static final String UNIT_YEAR = "Y";
public static long getTimeMills(String expr) {
LocalDateTime localDateTime = LocalDateTime.of(LocalDate.now(), LocalTime.now().withMinute(0).withSecond(0).withNano(0));
public static long getTimeMills(long time,String expr) {
Instant instant = Instant.ofEpochMilli(time);
ZoneId zone = ZoneId.systemDefault();
LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, zone);
long timeMills = 0;
LocalDateTime date = exprToLocalDateTime(localDateTime, expr);
if (date != null) {

View File

@ -10,6 +10,17 @@ CREATE TABLE `operating_log_resource`
KEY `source_id_index` (`source_id`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE utf8mb4_general_ci;
CREATE TABLE IF NOT EXISTS `project_application`
(
`project_id` varchar(50) DEFAULT NULL,
`type` varchar(50) DEFAULT NULL,
`share_report_expr`varchar(50) NOT NULL DEFAULT '24H',
UNIQUE KEY `project_application_pk` (`project_id`, `type`),
KEY `project_application_project_id_index` (`project_id`),
KEY `project_application_type` (`type`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4 COLLATE utf8mb4_general_ci;
-- permission
DROP PROCEDURE IF EXISTS test_personal;
DELIMITER //