package com.bc_chat.bc_base.presenter

import com.bc_chat.bc_base.contract.RedPacketRecordContract
import com.bc_chat.bc_base.entity.wallet.RedPacketRecordEntity
import com.bc_chat.bc_base.task.RedPacketRecordTask
import com.zhaohaoting.framework.abs.presenter.BasePresenter
import com.zhaohaoting.framework.requset.NetWorkCallBack

/**
 * author：Created by zhaohaoting on 2019/3/8
 * email：526309416@qq.com
 * desc：
 */
class RedPacketRecrodPresenter<T>(view: RedPacketRecordContract.View) : BasePresenter<RedPacketRecordContract.View>(view), RedPacketRecordContract.Presenter {

    override fun myRedPacketLog(type: Int
                                , page_num: Int
                                , page_size: Int) {
        taskHelper.execute<Any>(RedPacketRecordTask(type, page_num, page_size), object : NetWorkCallBack<List<RedPacketRecordEntity>>() {
            override fun onPreExecute(task: Any?) {
                super.onPreExecute(task)
                view.showLoading(task)
            }

            override fun onPostExecuteFailure(task: Any?, exception: java.lang.Exception?) {
                super.onPostExecuteFailure(task, exception)
                view.dismissLoading(task)
                view.myRedPacketLogFailed(exception)
            }

            override fun onPostExecuteSuccess(task: Any?, data: List<RedPacketRecordEntity>?) {
                view.dismissLoading(task)
                view.myRedPacketLogSuccess(data)
            }
        })
    }

}
