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 DeviceRecordsDto {

    @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 = "mercId不能为空")
        @ApiModelProperty(value = "商户ID")
        private Long mercId;

        @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 mercId;

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

        @ApiModelProperty(value = "变更类型")
        private String changeType;

        @ApiModelProperty(value = "变更前")
        private String changeBefore;

        @ApiModelProperty(value = "变更后")
        private String changeAfter;

        @ApiModelProperty(value = "备注")
        private String remark;

        @ApiModelProperty(value = "创建人")
        private Long createUser;

        @ApiModelProperty(value = "创建人姓名")
        private String createUserName;

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

}