package com.red.circle.other.app.dto.clientobject.game.sud;
import com.red.circle.framework.web.response.IgnoreResultResponse;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;

@Data
@Accessors(chain = true)
public class SudResponse <T>  implements Serializable, IgnoreResultResponse {
    private static final long serialVersionUID = 1L;

    /**
     * 错误码，0成功，其他表示错误
     */
    private Integer ret_code;

    /**
     * 错误信息
     */
    private String ret_msg;

    /**
     * sdk错误码，0:成功，其他表示错误
     */
    private Integer sdk_error_code;

    private T data;


    public static <T> SudResponse<T> fail(SudErrorCode code) {
        return new SudResponse<T>()
                .setRet_code(code.getCode())
                .setRet_msg(code.getMessage())
                .setSdk_error_code(code.getCode());
    }

    public static <T> SudResponse<T> success(T body) {
        return new SudResponse<T>()
                .setRet_code(SudErrorCode.SUCCESS.getCode())
                .setRet_msg(SudErrorCode.SUCCESS.getMessage())
                .setSdk_error_code(SudErrorCode.SUCCESS.getCode())
                .setData(body);
    }

}
