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 java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

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

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

        @NotBlank(message = "code不能为空")
        @ApiModelProperty("标识")
        private String code;

        @NotBlank(message = "name不能为空")
        @ApiModelProperty("名称")
        private String name;

        @ApiModelProperty("图标")
        private String icon;
    }

    @Data
    @Accessors(chain = true)
    @ApiModel("更新交互")
    public static class Update {

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

        @ApiModelProperty("名称")
        private String name;

        @ApiModelProperty("状态 true=启用 false=封禁")
        private Boolean status;

        @ApiModelProperty("图标")
        private String icon;
    }

    @Data
    @Accessors(chain = true)
    @ApiModel("查询交互")
    public static class Select extends Vo {
        @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)
    @ApiModel("分页查询交互")
    public static class PageSelect extends Select {
        @ApiModelProperty(value = "分页对象")
        private PageBean page;
    }

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

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

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

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

        @ApiModelProperty("标识")
        private String code;

        @ApiModelProperty("名称")
        private String name;

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

        @ApiModelProperty("图标")
        private String icon;
    }
}
