package cd.casic.ci.process.dto.resp.shuimu;

import com.alibaba.fastjson.JSON;
import lombok.Data;

@Data
public class ShuiMuProjectVersionResp {
    private Integer id;
    private String vcs;
    private String versionCode;
    private Repo repo;
    private Integer projectId;
    private Integer createBy;
    private Long createAt;
    private Long updateAt;
    private Long deleteAt;
    private String ownerId;
    private String workSpaceState;
    private BuildState buildState;
    private Boolean containsNeedFile;
    private String buildResult;
    private String buildLog;
    private VerifyState verifyState;
    private String verifyLog;
    public void setRepo(Object repo) {
        if (repo instanceof String) {
            this.repo = JSON.parseObject((String) repo, Repo.class);
        } else if (repo instanceof Repo) {
            this.repo = (Repo) repo;
        }
    }

    public void setBuildState(Object buildState) {
        if (buildState instanceof String) {
            this.buildState = JSON.parseObject((String) buildState, BuildState.class);
        } else if (buildState instanceof BuildState) {
            this.buildState = (BuildState) buildState;
        }
    }

    public void setVerifyState(Object verifyState) {
        if (verifyState instanceof String) {
            this.verifyState = JSON.parseObject((String) verifyState, VerifyState.class);
        } else if (verifyState instanceof VerifyState) {
            this.verifyState = (VerifyState) verifyState;
        }
    }

    @Data
    public static class Repo {
        private String env;
        private String envSpecs;
        private String filename;
        private String filesize;
        private String hash;
        private String totalCount;
    }

    @Data
    public static class BuildState {
        private Integer state;
    }

    @Data
    public static class VerifyState {
        private Integer state;
    }
}