Commit 70d8886d by 刘鑫

fix: 日期范围限制实现变更

1 parent 61fdd5fe
package com.dituhui.pea.order.controller;
import cn.hutool.core.date.LocalDateTimeUtil;
import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dto.OrganizationTreeDTO;
......@@ -28,6 +29,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.Duration;
import java.time.Period;
import java.util.Date;
......@@ -109,12 +111,14 @@ public class PeaApiController {
@PostMapping("/capacity/query")
public Result<CapacityQueryDTO.Result> capacityQuery(@Validated @RequestBody CapacityQueryDTO.Request reqDTO) {
//查询日期起止参数限制为一月
Period between = Period.between(DateUtil.fromDate(reqDTO.getBeginDate()).toLocalDate(), DateUtil.fromDate(reqDTO.getEndDate()).toLocalDate());
if (between.getMonths() > 1) {
Duration between = LocalDateTimeUtil.between(DateUtil.fromDate(reqDTO.getBeginDate()), DateUtil.fromDate(reqDTO.getEndDate()));
if (between.toDays()> 31) {
throw new BusinessException("查询日期起止参数限制为一月");
}
CapacityQueryDTO.Result result = new CapacityQueryDTO.Result();
return Result.success(result);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!