Skip to main content

ncm_api_rs/api/
comment_floor.rs

1use super::Query;
2use crate::error::Result;
3/// 楼层评论
4/// 对应 Node.js module/comment_floor.js
5use crate::request::{ApiClient, ApiResponse, CryptoType};
6use serde_json::json;
7
8impl ApiClient {
9    /// 楼层评论
10    /// 对应 /comment/floor
11    pub async fn comment_floor(&self, query: &Query) -> Result<ApiResponse> {
12        let resource_type = query.get_or("type", "0");
13        let thread_id = crate::util::config::RESOURCE_TYPE_MAP
14            .get(resource_type.as_str())
15            .map(|prefix| format!("{}{}", prefix, query.get_or("id", "0")))
16            .unwrap_or_default();
17        let data = json!({
18            "parentCommentId": query.get_or("parentCommentId", "0"),
19            "threadId": thread_id,
20            "time": query.get_or("time", "-1").parse::<i64>().unwrap_or(-1),
21            "limit": query.get_or("limit", "20").parse::<i64>().unwrap_or(20)
22        });
23        self.request(
24            "/api/resource/comment/floor/get",
25            data,
26            query.to_option(CryptoType::Weapi),
27        )
28        .await
29    }
30}