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

import com.casic.dcms.bean.DeptTreeBean;
import com.casic.dcms.listener.OnGetDeptTreeListener;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.impl.DeptTreeModelImpl;
import com.casic.dcms.mvp.presenter.IDeptTreePresenter;
import com.casic.dcms.mvp.view.IDeptTreeView;

public class DeptTreePresenterImpl extends BasePresenter implements IDeptTreePresenter, OnGetDeptTreeListener {

    private final IDeptTreeView view;
    private final DeptTreeModelImpl actionModel;

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

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

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

    @Override
    public void onFailure(Throwable throwable) {

    }

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