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

import cn.reghao.autodop.dmaster.app.model.po.config.AppConfig;
import cn.reghao.autodop.dmaster.app.model.po.config.DeployConfig;
import cn.reghao.autodop.dmaster.util.db.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.persistence.MappedSuperclass;

/**
 * 应用基本属性
 *
 * @author reghao
 * @date 2021-06-10 14:40:13
 */
@MappedSuperclass
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Data
public class AppProperty extends BaseEntity<Integer> {
    private String appId;
    private String appName;
    private String appType;
    private String env;
    private String machineId;
    private String machineIpv4;

    public AppProperty(AppConfig app, DeployConfig deployConfig) {
        this.appId = app.getAppId();
        this.appName = app.getAppName();
        this.appType = app.getAppType();
        this.env = app.getEnv();
        this.machineId = deployConfig.getMachineId();
        this.machineIpv4 = deployConfig.getMachineIpv4();
    }

    protected void update0(String appName, String machineIpv4) {
        this.setAppName(appName);
        this.setMachineIpv4(machineIpv4);
    }
}
