liding
5 天以前 92d4fac0b58498efc6be7764f00364535beb3d71
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package com.ruoyi.business.dto;
 
import jakarta.validation.constraints.*;
import lombok.Data;
 
import static com.ruoyi.common.utils.DateUtils.parseDate;
 
@Data
public class YearlyQueryDto {
 
    @Size(min = 2, max = 2, message = "时间范围必须包含开始和结束日期")
    private String[] timeRange;
 
    @AssertTrue(message = "日期格式必须为YYYY-MM")
    public boolean isTimeRangeValid() {
        try {
            if (timeRange == null || timeRange.length != 2) return false;
            parseDate(timeRange[0]);
            parseDate(timeRange[1]);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
 
}