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; 
 | 
    } 
 | 
} 
 |