package com.zfire.mall.manager.bean.k3.bill.result;

import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;

import java.util.List;
import java.util.Map;

@Data
public class ResponseStatus {

    private static final long serialVersionUID=1L;

    private Integer errorCode ;

    @JSONField(name = "IsSuccess")
    private boolean isSuccess = false;

    @JSONField(name = "Errors")
    private List<Errors> errors;

    @JSONField(name = "SuccessEntitys")
    private List<SuccessEntitys> successEntitys;

    @JSONField(name = "SuccessMessages")
    private List<Map<String, Object>> successMessages;

    @JSONField(name = "MsgCode")
    private Integer msgCode;

    @JSONField(name = "Message")
    private String message;

    public String getErrorInfo() {
        String info = "";
        if (this.errors != null && this.errors.size() > 0) {
            StringBuilder sb = new StringBuilder();
            for (Errors error : this.errors) {
                sb.append("序号：")
                        .append(error.getDIndex())
                        .append(" ")
                        .append("字段：")
                        .append(error.getFieldName())
                        .append("，")
                        .append(error.getMessage())
                        .append("；");
            }
            info = sb.toString();
        }
        return info;
    }

}
