ServiceImpl.kt 6.29 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.im.bean.BusyBean
7
import com.yidianling.im.bean.FirstQuestionBean
8
import com.yidianling.im.http.ImRetrofitApi
9
import com.yidianling.uikit.custom.http.response.*
10
import com.yidianling.uikit.custom.http.response.question.QuestionsInfoBean
konghaorui committed
11
import io.reactivex.Observable
严久程 committed
12 13
import okhttp3.MediaType
import okhttp3.RequestBody
konghaorui committed
14 15 16 17

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

    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
41 42 43 44 45 46 47
    fun getRecommendExpertList(
        doctorUid: Long,
        catName: String,
        limit: Int
    ): Observable<BaseAPIResponse<ArrayList<RecommendExpertBean>>> {
        return YDLHttpUtils.obtainApi(ServiceApi::class.java)
            .getRecommendExpertList(doctorUid, catName, limit)
konghaorui committed
48
    }
严久程 committed
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70

    /**
     * 获取常用语
     */
    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()
    }

71 72 73 74 75 76 77
    /**
     * 信息采集的问题新版
     */
    fun preExamQuestionPaper(): Observable<BaseAPIResponse<QuestionsInfoBean>> {
        return YDLHttpUtils.obtainApi(ServiceApi::class.java).preExamQuestionPaper()
    }

78 79 80
    /**
     * 获取新用户收集的信息
     */
徐健 committed
81 82 83 84 85 86 87
    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
88 89 90 91 92 93 94
    }

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

严久程 committed
97 98 99 100
    /**
     * 上传采集的问题
     */
    fun submitUserCollect(params: String): Observable<BaseAPIResponse<Any>> {
徐健 committed
101 102 103 104
        val body = RequestBody.create(
            MediaType.parse("application/json; charset=utf-8"),
            params
        ) as RequestBody
严久程 committed
105 106
        return YDLHttpUtils.obtainApi(ServiceApi::class.java).submitUserCollect(body)
    }
107 108 109 110

    /**
     * 关注用户
     */
111 112
    fun focus(doctorId: String, status: String): Observable<BaseAPIResponse<Any>> {
        return YDLHttpUtils.obtainApi(ServiceApi::class.java).focus(doctorId, status)
113
    }
徐健 committed
114 115 116 117 118 119 120

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

122 123 124
    /**
     * 查询咨询师是否在繁忙状态
     */
125
    fun queryDoctorIsBusy(doctorId: String): Observable<BaseAPIResponse<BusyBean>>{
126 127 128
        return YDLHttpUtils.obtainApi(ServiceApi::class.java).queryDoctorIsBusy(doctorId)
    }

129 130 131
    /**
     * 获取输入框的hint内容
     */
徐健 committed
132 133
    fun getChatViewConfig(): Observable<BaseAPIResponse<SystemInfoBean>> {
        return YDLHttpUtils.obtainApi(ServiceApi::class.java).getChatViewConfig()
134
    }
135 136 137


    /**
138
     * 客户端灵犀信息收集卡题库
139
     */
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
    fun getSourceDoctor(
        userUid: String,
        assistantUid: String
    ): Observable<BaseAPIResponse<SourceDoctorInfoBean>> {
        return YDLHttpUtils.obtainApi(ServiceApi::class.java)
            .getSourceDoctor(1, userUid, assistantUid)
    }

    /**
     * 创建答题信息
     */
    fun createEexams(params: String): Observable<BaseAPIResponse<String>> {
        val body = RequestBody.create(
            MediaType.parse("application/json; charset=utf-8"),
            params
        ) as RequestBody
        return YDLHttpUtils.obtainApi(ServiceApi::class.java).createEexams(body)
    }

    /**
160
     * 回答问题
161 162 163 164 165 166 167
     */
    fun answerQuestion(id: String, params: String): Observable<BaseAPIResponse<String>> {
        val body = RequestBody.create(
            MediaType.parse("application/json; charset=utf-8"),
            params
        ) as RequestBody
        return YDLHttpUtils.obtainApi(ServiceApi::class.java).answerQuestion(id, body)
168 169
    }

170 171 172 173 174 175 176 177 178 179 180
    /**
     * 去聊天 回答问题
     */
    fun lingxiAnswerQuestion(params: String): Observable<BaseAPIResponse<Any>> {
        val body = RequestBody.create(
            MediaType.parse("application/json; charset=utf-8"),
            params
        ) as RequestBody
        return YDLHttpUtils.obtainApi(ImRetrofitApi::class.java).lingxiAnswerQuestion(body)
    }

181 182 183 184 185 186 187 188 189 190 191
    /**
     * 去聊天批量发送 回答问题
     */
    fun batchSendCustomizeMessage(params: String): Observable<BaseAPIResponse<Any>> {
        val body = RequestBody.create(
            MediaType.parse("application/json; charset=utf-8"),
            params
        ) as RequestBody
        return YDLHttpUtils.obtainApi(ImRetrofitApi::class.java).batchSendCustomizeMessage(body)
    }

192 193 194 195 196 197 198 199 200 201 202
    /**
     * 获取首问语
     */
    fun getFirstQuestion(): Observable<BaseAPIResponse<FirstQuestionBean>> {
        val filterMap = HashMap<String,Any>()
        filterMap["type"] = 1
        val map = HashMap<String,Any>()
        map["filter"] = filterMap
        return YDLHttpUtils.obtainApi(ServiceApi::class.java).getFirstQuestion(map)
    }

konghaorui committed
203
}