package cn.reghao.autodop.dmaster.app.model.po.config.build;

import cn.reghao.autodop.dmaster.app.model.constant.build.RepoAuthType;
import cn.reghao.autodop.dmaster.app.model.constant.build.RepoType;
import cn.reghao.autodop.dmaster.util.validator.ValidEnum;
import cn.reghao.autodop.dmaster.util.db.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.validation.constraints.NotBlank;

/**
 * 仓库认证配置
 *
 * @author reghao
 * @date 2020-05-13 22:50:38
 */
@Getter
@Setter
@Entity
public class RepoAuthConfig extends BaseEntity<Integer> {
    @Column(nullable = false)
    @ValidEnum(value = RepoType.class, message = "请选择正确的仓库类型")
    private String type;
    @Column(nullable = false, unique = true)
    @NotBlank(message = "仓库认证名字不能为空白字符串")
    private String name;
    @Column(nullable = false)
    @ValidEnum(value = RepoAuthType.class, message = "请选择的仓库认证类型")
    private String authType;
    // TODO 根据 authType 选择 username, password 或 rsaPrikey
    private String username;
    private String password;
    @Lob
    @Column(columnDefinition="text")
    private String rsaPrikey;
}
