package com.casic.dcms.mvp.presenter;

import com.casic.dcms.bean.DeptTreeBean;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.DeptTreeModelImpl;
import com.casic.dcms.mvp.view.IDeptTreeView;

public class DeptTreePresenterImpl extends BasePresenter implements IDeptTreePresenter, DeptTreeModelImpl.OnGetDeptTreeListener {

    private IDeptTreeView view;
    private DeptTreeModelImpl actionModel;

    public DeptTreePresenterImpl(IDeptTreeView deptTreeView) {
        this.view = deptTreeView;
        actionModel = new DeptTreeModelImpl(this);
    }

    @Override
    public void onReadyRetrofitRequest(String pid) {
        addSubscription(actionModel.sendRetrofitRequest(pid));
    }

    @Override
    public void onSuccess(DeptTreeBean resultBean) {
        view.obtainDeptTreeResult(resultBean);
    }

    @Override
    public void onFailure(Throwable throwable) {

    }

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