feat: 热点话题详情 API
This commit is contained in:
parent
cfdfe9597b
commit
49abaf8a2d
|
|
@ -20,6 +20,9 @@ object Error {
|
|||
}
|
||||
|
||||
object Header {
|
||||
const val NO_ST_PARAMS = "no_st_params"
|
||||
const val NO_ST_PARAMS_TRUE = "true"
|
||||
|
||||
const val FORCE_PARAM = "force_param"
|
||||
const val FORCE_PARAM_QUERY = "query"
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,161 @@
|
|||
package com.huanchengfly.tieba.post.api.models
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class TopicDetailBean(
|
||||
@SerialName("no")
|
||||
val errorCode: Int,
|
||||
@SerialName("error")
|
||||
val errorMsg: String,
|
||||
val data: TopicDetailDataBean,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class TopicDetailDataBean(
|
||||
@SerialName("topic_info")
|
||||
val topicInfo: TopicInfoBean,
|
||||
val user: UserBean,
|
||||
val tbs: String,
|
||||
val relateForum: List<RelateForumBean>,
|
||||
@SerialName("special_topic")
|
||||
val specialTopic: List<SpecialTopicBean>,
|
||||
@SerialName("relate_thread")
|
||||
val relateThread: RelateThreadBean,
|
||||
@SerialName("has_more")
|
||||
val hasMore: Boolean,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class RelateThreadBean(
|
||||
@SerialName("thread_list")
|
||||
val threadList: List<ThreadBean>,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class ThreadBean(
|
||||
@SerialName("feed_id")
|
||||
val feedId: Long,
|
||||
val source: Int,
|
||||
@SerialName("thread_info")
|
||||
val threadInfo: ThreadInfoBean,
|
||||
@SerialName("user_agree")
|
||||
val userAgree: Int,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class TopicInfoBean(
|
||||
@SerialName("topic_id")
|
||||
val topicId: String,
|
||||
@SerialName("topic_name")
|
||||
val topicName: String,
|
||||
val candle: String,
|
||||
@SerialName("topic_desc")
|
||||
val topicDesc: String,
|
||||
@SerialName("discuss_num")
|
||||
val discussNum: String,
|
||||
@SerialName("topic_image")
|
||||
val topicImage: String,
|
||||
@SerialName("share_title")
|
||||
val shareTitle: String,
|
||||
@SerialName("share_pic")
|
||||
val sharePic: String,
|
||||
@SerialName("is_video_topic")
|
||||
val isVideoTopic: Int,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class UserBean(
|
||||
@SerialName("is_login")
|
||||
val isLogin: Boolean,
|
||||
val id: Long,
|
||||
val uid: Long,
|
||||
val name: String,
|
||||
@SerialName("name_show")
|
||||
val nameShow: String,
|
||||
@SerialName("portrait")
|
||||
val portraitUrl: String,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class RelateForumBean(
|
||||
@SerialName("forum_id")
|
||||
val forumId: Long,
|
||||
@SerialName("forum_name")
|
||||
val forumName: String,
|
||||
val avatar: String,
|
||||
val desc: String,
|
||||
@SerialName("member_num")
|
||||
val memberNum: Long,
|
||||
@SerialName("thread_num")
|
||||
val threadNum: Long,
|
||||
@SerialName("post_num")
|
||||
val postNum: Long,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class SpecialTopicBean(
|
||||
val title: String,
|
||||
@SerialName("thread_list")
|
||||
val threadList: List<ThreadInfoBean>,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class ThreadInfoBean(
|
||||
val id: Long,
|
||||
@SerialName("feed_id")
|
||||
val feedId: Long,
|
||||
val title: String,
|
||||
@SerialName("tid")
|
||||
val threadId: Long,
|
||||
@SerialName("forum_id")
|
||||
val forumId: Long,
|
||||
@SerialName("forum_name")
|
||||
val forumName: String,
|
||||
@SerialName("create_time")
|
||||
val createTime: Long,
|
||||
@SerialName("last_time")
|
||||
val lastTime: String,
|
||||
@SerialName("last_time_int")
|
||||
val lastTimeInt: Long,
|
||||
@SerialName("abstract")
|
||||
val abstractText: String,
|
||||
val media: List<MediaBean>,
|
||||
@SerialName("media_num")
|
||||
val mediaNum: MediaNumBean,
|
||||
@SerialName("agree_num")
|
||||
val agreeNum: Long,
|
||||
@SerialName("reply_num")
|
||||
val replyNum: Long,
|
||||
@SerialName("share_num")
|
||||
val shareNum: Long,
|
||||
@SerialName("user_id")
|
||||
val userId: Long,
|
||||
@SerialName("first_post_id")
|
||||
val firstPostId: Long,
|
||||
@SerialName("user_agree")
|
||||
val userAgree: Int,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class MediaNumBean(
|
||||
val pic: Int,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class MediaBean(
|
||||
val type: String,
|
||||
val width: String,
|
||||
val height: String,
|
||||
@SerialName("small_pic")
|
||||
val smallPic: String,
|
||||
@SerialName("big_pic")
|
||||
val bigPic: String,
|
||||
@SerialName("water_pic")
|
||||
val waterPic: String,
|
||||
@SerialName("is_long_pic")
|
||||
val isLongPic: Int,
|
||||
@SerialName("bsize")
|
||||
val bSize: String,
|
||||
)
|
||||
|
|
@ -145,7 +145,11 @@ object RetrofitTiebaApi {
|
|||
)
|
||||
}
|
||||
),
|
||||
AddWebCookieInterceptor
|
||||
AddWebCookieInterceptor,
|
||||
CommonParamInterceptor(
|
||||
Param.BDUSS to { AccountUtil.getBduss() },
|
||||
Param.STOKEN to { AccountUtil.getSToken() },
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,17 @@ class StParamInterceptor(private val method: Boolean = false) : Interceptor {
|
|||
var httpUrl = request.url
|
||||
var body = request.body
|
||||
|
||||
var addStParam = true
|
||||
val noStParams = headers[Header.NO_ST_PARAMS]
|
||||
if (noStParams != null) {
|
||||
headers = headers.newBuilder().removeAll(Header.NO_ST_PARAMS).build()
|
||||
addStParam = noStParams != Header.NO_ST_PARAMS_TRUE
|
||||
}
|
||||
|
||||
if (!addStParam) {
|
||||
return chain.proceed(request.newBuilder().headers(headers).build())
|
||||
}
|
||||
|
||||
//是否强制加到 Query(暂不存在强制加到 FormBody 的情况)
|
||||
var forceQuery = false
|
||||
val forceParam = headers[Header.FORCE_PARAM]
|
||||
|
|
|
|||
|
|
@ -1,21 +1,33 @@
|
|||
package com.huanchengfly.tieba.post.api.retrofit.interfaces
|
||||
|
||||
import com.huanchengfly.tieba.post.api.Param
|
||||
import com.huanchengfly.tieba.post.api.models.SearchForumBean
|
||||
import com.huanchengfly.tieba.post.api.models.SearchThreadBean
|
||||
import com.huanchengfly.tieba.post.api.models.SearchUserBean
|
||||
import com.huanchengfly.tieba.post.api.models.TopicDetailBean
|
||||
import com.huanchengfly.tieba.post.api.urlEncode
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Header
|
||||
import retrofit2.http.Headers
|
||||
import retrofit2.http.Query
|
||||
import com.huanchengfly.tieba.post.api.Header as TiebaHeaders
|
||||
|
||||
interface AppHybridTiebaApi {
|
||||
@Headers(
|
||||
"${TiebaHeaders.NO_ST_PARAMS}: ${TiebaHeaders.NO_ST_PARAMS_TRUE}",
|
||||
"${TiebaHeaders.NO_COMMON_PARAMS}: ${Param.BDUSS},${Param.STOKEN}",
|
||||
)
|
||||
@GET("/mo/q/search/forum")
|
||||
fun searchForumFlow(
|
||||
@Query("word") keyword: String,
|
||||
@Header("Referer") referer: String = "https://tieba.baidu.com/mo/q/hybrid/search?keyword=$keyword&_webview_time=${System.currentTimeMillis()}".urlEncode(),
|
||||
): Flow<SearchForumBean>
|
||||
|
||||
@Headers(
|
||||
"${TiebaHeaders.NO_ST_PARAMS}: ${TiebaHeaders.NO_ST_PARAMS_TRUE}",
|
||||
"${TiebaHeaders.NO_COMMON_PARAMS}: ${Param.BDUSS},${Param.STOKEN}",
|
||||
)
|
||||
@GET("/mo/q/search/thread")
|
||||
fun searchThreadFlow(
|
||||
@Query("word") keyword: String,
|
||||
|
|
@ -27,9 +39,25 @@ interface AppHybridTiebaApi {
|
|||
@Header("Referer") referer: String = "https://tieba.baidu.com/mo/q/hybrid/search?keyword=$keyword&_webview_time=${System.currentTimeMillis()}".urlEncode(),
|
||||
): Flow<SearchThreadBean>
|
||||
|
||||
@Headers(
|
||||
"${TiebaHeaders.NO_ST_PARAMS}: ${TiebaHeaders.NO_ST_PARAMS_TRUE}",
|
||||
"${TiebaHeaders.NO_COMMON_PARAMS}: ${Param.BDUSS},${Param.STOKEN}",
|
||||
)
|
||||
@GET("/mo/q/search/user")
|
||||
fun searchUserFlow(
|
||||
@Query("word") keyword: String,
|
||||
@Header("Referer") referer: String = "https://tieba.baidu.com/mo/q/hybrid/search?keyword=$keyword&_webview_time=${System.currentTimeMillis()}".urlEncode(),
|
||||
): Flow<SearchUserBean>
|
||||
|
||||
@GET("/mo/q/newtopic/topicDetail")
|
||||
fun topicDetailFlow(
|
||||
@Query("topic_id") topicId: String,
|
||||
@Query("topic_name") topicName: String,
|
||||
@Query("is_new") isNew: Int = 0,
|
||||
@Query("is_share") isShare: Int = 1,
|
||||
@Query("pn") page: Int,
|
||||
@Query("rn") pageSize: Int = 10,
|
||||
@Query("offset") offset: Int = 0,
|
||||
@Query("derivative_to_pic_id") derivativeToPicId: String = "",
|
||||
): Flow<TopicDetailBean>
|
||||
}
|
||||
Loading…
Reference in New Issue