riku
2025-07-02 3013b813e5df6977c0be921928f73b1a3adde290
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package cn.flightfeather.thirdappmodule.repository
 
import cn.flightfeather.thirdappmodule.common.net.ResultCallBack
import cn.flightfeather.thirdappmodule.common.net.ResultObserver
import cn.flightfeather.thirdappmodule.common.net.RetrofitFactory
import cn.flightfeather.thirdappmodule.httpservice.NightWorkService
import cn.flightfeather.thirdappmodule.model.bean.BaseResponse
import cn.flightfeather.thirdappmodule.model.bean.NightWorkFileVo
import cn.flightfeather.thirdappmodule.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()
            }
        })
 
    }
}