package com.sunyard.chsm.model.dto;

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

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

/**
 * @author liulu
 * @since 2024/11/6
 */
public abstract class CertDTO {

    @EqualsAndHashCode(callSuper = true)
    @Data
    public static class Query extends PageQuery {

        private Long appId;
        /**
         * 证书类型: encrypt_decrypt 加密证书, sign_verify 签名证书
         */
        private String certType;
    }


    @Data
    public static class ACView {
        private Long id;
        private Long applicationId;
        private String appName;
        private Boolean single;
        /**
         * 密钥算法
         */
        private String keyAlg;
        // 证书类型
        private String certType;
        private String certTypeText;
        /**
         * 证书DN
         */
        private String subject;
        /**
         * 序列号
         */
        private String serialNumber;
        /**
         * 颁发着
         */
        private String issuerDn;
        /**
         * 开始时间
         */
        private Date notBefore;
        /**
         * 结束时间
         */
        private Date notAfter;
        private String remark;
        private LocalDateTime createTime;
    }

    @Data
    public static class ImportCert {
        /**
         * 密钥算法 目前支持: SM2
         */
        @NotEmpty(message = "密钥算法不能为空")
        private String keyAlg;
        /**
         * 是否单证,
         */
        @NotNull(message = "单双证不能为空")
        private Boolean single;
        /**
         * 证书类型: encrypt_decrypt 加密证书, sign_verify 签名证书
         */
        private String certType;
        /**
         * 单证证书内容
         */
        private String certText;
        /**
         * 签名证书内容
         */
        private String signCertText;
        /**
         * 加密证书内容
         */
        private String encCertText;
        /**
         * 加密密钥信封
         */
        private String envelopedKey;
        private String remark;

    }

    @Data
    public static class CaInfo {
        private Long id;
        /**
         * 密钥算法 目前支持: SM2
         */
        @NotEmpty(message = "密钥算法不能为空")
        private String keyAlg;
        @NotEmpty(message = "CA名称不能为空")
        private String caName;
        private String caUrl;

        /**
         * 根证书内容
         */
        @NotEmpty(message = "根证书不能为空")
        private String certText;

        private String remark;
    }

    @EqualsAndHashCode(callSuper = true)
    @Data
    public static class CAQuery extends PageQuery {

        private String caName;
    }

    @Data
    public static class CAView {
        private Long id;
        private String caName;
        private String caUrl;
        /**
         * 密钥算法
         */
        private String keyAlg;
        /**
         * 证书DN
         */
        private String subject;
        private String certText;
        private String remark;
        private LocalDateTime createTime;
    }

}
