| | |
| | | package cn.flightfeather.thirdapp.module.nightwork |
| | | |
| | | import android.arch.lifecycle.MutableLiveData |
| | | import cn.flightfeather.thirdapp.common.net.ResultCallBack |
| | | import cn.flightfeather.thirdapp.model.bean.NightWorkFileVo |
| | | import cn.flightfeather.thirdapp.model.bean.NightWorkSummary |
| | | import cn.flightfeather.thirdapp.module.base.BaseViewModel |
| | | import cn.flightfeather.thirdapp.repository.NightWorkRepository |
| | | import cn.flightfeather.thirdapp.view.recyclerview.DataLoadModel |
| | | |
| | | /** |
| | | * @author riku |
| | |
| | | */ |
| | | class NightWorkViewModel : BaseViewModel() { |
| | | |
| | | private val nightWorkRepository = NightWorkRepository() |
| | | |
| | | var summary = MutableLiveData<NightWorkSummary>() |
| | | |
| | | //获取最新未读文件 |
| | | val dataLoadModel1 = object : DataLoadModel<NightWorkFileVo>(application) { |
| | | override fun loadDataByRefresh() { |
| | | getNightWorkFile(false, 1, this) |
| | | } |
| | | |
| | | override fun loadDataByLoadMore(page: Int) { |
| | | getNightWorkFile(false, page, this) |
| | | } |
| | | } |
| | | |
| | | //获取历史已读文件 |
| | | val dataLoadModel2 = object : DataLoadModel<NightWorkFileVo>(application) { |
| | | override fun loadDataByRefresh() { |
| | | getNightWorkFile(true, 1, this) |
| | | } |
| | | |
| | | override fun loadDataByLoadMore(page: Int) { |
| | | getNightWorkFile(true, page, this) |
| | | } |
| | | } |
| | | |
| | | //获取全部文件 |
| | | val dataLoadModel3 = object : DataLoadModel<NightWorkFileVo>(application) { |
| | | override fun loadDataByRefresh() { |
| | | getRecord(application.currentUser.dguid, 1, this) |
| | | } |
| | | |
| | | override fun loadDataByLoadMore(page: Int) { |
| | | getRecord(application.currentUser.dguid, page, this) |
| | | } |
| | | } |
| | | |
| | | fun getNightWorkFile(isRead: Boolean, page: Int, callBack: ResultCallBack<List<NightWorkFileVo>>) { |
| | | nightWorkRepository.getNightWorkFile(userId, isRead, page, callBack) |
| | | } |
| | | |
| | | fun signFile(fileId: Int, fileNum: String, callBack: ResultCallBack<Int>) { |
| | | nightWorkRepository.signFile(userId, fileNum, fileId, callBack) |
| | | } |
| | | |
| | | fun getRecord(districtCode: String, page: Int, callBack: ResultCallBack<List<NightWorkFileVo>>) { |
| | | nightWorkRepository.getRecord(districtCode, page, callBack) |
| | | } |
| | | |
| | | fun getSummary() { |
| | | nightWorkRepository.getSummary(application.currentUser.dguid, object : ResultCallBack<NightWorkSummary> { |
| | | override fun onSuccess(result: NightWorkSummary?) { |
| | | result?.let { summary.value = it } |
| | | } |
| | | |
| | | override fun onFailure() { |
| | | // summary.value = NightWorkSummary() |
| | | } |
| | | }) |
| | | } |
| | | } |