riku
2025-10-27 0f58aa8ea118c3bd0b28396febc58fdbd94eef75
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
package cn.flightfeather.thirdappmodule.repository
 
import cn.flightfeather.thirdappmodule.bean.entity.Subtask
import cn.flightfeather.thirdappmodule.common.net.NetWorkProgressListener
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.SearchService
import cn.flightfeather.thirdappmodule.model.bean.BaseResponse
import cn.flightfeather.thirdappmodule.model.bean.ExcelConfigVo
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import okhttp3.ResponseBody
import retrofit2.Response
 
/**
 * @author riku
 * Date: 2020/6/15
 */
class SearchRepository {
 
    val retrofit = RetrofitFactory.instance.retrofit
 
    fun getExcel(excelConfigVo: ExcelConfigVo, resultCallBack: ResultCallBack<Response<ResponseBody>>, listener: NetWorkProgressListener? = null) {
        val service = RetrofitFactory.withProgressListeningRetrofit(listener).create(SearchService::class.java)
                .getExcel(excelConfigVo)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe({
                    resultCallBack.onSuccess(it)
                },{
                    resultCallBack.onFailure()
                })
    }
 
    fun searchSubtask(userId: String, keyword: String, page: Int, resultCallBack: ResultCallBack<List<Subtask>>) {
        val service = retrofit.create(SearchService::class.java).searchSubtask(userId, keyword, page)
 
        RetrofitFactory.executeResult(service, object : ResultObserver<BaseResponse<List<Subtask>>>() {
            override fun onSuccess(result: BaseResponse<List<Subtask>>?) {
                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()
            }
        })
    }
}