package com.mortals.xhx.common.pdu.api;

import com.mortals.xhx.common.code.YesNoEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang.StringUtils;

/**
 * @author karlhoo
 */
@Data
public class ApiRespPdu<T> {
    /**
     * 结果编码
     */
    private int code;
    /**
     * 结果描述
     */
    private String msg;
    /**
     * 响应数据
     */
    private T data;

    public ApiRespPdu() {
        super();
    }

    public ApiRespPdu(int code, String msg) {
        super();
        this.code = code;
        this.msg = msg;
    }

    public ApiRespPdu(int code, String msg, T data) {
        super();
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public boolean isSuccess() {
        if (YesNoEnum.YES.getValue() == code) {
            return true;
        }
        return false;
    }

}
