package com.cooleshow.student.presenter.mine;

import com.cooleshow.base.presenter.BasePresenter;
import com.cooleshow.base.rx.BaseObserver;
import com.cooleshow.student.api.APIService;
import com.cooleshow.student.bean.TeachableInstrumentBean;
import com.cooleshow.student.contract.TeachableInstrumentContract;


import java.util.List;

/**
 * 创建日期：2022/5/13 16:32
 *
 * @author Ryan
 * 类说明：
 */
public class TeachableInstrumentPresenter extends BasePresenter<TeachableInstrumentContract.TeachableInstrumentView> implements TeachableInstrumentContract.Presenter {

    @Override
    public void subjectSelect() {
        getView().showLoading();
        addSubscribe(create(APIService.class).subjectSelect(), new BaseObserver<List<TeachableInstrumentBean>>(getView()) {
            @Override
            protected void onSuccess(List<TeachableInstrumentBean> data) {
                if (getView() != null) {
                    getView().subjectSelectSuccess(data);
                }
            }
            @Override
            public void onComplete() {
                super.onComplete();
                getView().hideLoading();
            }

        });
    }

    public void setSubject(String subjectId){
        getView().showLoading();
        addSubscribe(create(APIService.class).setSubject(subjectId), new BaseObserver<Object>(getView()) {
            @Override
            protected void onSuccess(Object data) {
                if (getView() != null) {
                    getView().setSubjectSuccess(data);
                }
            }
            @Override
            public void onComplete() {
                super.onComplete();
                getView().hideLoading();
            }

        });
    }
}
