package com.xy.dto;

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

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Data
@ApiModel("系统属性交互类")
@Accessors(chain = true)
public class SysSystemValueDto {

    @Data
    @ApiModel("添加类")
    @Accessors(chain = true)
    public static class Save {

        @NotNull(message = "sysId不能为空")
        @ApiModelProperty("系统id")
        private Long sysId;

        @NotBlank(message = "code不能为空")
        @ApiModelProperty("属性编码")
        private String code;

        @NotBlank(message = "value不能为空")
        @ApiModelProperty("属性值")
        private String value;
    }

    @Data
    @ApiModel("查询类")
    @Accessors(chain = true)
    public static class Select extends Vo {

        @ApiModelProperty("分页对象")
        private PageBean page;

        @NotNull(message = "sysId不能为空")
        @ApiModelProperty("系统id")
        private Long sysId;

        @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
    @ApiModel("修改类")
    @Accessors(chain = true)
    public static class Update {

        @NotNull(message = "id不能为空")
        @ApiModelProperty("唯一标识")
        private Long id;

        @ApiModelProperty("属性值")
        private String value;

        @ApiModelProperty("状态")
        private Boolean status;

    }

    @Data
    @ApiModel("删除类")
    @Accessors(chain = true)
    public static class Del {

        @NotEmpty(message = "id不能为空s")
        @ApiModelProperty("唯一标识")
        private List<Long> id;
    }


    @Data
    @ApiModel("返参类")
    @Accessors(chain = true)
    public static class Vo {

        @ApiModelProperty("系统id")
        private Long sysId;

        @ApiModelProperty("属性编码")
        private String code;

        @ApiModelProperty("属性值")
        private String value;

        @ApiModelProperty("状态")
        private Boolean status;

        @ApiModelProperty("唯一标识")
        private Long id;

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

        @ApiModelProperty("更新时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime updateTime;

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

        @ApiModelProperty("更新人")
        private Long updateUser;
    }

}
