日期校验问题

This commit is contained in:
2024-07-25 15:55:03 +08:00
parent e9ec9a1ca5
commit c7d4757c64
3 changed files with 12 additions and 18 deletions

View File

@@ -1,18 +1,4 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.ysk.cashier.controller.order;
import cn.ysk.cashier.annotation.Log;

View File

@@ -19,6 +19,7 @@ import lombok.Data;
import java.util.List;
import cn.ysk.cashier.annotation.Query;
import org.apache.commons.lang3.StringUtils;
/**
* @website https://eladmin.vip
@@ -74,4 +75,8 @@ public class TbOrderInfoQueryCriteria{
private String tableName;
private String productName;
public void setProductName(String productName) {
if(StringUtils.isNotBlank(productName)) this.productName = productName;
}
}

View File

@@ -103,6 +103,9 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
Date startTime, endTime;
DateTime offsetMonth = cn.hutool.core.date.DateUtil.offsetMonth(new Date(), 3);
if (criteria.getCreatedAt() != null && criteria.getCreatedAt().size() == 2) {
if (criteria.getCreatedAt().get(0) < System.currentTimeMillis() - 1000 * 60 * 60 * 24 * 90L) {
throw new BadRequestException("查询时间范围不能超过三个月");
}
Long startLong = criteria.getCreatedAt().get(0);
Long endLong = criteria.getCreatedAt().get(1);
@@ -110,9 +113,9 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
endTime = new Date(endLong);
// 如果开始时间小于三个月前,不查询
if (startTime.before(offsetMonth)) {
throw new BadRequestException("查询时间范围不能超过三个月");
}
// if (startTime.before(offsetMonth)) {
// throw new BadRequestException("查询时间范围不能超过三个月");
// }
} else {
startTime = offsetMonth;
endTime = new Date();