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

import cn.reghao.bnt.web.devops.app.model.constant.DeployStatus;
import cn.reghao.bnt.web.devops.app.model.po.config.AppDeployConfig;
import cn.reghao.jutil.jdk.web.result.NotAvailable;
import lombok.Data;
import lombok.NoArgsConstructor;

import jakarta.persistence.Embeddable;
import jakarta.persistence.OneToOne;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author reghao
 * @date 2024-07-27 09:20:37
 */
@NoArgsConstructor
@Data
@Embeddable
public class AppDeployingNode implements Serializable {
    private static final long serialVersionUID = 1L;

    @OneToOne
    private AppDeployConfig deployConfig;
    private LocalDateTime deployTime;
    private String deployResult;
    private String deployBy;
    private boolean onDeploying;
    private boolean deployed;

    // AppRunning
    private Boolean running;
    private LocalDateTime startTime;
    private Integer pid;
    private LocalDateTime lastCheck;

    public AppDeployingNode(AppDeployConfig deployConfig) {
        this.deployConfig = deployConfig;
        this.deployResult = DeployStatus.neverDeploy.getDesc();
        //this.deployTime = DateTimeConverter.localDateTime(0);
        this.deployBy = NotAvailable.na.getDesc();
        this.onDeploying = false;
        this.deployed = false;

        this.running = false;
        //this.startTime = DateTimeConverter.localDateTime(0);
        this.pid = -1;
        //this.lastCheck = DateTimeConverter.localDateTime(0);
    }
}
