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

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

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

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

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

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

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

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

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

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

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

130 131 132
    /**
     * 获取输入框的hint内容
     */
徐健 committed
133 134
    fun getChatViewConfig(): Observable<BaseAPIResponse<SystemInfoBean>> {
        return YDLHttpUtils.obtainApi(ServiceApi::class.java).getChatViewConfig()
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 160
    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)
    }

    /**
161
     * 回答问题
162 163 164 165 166 167 168
     */
    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)
169 170
    }

171 172 173 174 175 176 177 178 179 180 181
    /**
     * 去聊天 回答问题
     */
    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)
    }

182 183 184 185 186 187 188 189 190 191 192
    /**
     * 去聊天批量发送 回答问题
     */
    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)
    }

193 194 195 196 197 198 199 200 201 202 203
    /**
     * 获取首问语
     */
    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)
    }

范玉宾 committed
204 205 206 207 208 209 210
    /**
     * 是否显示立即咨询
     */
    fun canViewConsult(doctorId: String):Observable<BaseAPIResponse<CanViewConsult>>{
        return YDLHttpUtils.obtainApi(ServiceApi::class.java).canViewConsult(doctorId)
    }

konghaorui committed
211
}