package com.casic.dcms.mvp.presenter.impl;

import com.casic.dcms.bean.CaseHandleBean;
import com.casic.dcms.listener.OnGetCaseHandleListListener;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.impl.CaseHandleListModelImpl;
import com.casic.dcms.mvp.presenter.ICaseListHandlePresenter;
import com.casic.dcms.mvp.view.ICaseListHandleView;

public class CaseListHandlePresenterImpl extends BasePresenter implements ICaseListHandlePresenter,
        OnGetCaseHandleListListener {

    private final ICaseListHandleView view;
    private final CaseHandleListModelImpl actionModel;

    public CaseListHandlePresenterImpl(ICaseListHandleView caseHandleListView) {
        this.view = caseHandleListView;
        actionModel = new CaseHandleListModelImpl(this);
    }

    @Override
    public void onReadyRetrofitRequest(String isOvertime, String isEmergent, int limit, int offset) {
        addSubscription(actionModel.sendCaseHandleListRequest(isOvertime, isEmergent, limit, offset));
    }

    @Override
    public void disposeRetrofitRequest() {
        unSubscription();
    }

    @Override
    public void onSuccess(CaseHandleBean resultBean) {
        view.obtainCaseHandleList(resultBean);
    }

    @Override
    public void onFailure(Throwable throwable) {

    }
}
