package com.purui.prims.headless.core.pojo;


import com.purui.prims.common.pojo.RecordInfo;
import com.purui.prims.common.util.AESEncryptionUtil;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Database extends RecordInfo {

    private Long id;

    private Long domainId;

    private String name;

    private String description;

    private String version;

    // 完整的url
    private String url;

    private String username;

    private String password;

    private String database;

    private String schema;
    /**
     * mysql,clickhouse
     */
    private String type;

    // 密码是否加密
    private boolean encryptFlag;

    public String passwordDecrypt() {
        if (encryptFlag) {
            return AESEncryptionUtil.aesDecryptECB(password);
        }
        return password;
    }
}
