package com.sinata.xqmuse.network
|
|
import cn.sinata.xldutils.data.ResultData
|
import com.google.gson.Gson
|
import com.google.gson.JsonObject
|
import com.sinata.xqmuse.network.entity.*
|
import com.sinata.xqmuse.network.entity.req.*
|
import com.sinata.xqmuse.ui.mine.WatchHisActivity
|
import com.sinata.xqmuse.utils.Const
|
import com.sinata.xqmuse.utils.pay.PayInfo
|
import io.reactivex.Flowable
|
import retrofit2.http.Field
|
|
object HttpManager {
|
|
/**
|
* 发起请求方法
|
*/
|
private fun request() =
|
RRetrofit.instance().create(ApiService::class.java)
|
|
/**
|
* 获取h5
|
* @param type 1=用户协议,2=隐私协议 3=关于心泉 4=新手冥想指南 5=课程/冥想音频购买协议
|
*/
|
fun getH5(type: Int): Flowable<ResultData<H5Bean>> {
|
return request().getH5(type)
|
}
|
|
/**
|
* 支付
|
*/
|
fun pay(
|
id: String,
|
payType: Int,
|
buyType: Int
|
): Flowable<ResultData<PayInfo>> {
|
return request().pay(id,payType, buyType)
|
}
|
|
/**
|
* 支付结果
|
*/
|
fun success(
|
id: String
|
): Flowable<ResultData<Coupon>> {
|
return request().success(id)
|
}
|
|
/**
|
* 体检报告
|
*/
|
fun queryPhysical(id: String): Flowable<ResultData<Report>> {
|
return request().queryPhysical(id)
|
}
|
|
|
/**
|
* 打卡
|
*/
|
fun clockIn(courseId: String): Flowable<ResultData<FinishBean>> {
|
return request().clockIn(courseId)
|
}
|
|
/**
|
* 课程列表
|
*/
|
fun queryCourseList(
|
page: Int,
|
type: String? = null,
|
search: String? = null
|
): Flowable<ResultData<CourseListBean>> {
|
return request().queryCourseList(page,type,search)
|
}
|
|
/**
|
* 导师
|
*/
|
fun getCoursePageList(): Flowable<ResultData<TeacherBean>> {
|
return request().getCoursePageList()
|
}
|
|
/**
|
* 课程详情
|
*/
|
fun getPayCourseInfoById(id: String): Flowable<ResultData<CourseDetail>> {
|
return request().getPayCourseInfoById(id)
|
}
|
|
|
/**
|
* 课程收藏
|
*/
|
fun collectCourse(id: String): Flowable<ResultData<Any>> {
|
return request().collectCourse(id)
|
}
|
|
|
/**
|
* 我的动态
|
*/
|
fun myFind(page: Int): Flowable<ResultData<ArrayList<Dynamic>>> {
|
return request().myFind(page)
|
}
|
|
/**
|
* 推广信息
|
*/
|
fun shareInfo(): Flowable<ResultData<ShareInfo>> {
|
return request().shareInfo()
|
}
|
|
/**
|
* 我的课程列表
|
*/
|
fun lookHistory(type: Int,page: Int,state:Int): Flowable<ResultData<List<CourseBean>>> {
|
val url = if (type == WatchHisActivity.WATCH_HIS) Apis.lookHistory else if (type == WatchHisActivity.COLLECTED) Apis.myCollect else Apis.myOrderCourse
|
val id = if (type == WatchHisActivity.WATCH_HIS) "361bdf123992fb" else if (type == WatchHisActivity.COLLECTED) "365e099bb9988b" else "365f4fc1b99030"
|
return request().lookHistory(url,page,10,state,id)
|
}
|
|
fun getVipPrice(): Flowable<ResultData<VipPriceBean>> {
|
return request().getVipPrice()
|
}
|
|
|
/**
|
* @param type 1=会员权益介绍 2=会员用户协议 3=续费管理说明
|
*/
|
fun getVipContent(type: Int): Flowable<ResultData<String>> {
|
return request().getVipContent(type)
|
}
|
|
fun getQrCode(): Flowable<ResultData<String>> {
|
return request().getQrCode()
|
}
|
|
fun commonQuestion(page: Int): Flowable<ResultData<QABean>> {
|
return request().commonQuestion(page,10)
|
}
|
|
fun healingLevel(): Flowable<ResultData<LevelBean>> {
|
return request().healingLevel()
|
}
|
|
fun queryNotice(): Flowable<ResultData<Boolean>> {
|
return request().queryNotice()
|
}
|
|
fun balanceList(page: Int,state: Int): Flowable<ResultData<WalletDetailBean>> {
|
return request().balanceList(page,state,Const.PAGE_SIZE)
|
}
|
|
fun energyDetail(page: Int,state: Int): Flowable<ResultData<List<PowerDetail>>> {
|
return request().energyDetail(page,state,Const.PAGE_SIZE)
|
}
|
|
fun goodsList(page: Int): Flowable<ResultData<List<Gift>>> {
|
return request().goodsList(page,Const.PAGE_SIZE)
|
}
|
|
fun exchangeRecordList(page: Int): Flowable<ResultData<List<Gift>>> {
|
return request().exchangeRecordList(page,Const.PAGE_SIZE)
|
}
|
|
fun restart(): Flowable<ResultData<Any>> {
|
return request().restart()
|
}
|
|
fun getTotalEnergyValue(): Flowable<ResultData<Int>> {
|
return request().getTotalEnergyValue()
|
}
|
|
fun exchange(id: String): Flowable<ResultData<String>> {
|
return request().exchange(id)
|
}
|
|
fun balanceDetail(id: String): Flowable<ResultData<BalanceDetail>> {
|
return request().balanceDetail(id)
|
}
|
|
fun bankList(): Flowable<ResultData<List<BankInfo>>> {
|
return request().bankList()
|
}
|
|
fun addBank(bank: String,name: String,phone: String,idCard:String,num: String): Flowable<ResultData<Any>> {
|
return request().addBank(Gson().toJson(BankInfo(bank,num,name,phone,idCard)))
|
}
|
|
fun deleteBank(id: String): Flowable<ResultData<Any>> {
|
return request().deleteBank(id)
|
}
|
|
fun withdraw(id: String,money: Double): Flowable<ResultData<Any>> {
|
return request().withdraw(id,money)
|
}
|
|
fun noticeDetail(id: String): Flowable<ResultData<MsgDetail>> {
|
return request().noticeDetail(id)
|
}
|
|
fun changePhone(code: String,phone: String): Flowable<ResultData<Any>> {
|
return request().changePhone(code, phone)
|
}
|
|
fun deleteUser(): Flowable<ResultData<Any>> {
|
return request().deleteUser()
|
}
|
|
fun studyPage(): Flowable<ResultData<StudyBean>> {
|
return request().studyPage()
|
}
|
|
fun detailVersion(): Flowable<ResultData<Version>> {
|
return request().detailVersion()
|
}
|
|
/**
|
* 提现
|
*/
|
fun withdrawal(money: Double): Flowable<ResultData<Any>> {
|
return request().withdrawal(money)
|
}
|
|
fun bindVx(openid: String,wxName:String): Flowable<ResultData<Any>> {
|
return request().bindVx(openid,wxName)
|
}
|
|
/**
|
* 提现记录
|
*/
|
fun withdrawalRecord(page: Int,year: Int?,month: Int?): Flowable<ResultData<List<Detail>>> {
|
return request().withdrawalRecord(page,month, year)
|
}
|
|
/**
|
* 获取验证码
|
*/
|
fun getCode(phone: String, type: Int): Flowable<ResultData<Any>> {
|
return request().getCode(phone, type)
|
}
|
|
/**
|
* 验证验证码
|
*/
|
fun verifyPhone(phone: String, code: String): Flowable<ResultData<VerifyBean>> {
|
return request().verifyPhone("{\"captcha\":\"${code}\",\"cellPhone\":\"${phone}\"}")
|
}
|
|
/**
|
* 保存个性设置
|
*/
|
fun saveUserAnswers(answer: ReqAnswer): Flowable<ResultData<Any>> {
|
return request().saveUserAnswers(Gson().toJson(answer))
|
}
|
|
/**
|
* 引导音乐
|
*/
|
fun getPlan(): Flowable<ResultData<String>> {
|
return request().getPlan()
|
}
|
|
/**
|
* 微信登录-绑定手机号
|
*/
|
fun verifyCellPhone(token:String,phone: String,code: String,openid: String): Flowable<ResultData<Any>> {
|
return request().verifyCellPhone(" $token",Gson().toJson(ReqBindWxPhone(code,phone,openid)))
|
}
|
|
/**
|
* 答案标签
|
*/
|
fun getTagList(): Flowable<ResultData<ArrayList<TagBean>>> {
|
return request().getTagList()
|
}
|
|
/**
|
* 忘記密碼
|
*/
|
fun forgetPassword(phone: String, pwd: String,secret:String): Flowable<ResultData<Any>> {
|
return request().forgetPassword("{\"cellPhone\":\"${phone}\",\"password\":\"${pwd}\",\"secret\":\"${secret}\"}")
|
}
|
|
/**
|
* 注册/忘记密码/修改密码
|
* @param type 2:注册,3:修改密码,4:忘记密码,5:绑手机
|
*/
|
fun register(type: Int, phone: String, pwd: String, code: String): Flowable<ResultData<LoginBean>> {
|
val url = when (type) {
|
4 -> Apis.forgetPassword
|
5 -> Apis.bindWx
|
else -> Apis.register
|
}
|
return request().register(url, Gson().toJson(ReqRegister(code,phone,pwd)))
|
}
|
|
/**
|
* 注册/忘记密码/修改密码
|
* @param type 2:注册,3:修改密码,4:忘记密码,5:绑手机
|
*/
|
fun bindPhone(phone: String, code: String, invitationCode: String?): Flowable<ResultData<String>> {
|
return request().bindPhone(phone, code,invitationCode)
|
}
|
|
/**
|
* 密码登录
|
*/
|
fun userLogin(password: String, phone: String): Flowable<ResultData<LoginBean>> {
|
return request().userLogin("{\"cellPhone\":\"${phone}\",\"password\":\"${password}\"}")
|
}
|
|
/**
|
* 修改密码
|
*/
|
fun updatePassword(password: String, newPassword: String, code: String): Flowable<ResultData<Any>> {
|
return request().updatePassword(password,newPassword, code)
|
}
|
|
/**
|
* 验证码登录
|
*/
|
fun captchaLogin(device: String, code: String, phone: String): Flowable<ResultData<LoginBean>> {
|
return request().captchaLogin("{\"device\":\"${device}\",\"cellPhone\":\"${phone}\",\"captcha\":\"${code}\"}")
|
}
|
|
/**
|
* wx登录
|
*/
|
fun wxLogin(device: String, openid: String?, name: String?,sex: Int?,avatar: String?): Flowable<ResultData<WxLoginBean>> {
|
return request().wxLogin(Gson().toJson(ReqWxLogin(device,avatar,name,sex,openid)))
|
}
|
|
/**
|
* 轮播
|
*/
|
fun queryBanner(): Flowable<ResultData<ArrayList<Banner>>> {
|
return request().queryBanner()
|
}
|
|
/**
|
* 轮播
|
*/
|
fun getCourseCategoryList(): Flowable<ResultData<ArrayList<CourseType>>> {
|
return request().getCourseCategoryList()
|
}
|
|
/**
|
* 菜单
|
*/
|
fun getCategoryListByType(type: Int): Flowable<ResultData<ArrayList<Menu>>> {
|
return request().getCategoryListByType(type)
|
}
|
|
/**
|
* 今日冥想
|
*/
|
fun getTodayMeditation(): Flowable<ResultData<HomeItem>> {
|
return request().getTodayMeditation()
|
}
|
|
/**
|
* 私人订制
|
*/
|
fun getPersonalityPlan(): Flowable<ResultData<List<CommonItemBean>>> {
|
return request().getPersonalityPlan()
|
}
|
|
/**
|
* 动态列表
|
*/
|
fun getMeditationAndCateList(): Flowable<ResultData<List<HomeListBean>>> {
|
return request().getMeditationAndCateList()
|
}
|
|
/**
|
* bgm
|
*/
|
fun getHomeBackgroun(): Flowable<ResultData<List<BGMBean>>> {
|
return request().getHomeBackgroun()
|
}
|
|
/**
|
* 分类列表
|
*/
|
fun getMeditationPageByCateId(typeId:String,page: Int): Flowable<ResultData<SearchResult>> {
|
return request().getMeditationPageByCateId(typeId,page,Const.PAGE_SIZE)
|
}
|
|
/**
|
* 音频详情
|
*/
|
fun getMeditationDetails(id: String): Flowable<ResultData<VoiceDetail>> {
|
return request().getMeditationDetails(id)
|
}
|
|
/**
|
* 音频收藏
|
*/
|
fun favorite(id: String): Flowable<ResultData<Any>> {
|
return request().favorite(id)
|
}
|
|
/**
|
* 评论列表
|
*/
|
fun getMeditationQuestionPage(id: String,page: Int): Flowable<ResultData<VoiceCommentBean>> {
|
return request().getMeditationQuestionPage(id,page,Const.PAGE_SIZE)
|
}
|
|
/**
|
* 搜索
|
*/
|
fun search(key:String,page: Int,size: Int): Flowable<ResultData<SearchResult>> {
|
return request().search(key,page,size)
|
}
|
|
/**
|
* 热搜列表
|
*/
|
fun getHotWordList(): Flowable<ResultData<List<String>>> {
|
return request().getHotWordList()
|
}
|
|
/**
|
* 获取String类型通用接口
|
*/
|
fun queryString(url: String, map: HashMap<String, Any>): Flowable<ResultData<String>> {
|
return request().queryString(url, map)
|
}
|
|
/**
|
* 券列表
|
*/
|
fun queryCouponPackage(type: Int,page: Int): Flowable<ResultData<List<Coupon>>> {
|
return request().queryCouponPackage(type, page)
|
}
|
|
/**
|
* 用户查询
|
*/
|
fun getUserByPhone(phone: String): Flowable<ResultData<UserInfo>> {
|
return request().getUserByPhone(phone)
|
}
|
|
/**
|
* 确认订单
|
*/
|
fun confirmOrder(id: String): Flowable<ResultData<ConfirmOrder>> {
|
return request().confirmOrder(id)
|
}
|
|
/**
|
* 待支付订单
|
*/
|
fun payOrder(id: String): Flowable<ResultData<ConfirmOrder>> {
|
return request().payOrder(id)
|
}
|
|
|
/**
|
* 取消订单
|
*/
|
fun cancel(id: String): Flowable<ResultData<Any>> {
|
return request().cancel(id)
|
}
|
|
/**
|
* 确认订单
|
*/
|
fun confirmOrderVoice(id: String): Flowable<ResultData<ConfirmOrder>> {
|
return request().confirmOrderVoice(id)
|
}
|
|
/**
|
* 余额支付订单
|
*/
|
fun gvieCourse(id: String,type: Int,receiveId:String? = null): Flowable<ResultData<Any>> {
|
return request().gvieCourse(id,type,receiveId)
|
}
|
|
fun saveViewingHistory(id: String,time: Int): Flowable<ResultData<Any>> {
|
return request().saveViewingHistory(time,id)
|
}
|
|
/**
|
* 支付成功
|
*/
|
fun successOrder(id: String,isVoice:Boolean): Flowable<ResultData<List<CourseBean>>> {
|
return request().successOrder(if (isVoice) Apis.successOrderVoice else Apis.successOrder, id,id)
|
}
|
|
/**
|
* 课程学习
|
*/
|
fun studyPageByChapterId(id: String): Flowable<ResultData<List<Chapter>>> {
|
return request().studyPageByChapterId(id)
|
}
|
|
/**
|
* 记录视频观看
|
*/
|
fun saveCourseStudyHistory(id: String,isOver:Int,secondLook:Int): Flowable<ResultData<Any>> {
|
return request().saveCourseStudyHistory(id,isOver,secondLook)
|
}
|
|
fun isFirst(): Flowable<ResultData<Boolean>> {
|
return request().isFirst()
|
}
|
|
fun getUserTree(): Flowable<ResultData<TreeInfo>> {
|
return request().getUserTree()
|
}
|
|
fun watering(): Flowable<ResultData<WaterResult>> {
|
return request().watering()
|
}
|
|
fun sign(): Flowable<ResultData<Any>> {
|
return request().sign()
|
}
|
|
/**
|
* 注销
|
*/
|
fun cancellation(): Flowable<ResultData<Any>> {
|
return request().cancellation()
|
}
|
|
|
/**
|
* 反馈
|
*/
|
fun feedBack(content: String,img: String?): Flowable<ResultData<Any>> {
|
return request().feedBack(content, img)
|
}
|
|
/**
|
* 常见问题
|
*/
|
fun useGuide(search: String?): Flowable<ResultData<List<Guide>>> {
|
return request().useGuide(search)
|
}
|
|
/**
|
* 消息列表
|
*/
|
fun messageList(page: Int): Flowable<ResultData<MsgListBean>> {
|
return request().messageList(page,Const.PAGE_SIZE)
|
}
|
|
/**
|
* 删除
|
*/
|
fun deleteFind(id: String): Flowable<ResultData<Any>> {
|
return request().deleteFind(id)
|
}
|
|
/**
|
* 疗愈馆
|
*/
|
fun getMeditationPage(page: Int,name: String?,lat:Double?,lon:Double?): Flowable<ResultData<PlaceListBean>> {
|
return request().getMeditationPage(name,lat,lon,page,10)
|
}
|
|
/**
|
* 疗愈馆
|
*/
|
fun getMeditationInfo(id: String): Flowable<ResultData<Place>> {
|
return request().getMeditationInfo(id)
|
}
|
|
/**
|
* 公告详情
|
*/
|
fun noticeDetail(id: String, type: Int): Flowable<ResultData<Notice>> {
|
return request().noticeDetail(
|
if (type == 1) Apis.noticeDetail else Apis.exceptionDetail,
|
id,
|
id
|
)
|
}
|
|
/**
|
* 更新用户信息
|
*/
|
fun updateInfo(birthday: String?, company: String?,education: String?,email: String?,gender: Int?,hometown: String?,industry: String?,
|
location: String?,nickname: String?,occupation: String?, signature: String?,name: String?): Flowable<ResultData<Any>> {
|
val req = ReqUpdateUser(birthday,company,education,email,gender,hometown,industry,location,nickname,occupation,name,signature)
|
return request().updateInfo(Gson().toJson(req))
|
}
|
|
/**
|
* 支付
|
*/
|
fun placeOrder(orderFrom:Int,payType:Int,balanceFlag:Int,amount:Double?,receiverId:String?,targetId:String?,vipType:Int?): Flowable<ResultData<PayInfo>> {
|
return request().placeOrder(orderFrom, payType, balanceFlag, amount, receiverId, targetId, vipType)
|
}
|
|
/**
|
* 更新用户头像
|
*/
|
fun updateUserAvatar(avatar: String): Flowable<ResultData<Any>> {
|
return request().updateUserAvatar(avatar)
|
}
|
|
/**
|
* 钱包
|
*/
|
fun wallet(): Flowable<ResultData<WalletBean>> {
|
return request().wallet()
|
}
|
|
/**
|
* 举报
|
*/
|
fun report(id: String,content: String): Flowable<ResultData<Any>> {
|
return request().report(id, content)
|
}
|
|
/**
|
* 提问
|
*/
|
fun addQuestion(id: String,content: String): Flowable<ResultData<Any>> {
|
return request().addQuestion(id, content)
|
}
|
|
/**
|
* 评论
|
* @param pid 如果是评论的动态 pid传0 否则传一级评论的id
|
* @param replyCommentId 回复的那条评论的评论id,不是回复评论就不传
|
* @param replyUserId 回复的那条评论的用户id,不是回复就不传
|
*/
|
fun addComment(findId:String,pid: String,content: String,replyCommentId:String?,replyUserId:String?): Flowable<ResultData<Any>> {
|
return request().addComment(findId, content, pid, replyCommentId, replyUserId)
|
}
|
|
/**
|
* 动态
|
*/
|
fun findDetail(id: String): Flowable<ResultData<Dynamic>> {
|
return request().findDetail(id)
|
}
|
|
/**
|
* 點贊
|
*/
|
fun doLike(id:String): Flowable<ResultData<Any>> {
|
return request().doLike(id)
|
}
|
|
/**
|
* 发布
|
*/
|
fun addFind(title: String,content: String,img: String?,cover:String?,video:String?): Flowable<ResultData<Any>> {
|
return request().addFind(title,content,img,cover,video)
|
}
|
|
/**
|
*用户信息
|
*/
|
fun getUserInfo(): Flowable<ResultData<MineInfo>> {
|
return request().getUserInfo()
|
}
|
|
/**
|
*资料
|
*/
|
fun getUserDetail(): Flowable<ResultData<UserInfo>> {
|
return request().getUserDetail()
|
}
|
}
|