Skip to main content

bpi_rs/comment/
types.rs

1//! 评论相关数据结构
2//!
3//! 本模块定义了评论系统相关的所有数据结构,包括评论内容、用户信息、表情等。
4
5use std::collections::HashMap;
6
7use crate::models::{LevelInfo, Nameplate, OfficialVerify, Pendant};
8use serde::{Deserialize, Serialize};
9
10/// 评论条目对象
11#[derive(Debug, Clone, Serialize, Deserialize)]
12pub struct Comment {
13    pub rpid: i64, // 评论 rpid
14    pub oid: i64,  // 评论区对象 id
15    #[serde(rename = "type")]
16    pub oid_type: i64, // 评论区类型代码(type)
17    pub mid: i64,  // 评论发送者 mid
18    pub root: i64, // 根评论 rpid,一级评论为0
19    pub parent: i64, // 回复父评论 rpid
20    pub dialog: i64, // 回复对方 rpid
21    pub count: i64, // 二级评论条数
22    pub rcount: i64, // 回复评论条数
23    pub state: i64, // 评论状态,0正常,17隐藏
24    pub fansgrade: i64, // 是否具有粉丝标签,0无,1有
25    pub attr: i64, // 某属性位
26    pub ctime: i64, // 评论发送时间戳
27    pub like: i64, // 评论获赞数
28    pub action: i64, // 当前用户操作状态,0无,1已点赞,2已点踩
29    pub member: Member, // 评论发送者信息
30    pub content: Content, // 评论内容信息
31    pub up_action: UpAction, // 评论 UP 主操作信息
32    pub invisible: bool, // 评论是否被隐藏
33    pub reply_control: ReplyControl, // 评论提示文案信息
34    pub folder: Folder, // 折叠信息
35
36    pub floor: Option<u64>,
37    pub show_follow: Option<bool>,
38    pub card_label: Option<Vec<CardLabel>>,
39    pub rpid_str: Option<String>,
40    pub root_str: Option<String>,
41    pub parent_str: Option<String>,
42    pub dialog_str: Option<String>,
43    pub mid_str: Option<String>,
44    pub oid_str: Option<String>,
45    pub replies: Option<Vec<Comment>>,
46    pub assist: Option<u64>,
47
48    pub dynamic_id_str: Option<String>,
49    pub note_cvid_str: Option<String>,
50    pub track_info: Option<String>,
51}
52
53/// 页信息
54#[derive(Debug, Clone, Serialize, Deserialize)]
55pub struct PageInfo {
56    pub num: u64,            // 当前页码
57    pub size: u64,           // 每页条数
58    pub count: u64,          // 根评论条数
59    pub acount: Option<u64>, // 总评论条数
60}
61
62/// 评论发送者信息
63#[derive(Debug, Clone, Serialize, Deserialize)]
64pub struct Member {
65    pub mid: String,                     // 发送者 mid
66    pub uname: String,                   // 昵称
67    pub sex: String,                     // 性别
68    pub sign: String,                    // 用户签名
69    pub avatar: String,                  // 头像 url
70    pub level_info: LevelInfo,           // 等级信息
71    pub pendant: Pendant,                // 头像框信息
72    pub nameplate: Nameplate,            // 勋章信息
73    pub official_verify: OfficialVerify, // 认证信息
74    pub vip: Vip,                        // 大会员信息
75    #[serde(default)]
76    pub user_sailing: serde_json::Value, // 评论条目装饰信息
77    #[serde(default)]
78    pub is_contractor: bool,             // 是否合作用户
79    #[serde(default)]
80    pub contract_desc: String,           // 合作用户说明
81
82    pub rank: Option<String>,
83    pub display_rank: Option<String>,
84    pub fans_detail_a: Option<FansDetail>, // 粉丝标签信息,仅 A 有
85    pub following: Option<u64>,            // 是否关注该用户
86    pub is_followed: Option<u64>,          // 是否被关注
87
88    pub rank_b: Option<String>,    //
89    pub face_nft_new: Option<i64>, // 是否有头像 NFT
90    pub senior: Option<JumpUrl>,   // 高级会员信息
91    pub fans_detail_b: Option<serde_json::Value>,
92    pub user_sailing_v2: Option<JumpUrl>,           // 装饰信息
93    pub nft_interaction: Option<serde_json::Value>, // NFT 交互信息
94    pub avatar_item: Option<serde_json::Value>,     // 头像物品信息
95}
96
97/// 大会员信息
98#[derive(Debug, Clone, Serialize, Deserialize)]
99#[serde(rename_all = "camelCase")]
100pub struct Vip {
101    pub vip_type: i64,
102    pub vip_due_date: i64,
103    pub due_remark: String,
104    pub access_status: i64,
105    pub vip_status: i64,
106    pub vip_status_warn: String,
107    pub theme_type: i64,
108    #[serde(rename = "avatar_subscript")]
109    pub avatar_subscript: i64,
110    #[serde(rename = "nickname_color")]
111    pub nickname_color: String,
112}
113
114/// 会员铭牌样式
115
116/// 粉丝标签信息
117#[derive(Debug, Clone, Serialize, Deserialize)]
118pub struct FansDetail {
119    pub uid: u64,
120    pub medal_id: u64,
121    pub medal_name: String,
122    pub score: Option<u64>,
123    pub level: u64,
124    pub intimacy: Option<u64>,
125    pub master_status: Option<u64>,
126    pub is_receive: Option<u64>,
127}
128
129/// 评论条目装扮信息
130#[derive(Debug, Clone, Serialize, Deserialize)]
131pub struct UserSailing {
132    pub pendant: Option<Pendant>,
133    pub cardbg: Option<CardBg>,
134    pub cardbg_with_focus: Option<()>, // 待确认
135}
136
137/// 评论条目装扮信息
138#[derive(Debug, Clone, Serialize, Deserialize)]
139pub struct CardBg {
140    pub id: u64,
141    pub name: String,
142    pub image: String,
143    pub jump_url: Option<String>,
144    pub fan: Option<FanInfo>,
145    pub r#type: String, // suit/vip_suit
146}
147
148/// 粉丝专属装扮信息
149#[derive(Debug, Clone, Serialize, Deserialize)]
150pub struct FanInfo {
151    pub is_fan: u64, // 0否 1是
152    pub number: u64,
153    pub color: String,
154    pub name: String,
155    pub num_desc: String,
156}
157
158/// 评论内容
159#[derive(Debug, Clone, Serialize, Deserialize)]
160pub struct Content {
161    pub message: String,
162    pub members: Option<Vec<Member>>,               // at 用户
163    pub jump_url: Option<HashMap<String, JumpUrl>>, // 高亮超链,以超链转义符为键
164    pub max_line: Option<u64>,
165
166    pub plat: Option<u64>, // 发送端
167    pub device: Option<String>,
168    pub emote: Option<HashMap<String, Emote>>, // 表情转义,以表情转义符为键
169    pub pictures: Option<Vec<Picture>>,
170}
171
172/// 单个表情对象
173#[derive(Debug, Clone, Serialize, Deserialize)]
174pub struct Emote {
175    pub id: u64,                    // 表情 id
176    pub package_id: u64,            // 表情包 id
177    pub state: u64,                 // 0
178    pub r#type: u64,                // 表情类型:1免费/2会员专属/3购买/4颜文字
179    pub attr: Option<u64>,          // 待确认
180    pub text: String,               // 表情转义符
181    pub url: String,                // 表情图片 url
182    pub meta: Option<EmoteMeta>,    // 属性信息
183    pub mtime: Option<u64>,         // 表情创建时间戳
184    pub jump_title: Option<String>, // 表情名称
185}
186
187#[derive(Debug, Clone, Serialize, Deserialize)]
188pub struct JumpUrl {
189    pub title: Option<String>,            // 标题
190    pub state: Option<u64>,               // 图标 url 或状态
191    pub prefix_icon: Option<String>,      // 待确认
192    pub app_url_schema: Option<String>,   // APP 跳转 schema
193    pub app_name: Option<String>,         // APP 名称
194    pub app_package_name: Option<String>, // APP 包名
195    pub click_report: Option<String>,     // 上报 id
196}
197
198/// 表情属性信息
199#[derive(Debug, Clone, Serialize, Deserialize)]
200pub struct EmoteMeta {
201    pub size: Option<u64>,     // 表情尺寸信息,1小/2大
202    pub alias: Option<String>, // 简写名
203}
204
205/// 评论图片信息
206#[derive(Debug, Clone, Serialize, Deserialize)]
207pub struct Picture {
208    pub img_src: String,
209    pub img_width: u64,
210    pub img_height: u64,
211    pub img_size: f64, // KB
212}
213
214/// 折叠信息
215#[derive(Debug, Clone, Serialize, Deserialize)]
216pub struct Folder {
217    pub has_folded: bool,
218    pub is_folded: bool,
219    pub rule: String, // 相关规则页面 url
220}
221
222/// UP主操作信息
223#[derive(Debug, Clone, Serialize, Deserialize)]
224pub struct UpAction {
225    pub like: bool,
226    pub reply: bool,
227}
228
229/// 卡片标签信息
230#[derive(Debug, Clone, Serialize, Deserialize)]
231pub struct CardLabel {
232    pub rpid: u64,
233    pub text_content: String,
234    pub text_color_day: String,
235    pub text_color_night: String,
236    pub label_color_day: String,
237    pub label_color_night: String,
238    pub image: Option<String>,
239    pub r#type: Option<u64>,
240    pub background: Option<String>,
241    pub background_width: Option<u64>,
242    pub background_height: Option<u64>,
243    pub jump_url: Option<String>,
244    pub effect: Option<u64>,
245    pub effect_start_time: Option<u64>,
246}
247
248/// 回复提示文案信息
249#[derive(Debug, Clone, Serialize, Deserialize)]
250pub struct ReplyControl {
251    pub sub_reply_entry_text: Option<String>,
252    pub sub_reply_title_text: Option<String>,
253    pub time_desc: Option<String>,
254    pub location: Option<String>,
255}
256
257/// 评论区顶部信息
258#[derive(Debug, Clone, Serialize, Deserialize)]
259pub struct Top {
260    pub admin: serde_json::Value,
261    pub upper: serde_json::Value,
262    pub vote: serde_json::Value,
263}
264
265#[derive(Debug, Clone, Serialize, Deserialize)]
266pub struct Config {
267    pub showtopic: u32,
268    pub show_up_flag: bool,
269    pub read_only: bool,
270}
271
272/// 评论区分页信息
273#[derive(Debug, Clone, Serialize, Deserialize)]
274pub struct Cursor {
275    pub is_begin: bool,
276    pub prev: i64,
277    pub next: i64,
278    pub is_end: bool,
279    pub pagination_reply: serde_json::Value,
280    pub session_id: String,
281    pub mode: i64,
282    pub mode_text: String,
283    pub all_count: i64,
284    pub support_mode: Vec<i64>,
285}
286
287/// 评论区顶部信息
288#[derive(Debug, Clone, Serialize, Deserialize)]
289pub struct Upper {
290    pub mid: u64, // UP 主 mid
291}
292
293#[derive(Debug, Clone, Serialize, Deserialize)]
294pub struct Control {
295    pub input_disable: bool,
296    pub root_input_text: String,
297    pub child_input_text: String,
298    pub giveup_input_text: String,
299    pub screenshot_icon_state: i64,
300    pub upload_picture_icon_state: i64,
301    pub answer_guide_text: String,
302    pub answer_guide_icon_url: String,
303    pub answer_guide_ios_url: String,
304    pub answer_guide_android_url: String,
305    pub bg_text: String,
306    pub empty_page: Option<serde_json::Value>,
307    pub show_type: i64,
308    pub show_text: String,
309    pub web_selection: bool,
310    pub disable_jump_emote: bool,
311    pub enable_charged: bool,
312    pub enable_cm_biz_helper: bool,
313    pub preload_resources: Option<serde_json::Value>,
314}
315
316/// 广告
317#[derive(Debug, Clone, Serialize, Deserialize)]
318pub struct CM {
319    pub id: i64,
320    pub contract_id: String,
321    pub pos_num: i64,
322    pub name: String,
323    pub pic: String,
324    pub litpic: String,
325    pub url: String,
326    pub style: i64,
327    pub agency: String,
328    pub label: String,
329    pub intro: String,
330    pub creative_type: i64,
331    pub request_id: String,
332    pub src_id: i64,
333    pub area: i64,
334    pub is_ad_loc: bool,
335    pub ad_cb: String,
336    pub title: String,
337    pub server_type: i64,
338    pub cm_mark: i64,
339    pub stime: i64,
340    pub mid: String,
341    pub activity_type: i64,
342    pub epid: i64,
343    pub sub_title: String,
344    pub ad_desc: String,
345    pub adver_name: String,
346    pub null_frame: bool,
347    pub pic_main_color: String,
348}