package com.xy.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.xy.utils.PageBean;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotNull;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * <p>
 * 设备温度日志表
 * </p>
 *
 * @author lijin
 * @since 2023-01-11
 */
public class DeviceTempRecordsDto {

    @Data
    @Accessors(chain = true)
    public static class Page extends Vo {

        @ApiModelProperty(value = "分页对象", required = true)
        private PageBean page;

        @JsonFormat(pattern = "yyyy-MM-dd")
        @ApiModelProperty(value = "创建时间-起")
        private LocalDate beginCreateTime;

        @JsonFormat(pattern = "yyyy-MM-dd")
        @ApiModelProperty(value = "创建时间-始")
        private LocalDate endCreateTime;

        public LocalDateTime getBeginCreateTime() {
            return beginCreateTime == null ? null : beginCreateTime.atTime(0, 0, 0);
        }

        public LocalDateTime getEndCreateTime() {
            return endCreateTime == null ? null : endCreateTime.atTime(23, 59, 59);
        }
    }

    @Data
    @Accessors(chain = true)
    public static class Save extends Vo {

        @NotNull(message = "deviceId不能为空")
        @ApiModelProperty(value = "设备ID")
        private Long deviceId;
    }

    @Data
    @Accessors(chain = true)
    public static class Vo {

        @ApiModelProperty(value = "id")
        private Integer id;

        @ApiModelProperty(value = "设备ID")
        private Long deviceId;

        @ApiModelProperty(value = "温度值")
        private Integer tempValue;

        @ApiModelProperty(value = "温控仪状态")
        private String wkyState;

        @ApiModelProperty(value = "创建时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime createTime;


    }

}
