package cn.flightfeather.thirdapp.repository
|
|
import cn.flightfeather.thirdapp.common.net.ResultCallBack
|
import cn.flightfeather.thirdapp.common.net.ResultObserver
|
import cn.flightfeather.thirdapp.common.net.RetrofitFactory
|
import cn.flightfeather.thirdapp.httpservice.NightWorkService
|
import cn.flightfeather.thirdapp.model.bean.BaseResponse
|
import cn.flightfeather.thirdapp.model.bean.NightWorkFileVo
|
import cn.flightfeather.thirdapp.model.bean.NightWorkSummary
|
|
/**
|
* @author riku
|
* Date: 2020/12/29
|
*/
|
class NightWorkRepository {
|
val retrofit = RetrofitFactory.instance.retrofit
|
|
fun getRecord(districtCode: String, page: Int, resultCallBack: ResultCallBack<List<NightWorkFileVo>>) {
|
val service = retrofit.create(NightWorkService::class.java).getRecord(districtCode, page)
|
|
RetrofitFactory.executeResult(service, object : ResultObserver<BaseResponse<List<NightWorkFileVo>>>() {
|
override fun onSuccess(result: BaseResponse<List<NightWorkFileVo>>?) {
|
resultCallBack.onSuccess(result?.data)
|
}
|
|
override fun onPage(current: Int, total: Int) {
|
super.onPage(current, total)
|
resultCallBack.onPage(current, total)
|
}
|
|
override fun onFailure(e: Throwable, isNetWorkError: Boolean) {
|
resultCallBack.onFailure()
|
}
|
})
|
}
|
|
fun getNightWorkFile(userId: String, isRead: Boolean? = null, page: Int, resultCallBack: ResultCallBack<List<NightWorkFileVo>>) {
|
val service = retrofit.create(NightWorkService::class.java).getNightWorkFile(userId, isRead, page)
|
|
RetrofitFactory.executeResult(service, object : ResultObserver<BaseResponse<List<NightWorkFileVo>>>() {
|
override fun onSuccess(result: BaseResponse<List<NightWorkFileVo>>?) {
|
resultCallBack.onSuccess(result?.data)
|
}
|
|
override fun onPage(current: Int, total: Int) {
|
super.onPage(current, total)
|
resultCallBack.onPage(current, total)
|
}
|
|
override fun onFailure(e: Throwable, isNetWorkError: Boolean) {
|
resultCallBack.onFailure()
|
}
|
})
|
}
|
|
fun signFile(userId: String, fileNum: String, id: Int, resultCallBack: ResultCallBack<Int>) {
|
val service = retrofit.create(NightWorkService::class.java).signFile(userId, fileNum, id)
|
|
RetrofitFactory.executeResult(service, object : ResultObserver<BaseResponse<Int>>() {
|
override fun onSuccess(result: BaseResponse<Int>?) {
|
resultCallBack.onSuccess(result?.data)
|
}
|
|
override fun onFailure(e: Throwable, isNetWorkError: Boolean) {
|
resultCallBack.onFailure()
|
}
|
})
|
}
|
|
fun getSummary(districtCode: String, resultCallBack: ResultCallBack<NightWorkSummary>) {
|
val service = retrofit.create(NightWorkService::class.java).getSummary(districtCode)
|
|
RetrofitFactory.executeResult(service, object : ResultObserver<BaseResponse<NightWorkSummary>>() {
|
override fun onSuccess(result: BaseResponse<NightWorkSummary>?) {
|
resultCallBack.onSuccess(result?.data)
|
}
|
|
override fun onFailure(e: Throwable, isNetWorkError: Boolean) {
|
resultCallBack.onFailure()
|
}
|
})
|
|
}
|
}
|