package com.cooleshow.teacher.presenter.main;

import com.cooleshow.base.presenter.BasePresenter;
import com.cooleshow.base.rx.BaseObserver;
import com.cooleshow.base.utils.RequestBodyUtil;
import com.cooleshow.teacher.api.APIService;
import com.cooleshow.teacher.bean.TeacherUserInfo;
import com.cooleshow.teacher.contract.HomeContract;
import com.cooleshow.usercenter.bean.UserInfo;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.List;

/**
 * Author by pq, Date on 2022/4/20.
 */
public class HomePresenter extends BasePresenter<HomeContract.HomeView> implements HomeContract.Presenter {

    /**
     * 查询UserInfo
     *
     * @param
     */
    @Override
    public void getUserInfo() {
        addSubscribe(create(APIService.class).getUserInfo(), new BaseObserver<UserInfo>(getView()) {
            @Override
            protected void onSuccess(UserInfo data) {
                if (getView() != null) {
                    getView().getUserInfoSuccess(data);
                }
            }
        });
    }

    @Override
    public void getTeacherUserInfo() {
        addSubscribe(create(APIService.class).getTeacherUserInfo(), new BaseObserver<TeacherUserInfo>(getView()) {
            @Override
            protected void onSuccess(TeacherUserInfo data) {
                if (getView() != null) {
                    getView().getTeacherInfoSuccess(data);
                }
            }
        });
    }
}
