package com.smppw.modaq.domain.dto.report;

import cn.hutool.core.util.StrUtil;
import com.smppw.modaq.common.enums.ReportParseStatus;
import lombok.Getter;
import lombok.Setter;

/**
 * @author wangzaijun
 * @date 2024/10/10 14:08
 * @description 报告解析结果
 */
@Setter
@Getter
public class ParseResult<T extends ReportData> {
    private Integer status;

    private String msg;

    private T data;

    public ParseResult() {
    }

    public ParseResult(Integer status, String msg, T data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }

    public ParseResult(ReportParseStatus parseStatus, T data) {
        this.status = parseStatus.getCode();
        this.msg = parseStatus.getMsg();
        this.data = data;
    }

    public ParseResult(ReportParseStatus parseStatus, T data, String format) {
        this.status = parseStatus.getCode();
        this.msg = StrUtil.format(parseStatus.getMsg(), format);
        this.data = data;
    }

    @Override
    public String toString() {
        return "{" +
                "status=" + status +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }
}
