package cn.reghao.bnt.web.devops.machine.model.po;

import cn.reghao.bnt.web.util.BaseEntity;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;

/**
 * @author reghao
 * @date 2021-06-29 09:36:13
 */
@NoArgsConstructor
@Getter
@Setter
@Entity
@Table(name = "devops_machine_host")
public class MachineHost extends BaseEntity {
    @NotNull
    @OneToOne
    private MachineInfo machineInfo;
    @Column(unique = true, nullable = false)
    private String machineId;
    @NotNull
    private String machineIpv4;
    @NotNull
    private String env;

    // TODO 根据机器所属的地区，机房等维度来分组
    public MachineHost(MachineInfo machineInfo, String env) {
        this.machineInfo = machineInfo;
        this.machineId = machineInfo.getMachineId();
        this.machineIpv4 = machineInfo.getMachineIpv4();
        this.env = env;
    }
}
