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

import cn.reghao.autodop.dmaster.app.model.po.config.AppConfig;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Collections;

/**
 * @author reghao
 * @date 2021-06-03 16:15:23
 */
@Data
public class NewApp implements Serializable {
    private static final long serialVersionUID = 1L;

    @NotBlank(message = "应用 ID 不能为空白字符串")
    private String newId;
    @NotBlank(message = "仓库分支不能为空白字符串")
    private String newRepoBranch;
    @NotBlank(message = "应用环境不能为空白字符串")
    private String env;

    public AppConfig app(AppConfig from) {
        from.setAppId(newId);
        from.setRepoBranch(newRepoBranch);
        from.setEnv(env);
        from.setNotifyGroups(Collections.emptyList());
        from.setDeployConfigs(Collections.emptyList());

        from.setId(null);
        from.setCreateTime(null);
        from.setUpdateTime(null);
        return from;
    }
}
