package com.ltgk.boat.domain.dto;


import cn.hutool.core.date.DateUtil;
import com.ltgk.common.utils.StringUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import java.util.Date;

/**
 * 渔船报警统计请求参数-安全页-右侧渔船动态
 *
 * @author Qi ChengBin
 * @date 2025/04/21
 */
@Data
public class BoatAlarmInfoReq {

    @ApiModelProperty(value = "时间类型")
    @NotBlank(message = "时间类型不能为空")
    private String timeType;

    @ApiModelProperty(value = "开始时间")
    private Date startTime;

    public void setTimeType(String timeType) {
        if (StringUtils.isNotBlank(timeType) && "year".equals(timeType)){
            this.startTime = DateUtil.beginOfYear(new Date());
        }
        if (StringUtils.isNotBlank(timeType) && "quarter".equals(timeType)){
            this.startTime = DateUtil.beginOfQuarter(new Date());
        }
        if (StringUtils.isNotBlank(timeType) && "month".equals(timeType)){
            this.startTime = DateUtil.beginOfMonth(new Date());
        }
        this.timeType = timeType;
    }
}
