package cn.skcks.docking.gb28181.wvp.api.video.dto;

import cn.hutool.core.date.DatePattern;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

@NoArgsConstructor
@Data
public class VideoReq {

    @NotBlank(message = "设备编码 不能为空")
    @Schema(description = "设备编码 (支持参数名: deviceCode device_code deviceId device_id)")
    private String deviceCode;

    @Schema(description = "开始时间 (支持参数名: startTime start_time beginTime begin_time)",example = "20230909000000")
    @NotBlank(message = "开始时间 不能为空")
    @DateTimeFormat(pattern= DatePattern.PURE_DATETIME_PATTERN)
    @JsonFormat(pattern = DatePattern.PURE_DATETIME_PATTERN)
    private Date startTime;

    @Schema(description = "结束时间 (支持参数名: endTime end_time endTime end_time)",example = "20230909000500")
    @NotBlank(message = "结束时间 不能为空")
    @DateTimeFormat(pattern= DatePattern.PURE_DATETIME_PATTERN)
    @JsonFormat(pattern = DatePattern.PURE_DATETIME_PATTERN)
    private Date endTime;

    @Schema(description = "http 头是否需要文件名 (没有文件名时浏览器会试图直接播放,会导致短时间内重复访问同一设备,导致失败)")
    private Boolean fileHeader = true;

    @Schema(description = "使用哪种方式拉取历史视频 (true 为 使用 Download 方式拉取 4倍速流, false 为 使用 Playback 原始速率拉取 视频回放)")
    private Boolean useDownload = true;

    public void setDevice_id(String deviceCode){
        this.deviceCode = deviceCode;
    }

    public void setDevice_code(String deviceCode){
        this.deviceCode = deviceCode;
    }

    @DateTimeFormat(pattern= DatePattern.PURE_DATETIME_PATTERN)
    @JsonFormat(pattern = DatePattern.PURE_DATETIME_PATTERN)
    public void setBegin_time(Date startTime){
        this.startTime = startTime;
    }

    @DateTimeFormat(pattern= DatePattern.PURE_DATETIME_PATTERN)
    @JsonFormat(pattern = DatePattern.PURE_DATETIME_PATTERN)
    public void setStart_time(Date startTime){
        this.startTime = startTime;
    }

    @DateTimeFormat(pattern= DatePattern.PURE_DATETIME_PATTERN)
    @JsonFormat(pattern = DatePattern.PURE_DATETIME_PATTERN)
    public void setEnd_time(Date endTime){
        this.endTime = endTime;
    }

    public void setUse_download(Boolean useDownload){
        this.useDownload = useDownload;
    }
}
