package com.casic.dcms.mvp.presenter;

import com.casic.dcms.bean.PhoneBookBean;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.PhoneBookModelImpl;
import com.casic.dcms.mvp.view.IPhoneBookView;

public class PhoneBookPresenterImpl extends BasePresenter implements IPhoneBookPresenter, PhoneBookModelImpl.OnGetPhoneBookListener {

    private IPhoneBookView view;
    private PhoneBookModelImpl actionModel;

    public PhoneBookPresenterImpl(IPhoneBookView phoneBookView) {
        this.view = phoneBookView;
        actionModel = new PhoneBookModelImpl(this);
    }

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

    @Override
    public void onSuccess(PhoneBookBean resultBean) {
        view.obtainPhoneBookResult(resultBean);
    }

    @Override
    public void onFailure(Throwable throwable) {

    }

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