package com.police.policedatasystem.apply.viewmodel;

import androidx.annotation.NonNull;

import com.police.policedatasystem.apply.activity.QueryApplyResultActivity;
import com.police.policedatasystem.http.CustomCallBack;
import com.police.policedatasystem.http.RequestClient;
import com.police.policedatasystem.mine.model.Apply;
import com.police.policedatasystem.util.UiUtils;

import java.util.HashMap;
import java.util.List;

import okhttp3.Call;

public class ApplyResultViewModel {
    public QueryApplyResultActivity activity;

    public ApplyResultViewModel(QueryApplyResultActivity activity) {
        this.activity = activity;
    }

    public void getApplyList(String fnbh) {
        activity.loadingShow();
        HashMap<String, String> map = new HashMap<>();
        map.put("jqbh", fnbh);
//        map.put("sfhm", "220283197910023151");
        RequestClient.instance().getApplyList(map, new CustomCallBack<List<Apply>>() {
            @Override
            public void onError(@NonNull Call call, @NonNull Exception e) {
                UiUtils.toast(e.getMessage());
                activity.loadingNone();
            }

            @Override
            public void onSuccess(List<Apply> value) {
                activity.applyList(value);
                activity.loadingNone();
            }
        });
    }
}
