jinpengyong
2022-01-17 3ddfa12fbc43e80e99e4959fbac8881eaa8e3ca3
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.moral.api.pojo.form.aqi;
 
import com.fasterxml.jackson.annotation.JsonFormat;
import com.moral.util.DateUtils;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
 
import java.util.Date;
 
/**
 * @ClassName SpecialCitiesPollutionLevel
 * @Description 查询28,74城市接收参数实体类
 * @Author 陈凯裕
 * @Date 2021/12/31 9:35
 * @Version TODO
 **/
@Data
public class SpecialCitiesPollutionLevelForm {
    /*
     * 如果是查年数据则该参数不能为空
     * */
    @DateTimeFormat(pattern = "yyyy")
    @JsonFormat(pattern = "yyyy", timezone = "GMT+8")
    private Date year;
 
    /*
     * 如果是查月数据则该参数不能为空
     * */
    @DateTimeFormat(pattern = "yyyy-MM")
    @JsonFormat(pattern = "yyyy-MM", timezone = "GMT+8")
    private Date month;
 
    /*
     * 用于查询数据的开始时间,由form自行转换
     * */
    private Date startDate;
 
    /*
     * 用于查询数据的结束时间,由form自行转换
     * */
    private Date endDate;
 
    public boolean valid() {
        if ( (year == null && month == null)||(year != null && month != null))
            return false;
        //时间转换
        if (year != null) {
            startDate = DateUtils.getFirstDayOfYear(year);
            endDate = DateUtils.getLastDayOfYear(year);
            return true;
        }
        startDate = DateUtils.getFirstDayOfMonth(month);
        endDate = DateUtils.getLastDayOfMonth(month);
        return true;
    }
}