riku
2022-02-18 d59d55575d913646b7a90fca651904ab889c6723
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
package cn.flightfeather.thirdappmodule.repository
 
import cn.flightfeather.thirdappmodule.bean.entity.Userinfo
import cn.flightfeather.thirdappmodule.common.net.ResponseBodyCallBack
import cn.flightfeather.thirdappmodule.common.net.ResultCallBack
import cn.flightfeather.thirdappmodule.common.net.RetrofitFactory
import cn.flightfeather.thirdappmodule.httpservice.UserInfoService
 
/**
 * @author riku
 * Date: 2021/7/21
 */
class UserInfoRepository private constructor(){
 
    companion object {
        @JvmStatic
        val instance: UserInfoRepository by lazy(LazyThreadSafetyMode.SYNCHRONIZED) { UserInfoRepository()}
    }
 
    private val retrofit = RetrofitFactory.instance.retrofit
 
    /**
     * 自动创建监管场景账户
     * @param sceneId 场景id
     */
    fun createAccount(sceneId: String, resultCallBack: ResultCallBack<Userinfo>) {
        retrofit.create(UserInfoService::class.java).createAccount(sceneId)
            .enqueue(ResponseBodyCallBack(resultCallBack))
    }
 
    /**
     * 获取场景对应的账户信息
     * @param sceneId 场景id
     */
    fun getByScene(sceneId: String, resultCallBack: ResultCallBack<Userinfo?>) {
        retrofit.create(UserInfoService::class.java).getByScene(sceneId)
            .enqueue(ResponseBodyCallBack(resultCallBack))
    }
 
    fun getUsersByType(userTypeId: Int, resultCallBack: ResultCallBack<List<Userinfo>>) {
        retrofit.create(UserInfoService::class.java).getUserByTypeId(userTypeId.toByte())
            .enqueue(ResponseBodyCallBack(resultCallBack))
    }
}