package com.qqchen.deploy.backend.deploy.entity;

import com.qqchen.deploy.backend.system.enums.ExternalSystemAuthTypeEnum;
import com.qqchen.deploy.backend.system.enums.ExternalSystemSyncStatusEnum;
import com.qqchen.deploy.backend.system.enums.ExternalSystemTypeEnum;
import com.qqchen.deploy.backend.framework.annotation.LogicDelete;
import com.qqchen.deploy.backend.framework.domain.Entity;
import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;

@Data
@EqualsAndHashCode(callSuper = true)
@jakarta.persistence.Entity
@Table(name = "sys_external_system")
@LogicDelete
public class ExternalSystem extends Entity<Long> {
    
    /**
     * 系统名称
     */
    @Column(nullable = false)
    private String name;
    
    /**
     * 系统类型：JENKINS/GIT/ZENTAO等
     */
    @Column(nullable = false)
    @Enumerated(EnumType.STRING)
    private ExternalSystemTypeEnum type;
    
    /**
     * 系统访问地址
     */
    @Column(nullable = false)
    private String url;
    
    /**
     * 备注说明
     */
    @Column(columnDefinition = "TEXT")
    private String remark;
    
    /**
     * 排序
     */
    private Integer sort;
    
    /**
     * 是否启用
     */
    private Boolean enabled = true;
    
    /**
     * 认证方式：BASIC/TOKEN/OAUTH
     */
    @Column(name = "auth_type", nullable = false)
    @Enumerated(EnumType.STRING)
    private ExternalSystemAuthTypeEnum authType;
    
    /**
     * 用户名
     */
    private String username;
    
    /**
     * 密码
     */
    private String password;
    
    /**
     * 访问令牌
     */
    private String token;
    
    /**
     * 最近连接成功时间
     */
    @Column(name = "last_connect_time")
    private LocalDateTime lastConnectTime;
    
    /**
     * 系统特有配置，JSON格式
     */
    @Column(columnDefinition = "JSON")
    private String config;


}