package com.casic.dcms.mvp.presenter;

import com.casic.dcms.bean.ActionResultBean;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.ShopCaseSubmitModelImpl;
import com.casic.dcms.mvp.view.ICaseSubmitCaseView;

/**
 * @Author: Pengxh
 * @Time: 2021/4/12 13:29
 * @Email: 290677893@qq.com
 **/
public class ShopCaseSubmitPresenterImpl extends BasePresenter implements IShopCaseSubmitPresenter, ShopCaseSubmitModelImpl.OnShopSubmitListener {

    private ICaseSubmitCaseView view;
    private ShopCaseSubmitModelImpl actionModel;

    public ShopCaseSubmitPresenterImpl(ICaseSubmitCaseView caseTypeView) {
        this.view = caseTypeView;
        actionModel = new ShopCaseSubmitModelImpl(this);
    }

    @Override
    public void onReadyRetrofitRequest(String isNeedVerify, String isNeedRevisit, String longitude, String latitude,
                                       String source, String caseLevel, String areaCode, String streetCode,
                                       String communityCode, String gridId, String description, String fieldintro,
                                       String fileIdVerify, int bzhours, int bzminis, String shopId,
                                       String shopkeeperName, String shopPhone) {
        view.showProgress();
        addSubscription(actionModel.sendRetrofitRequest(isNeedVerify, isNeedRevisit, longitude, latitude,
                source, caseLevel, areaCode, streetCode, communityCode, gridId, description, fieldintro, fileIdVerify,
                bzhours, bzminis, shopId, shopkeeperName, shopPhone));
    }

    @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();
    }
}
