package com.sunyard.chsm.dto;

import com.sunyard.chsm.model.PageQuery;
import lombok.Data;
import lombok.EqualsAndHashCode;

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

/**
 * @author liulu
 * @since 2024/10/22
 */
public abstract class KeyTemplateDTO {

    @EqualsAndHashCode(callSuper = true)
    @Data
    public static class Query extends PageQuery {
        /**
         * 密钥类型
         * @see com.sunyard.chsm.enums.KeyCategory#getCode()
         */
        private String keyType;
    }

    @Data
    public static class KTView {
        private Long id;
        private String code;
        private String name;
        private String keyType;
        private String keyTypeText;
        private String keyAlg;
        private Integer keyLength;
        private List<String> keyUsages;
        private String keyUsageText;
        private Integer validTime;
        private String validUnit;
        private Integer startAfterCreateTime;
        private String startAfterCreateUnit;

        private String remark;
        private LocalDateTime createTime;

    }


    @Data
    public static class KTSave {
        private Long id;
        /**
         * 模版编号
         */
        @NotBlank(message = "模版编号不能为空")
        private String code;
        /**
         * 模版名称
         */
        @NotBlank(message = "模版名称不能为空")
        private String name;
        /**
         * 密钥类型
         * @see com.sunyard.chsm.enums.KeyCategory#getCode()
         */
        @NotBlank(message = "密钥类型不能为空")
        private String keyType;
        /**
         * 密钥算法
         * @see com.sunyard.chsm.enums.KeyAlg#getCode()
         */
        @NotBlank(message = "密钥算法不能为空")
        private String keyAlg;
        /**
         * 密钥长度
         */
        private Integer keyLength;
        /**
         * 密钥用途
         * @see com.sunyard.chsm.enums.KeyUsage#getCode()
         */
        @NotEmpty(message = "密钥用途不能为空")
        private List<String> keyUsages;
        /**
         * 密钥有效期
         */
        @NotNull(message = "密钥有效期不能为空")
        private Integer validTime;
        /**
         * 密钥有效期时间单位 YEARS, MONTHS, DAYS
         */
        @NotBlank(message = "密钥有效期时间单位不能为空")
        private String validUnit;
        /**
         * 创建后多久生效
         */
        @NotNull(message = "创建后多久生效不能为空")
        private Integer startAfterCreateTime;
        /**
         * 创建后多久生效时间单位 MONTHS, DAYS, HOURS
         */
        @NotBlank(message = "创建后多久生效时间单位不能为空")
        private String startAfterCreateUnit;

        private String remark;

    }


}
