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

import com.casic.dcms.bean.ActionResultBean;
import com.casic.dcms.listener.OnActionResultListener;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.impl.CaseSubmitModelImpl;
import com.casic.dcms.mvp.presenter.ICaseSubmitPresenter;
import com.casic.dcms.mvp.view.ICaseSubmitView;

/**
 * @Author: Pengxh
 * @Time: 2021/4/12 13:29
 * @Email: 290677893@qq.com
 **/
public class CaseSubmitPresenterImpl extends BasePresenter implements ICaseSubmitPresenter, OnActionResultListener {

    private final ICaseSubmitView view;
    private final CaseSubmitModelImpl actionModel;

    public CaseSubmitPresenterImpl(ICaseSubmitView submitCaseView) {
        this.view = submitCaseView;
        actionModel = new CaseSubmitModelImpl(this);
    }

    @Override
    public void onReadyRetrofitRequest(String isNeedVerify, String isNeedRevisit, String longitude,
                                       String latitude, String source, String caseLevel, String eorc,
                                       String casetypeCode, String casetypeDetailCode, String areaCode,
                                       String streetCode, String communityCode, String gridId,
                                       String description, String fieldintro, String fileIdVerify,
                                       String audioIdVerify, String videoIdVerify, int bzhours, int bzminis) {
        view.showProgress();
        addSubscription(actionModel.sendCaseSubmitRequest(isNeedVerify, isNeedRevisit, longitude, latitude,
                source, caseLevel, eorc, casetypeCode, casetypeDetailCode, areaCode, streetCode, communityCode,
                gridId, description, fieldintro, fileIdVerify, audioIdVerify, videoIdVerify, bzhours, bzminis));
    }

    @Override
    public void onSuccess(ActionResultBean resultBean) {
        view.hideProgress();
        view.obtainSubmitResult(resultBean);
    }

    @Override
    public void onFailure(Throwable throwable) {
        view.hideProgress();
        view.obtainDataFail();
    }

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