ServiceImpl.kt 3.8 KB
Newer Older
konghaorui committed
1 2
package com.yidianling.uikit.custom.http

徐健 committed
3
import com.alibaba.fastjson.JSON
konghaorui committed
4 5
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlnet.YDLHttpUtils
6
import com.yidianling.uikit.custom.http.response.*
konghaorui committed
7
import io.reactivex.Observable
严久程 committed
8 9
import okhttp3.MediaType
import okhttp3.RequestBody
konghaorui committed
10 11 12 13

/**
 * Created by xj on 2019/6/26.
 */
徐健 committed
14
class ServiceImpl private constructor() {
konghaorui committed
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

    companion object {
        val instance by lazy { ServiceImpl() }
    }

    /**
     * 获取专家登录状态
     */
    fun getDoctorChatStatus(doctorUid: Long): Observable<BaseAPIResponse<ChatStatusBean>> {
        return YDLHttpUtils.obtainApi(ServiceApi::class.java).getDoctorChatStatus(doctorUid)
    }

    /**
     * 获取助理登录状态
     */
    fun getAssistantChatStatus(assistantUid: Long): Observable<BaseAPIResponse<Int>> {
        return YDLHttpUtils.obtainApi(ServiceApi::class.java).getAssistantChatStatus(assistantUid)
    }

    /**
     * 获取推荐专家列表
     */
徐健 committed
37 38 39 40 41 42 43
    fun getRecommendExpertList(
        doctorUid: Long,
        catName: String,
        limit: Int
    ): Observable<BaseAPIResponse<ArrayList<RecommendExpertBean>>> {
        return YDLHttpUtils.obtainApi(ServiceApi::class.java)
            .getRecommendExpertList(doctorUid, catName, limit)
konghaorui committed
44
    }
严久程 committed
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66

    /**
     * 获取常用语
     */
    fun getCommonQuestionList(): Observable<BaseAPIResponse<List<CommonQuestionBean>>> {
        return YDLHttpUtils.obtainApi(ServiceApi::class.java).getCommonQuestionList()
    }

    /**
     * 常用语的点击
     */
    fun sendCommonQuestionCount(id: String): Observable<BaseAPIResponse<Any>> {
        return YDLHttpUtils.obtainApi(ServiceApi::class.java).sendCommonQuestionCount(id)
    }

    /**
     * 信息采集的问题
     */
    fun userCollectList(): Observable<BaseAPIResponse<List<UserQuestInfoBean>>> {
        return YDLHttpUtils.obtainApi(ServiceApi::class.java).userCollectList()
    }

67 68 69
    /**
     * 获取新用户收集的信息
     */
徐健 committed
70 71 72 73 74 75 76
    fun getNewUserMes(bean: NewUserMesBean): Observable<BaseAPIResponse<List<UserQuestInfoBean>>> {
        val beanStr = JSON.toJSONString(bean)
        val body = RequestBody.create(
            MediaType.parse("application/json; charset=utf-8"),
            beanStr
        ) as RequestBody
        return YDLHttpUtils.obtainApi(ServiceApi::class.java).getNewUserMes(body)
徐健 committed
77 78 79 80 81 82 83
    }

    /**
     * 获取用户来源
     */
    fun getUserSourceFrom(uid: String): Observable<BaseAPIResponse<String>> {
        return YDLHttpUtils.obtainApi(ServiceApi::class.java).getUserSource(uid)
84 85
    }

严久程 committed
86 87 88 89
    /**
     * 上传采集的问题
     */
    fun submitUserCollect(params: String): Observable<BaseAPIResponse<Any>> {
徐健 committed
90 91 92 93
        val body = RequestBody.create(
            MediaType.parse("application/json; charset=utf-8"),
            params
        ) as RequestBody
严久程 committed
94 95
        return YDLHttpUtils.obtainApi(ServiceApi::class.java).submitUserCollect(body)
    }
96 97 98 99

    /**
     * 关注用户
     */
100 101
    fun focus(doctorId: String, status: String): Observable<BaseAPIResponse<Any>> {
        return YDLHttpUtils.obtainApi(ServiceApi::class.java).focus(doctorId, status)
102
    }
徐健 committed
103 104 105 106 107 108 109

    /**
     * 服务列表
     */
    fun serviceList(doctorId: String): Observable<BaseAPIResponse<List<ServiceItemBean>>> {
        return YDLHttpUtils.obtainApi(ServiceApi::class.java).serviceList(doctorId)
    }
徐健 committed
110

111 112 113
    /**
     * 获取输入框的hint内容
     */
徐健 committed
114 115
    fun getChatViewConfig(): Observable<BaseAPIResponse<SystemInfoBean>> {
        return YDLHttpUtils.obtainApi(ServiceApi::class.java).getChatViewConfig()
116
    }
117 118 119 120 121


    /**
     * 获取代运营关联的专家的信息
     */
122 123
    fun getSourceDoctor(userUid: String, assistantUid: String): Observable<BaseAPIResponse<SourceDoctorInfoBean>> {
        return YDLHttpUtils.obtainApi(ServiceApi::class.java).getSourceDoctor(1, userUid, assistantUid)
124 125
    }

konghaorui committed
126
}