package cn.dankal.basiclib.rx;

import cn.dankal.basiclib.exception.ApiException;
import cn.dankal.basiclib.model.BaseModel;
import io.reactivex.functions.Function;

public class MapFunc<T extends BaseModel> implements Function {

    @Override
    public Object apply(Object o) throws Exception {
        BaseModel model = (BaseModel) o;
        if (model.getCode() != 10000) {
            throw new ApiException(model.getCode(), model.getMessage());
        }
        return o;
    }
}
