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<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    pub user_sailing: serde_json::Value, // 评论条目装饰信息
76    pub is_contractor: bool,             // 是否合作用户
77    pub contract_desc: String,           // 合作用户说明
78
79    pub rank: Option<String>,
80    pub display_rank: Option<String>,
81    pub fans_detail_a: Option<FansDetail>, // 粉丝标签信息,仅 A 有
82    pub following: Option<u64>,            // 是否关注该用户
83    pub is_followed: Option<u64>,          // 是否被关注
84
85    pub rank_b: Option<String>,    //
86    pub face_nft_new: Option<i64>, // 是否有头像 NFT
87    pub senior: Option<JumpUrl>,   // 高级会员信息
88    pub fans_detail_b: Option<serde_json::Value>,
89    pub user_sailing_v2: Option<JumpUrl>,           // 装饰信息
90    pub nft_interaction: Option<serde_json::Value>, // NFT 交互信息
91    pub avatar_item: Option<serde_json::Value>,     // 头像物品信息
92}
93
94/// 大会员信息
95#[derive(Debug, Clone, Serialize, Deserialize)]
96#[serde(rename_all = "camelCase")]
97pub struct Vip {
98    pub vip_type: i64,
99    pub vip_due_date: i64,
100    pub due_remark: String,
101    pub access_status: i64,
102    pub vip_status: i64,
103    pub vip_status_warn: String,
104    pub theme_type: i64,
105    #[serde(rename = "avatar_subscript")]
106    pub avatar_subscript: i64,
107    #[serde(rename = "nickname_color")]
108    pub nickname_color: String,
109}
110
111/// 会员铭牌样式
112
113/// 粉丝标签信息
114#[derive(Debug, Clone, Serialize, Deserialize)]
115pub struct FansDetail {
116    pub uid: u64,
117    pub medal_id: u64,
118    pub medal_name: String,
119    pub score: Option<u64>,
120    pub level: u64,
121    pub intimacy: Option<u64>,
122    pub master_status: Option<u64>,
123    pub is_receive: Option<u64>,
124}
125
126/// 评论条目装扮信息
127#[derive(Debug, Clone, Serialize, Deserialize)]
128pub struct UserSailing {
129    pub pendant: Option<Pendant>,
130    pub cardbg: Option<CardBg>,
131    pub cardbg_with_focus: Option<()>, // 待确认
132}
133
134/// 评论条目装扮信息
135#[derive(Debug, Clone, Serialize, Deserialize)]
136pub struct CardBg {
137    pub id: u64,
138    pub name: String,
139    pub image: String,
140    pub jump_url: Option<String>,
141    pub fan: Option<FanInfo>,
142    pub r#type: String, // suit/vip_suit
143}
144
145/// 粉丝专属装扮信息
146#[derive(Debug, Clone, Serialize, Deserialize)]
147pub struct FanInfo {
148    pub is_fan: u64, // 0否 1是
149    pub number: u64,
150    pub color: String,
151    pub name: String,
152    pub num_desc: String,
153}
154
155/// 评论内容
156#[derive(Debug, Clone, Serialize, Deserialize)]
157pub struct Content {
158    pub message: String,
159    pub members: Option<Vec<Member>>,               // at 用户
160    pub jump_url: Option<HashMap<String, JumpUrl>>, // 高亮超链,以超链转义符为键
161    pub max_line: Option<u64>,
162
163    pub plat: Option<u64>, // 发送端
164    pub device: Option<String>,
165    pub emote: Option<HashMap<String, Emote>>, // 表情转义,以表情转义符为键
166    pub pictures: Option<Vec<Picture>>,
167}
168
169/// 单个表情对象
170#[derive(Debug, Clone, Serialize, Deserialize)]
171pub struct Emote {
172    pub id: u64,                    // 表情 id
173    pub package_id: u64,            // 表情包 id
174    pub state: u64,                 // 0
175    pub r#type: u64,                // 表情类型:1免费/2会员专属/3购买/4颜文字
176    pub attr: Option<u64>,          // 待确认
177    pub text: String,               // 表情转义符
178    pub url: String,                // 表情图片 url
179    pub meta: Option<EmoteMeta>,    // 属性信息
180    pub mtime: Option<u64>,         // 表情创建时间戳
181    pub jump_title: Option<String>, // 表情名称
182}
183
184#[derive(Debug, Clone, Serialize, Deserialize)]
185pub struct JumpUrl {
186    pub title: Option<String>,            // 标题
187    pub state: Option<u64>,               // 图标 url 或状态
188    pub prefix_icon: Option<String>,      // 待确认
189    pub app_url_schema: Option<String>,   // APP 跳转 schema
190    pub app_name: Option<String>,         // APP 名称
191    pub app_package_name: Option<String>, // APP 包名
192    pub click_report: Option<String>,     // 上报 id
193}
194
195/// 表情属性信息
196#[derive(Debug, Clone, Serialize, Deserialize)]
197pub struct EmoteMeta {
198    pub size: Option<u64>,     // 表情尺寸信息,1小/2大
199    pub alias: Option<String>, // 简写名
200}
201
202/// 评论图片信息
203#[derive(Debug, Clone, Serialize, Deserialize)]
204pub struct Picture {
205    pub img_src: String,
206    pub img_width: u64,
207    pub img_height: u64,
208    pub img_size: u64, // KB
209}
210
211/// 折叠信息
212#[derive(Debug, Clone, Serialize, Deserialize)]
213pub struct Folder {
214    pub has_folded: bool,
215    pub is_folded: bool,
216    pub rule: String, // 相关规则页面 url
217}
218
219/// UP主操作信息
220#[derive(Debug, Clone, Serialize, Deserialize)]
221pub struct UpAction {
222    pub like: bool,
223    pub reply: bool,
224}
225
226/// 卡片标签信息
227#[derive(Debug, Clone, Serialize, Deserialize)]
228pub struct CardLabel {
229    pub rpid: u64,
230    pub text_content: String,
231    pub text_color_day: String,
232    pub text_color_night: String,
233    pub label_color_day: String,
234    pub label_color_night: String,
235    pub image: Option<String>,
236    pub r#type: Option<String>,
237    pub background: Option<String>,
238    pub background_width: Option<u64>,
239    pub background_height: Option<u64>,
240    pub jump_url: Option<String>,
241    pub effect: Option<u64>,
242    pub effect_start_time: Option<u64>,
243}
244
245/// 回复提示文案信息
246#[derive(Debug, Clone, Serialize, Deserialize)]
247pub struct ReplyControl {
248    pub sub_reply_entry_text: Option<String>,
249    pub sub_reply_title_text: Option<String>,
250    pub time_desc: Option<String>,
251    pub location: Option<String>,
252}
253
254/// 评论区顶部信息
255#[derive(Debug, Clone, Serialize, Deserialize)]
256pub struct Top {
257    pub admin: serde_json::Value,
258    pub upper: serde_json::Value,
259    pub vote: serde_json::Value,
260}
261
262#[derive(Debug, Clone, Serialize, Deserialize)]
263pub struct Config {
264    pub showtopic: u32,
265    pub show_up_flag: bool,
266    pub read_only: bool,
267}
268
269/// 评论区分页信息
270#[derive(Debug, Clone, Serialize, Deserialize)]
271pub struct Cursor {
272    pub is_begin: bool,
273    pub prev: i64,
274    pub next: i64,
275    pub is_end: bool,
276    pub pagination_reply: serde_json::Value,
277    pub session_id: String,
278    pub mode: i64,
279    pub mode_text: String,
280    pub all_count: i64,
281    pub support_mode: Vec<i64>,
282}
283
284/// 评论区顶部信息
285#[derive(Debug, Clone, Serialize, Deserialize)]
286pub struct Upper {
287    pub mid: u32,
288}
289
290#[derive(Debug, Clone, Serialize, Deserialize)]
291pub struct Control {
292    pub input_disable: bool,
293    pub root_input_text: String,
294    pub child_input_text: String,
295    pub giveup_input_text: String,
296    pub screenshot_icon_state: i64,
297    pub upload_picture_icon_state: i64,
298    pub answer_guide_text: String,
299    pub answer_guide_icon_url: String,
300    pub answer_guide_ios_url: String,
301    pub answer_guide_android_url: String,
302    pub bg_text: String,
303    pub empty_page: Option<serde_json::Value>,
304    pub show_type: i64,
305    pub show_text: String,
306    pub web_selection: bool,
307    pub disable_jump_emote: bool,
308    pub enable_charged: bool,
309    pub enable_cm_biz_helper: bool,
310    pub preload_resources: Option<serde_json::Value>,
311}
312
313/// 广告
314#[derive(Debug, Clone, Serialize, Deserialize)]
315pub struct CM {
316    pub id: i64,
317    pub contract_id: String,
318    pub pos_num: i64,
319    pub name: String,
320    pub pic: String,
321    pub litpic: String,
322    pub url: String,
323    pub style: i64,
324    pub agency: String,
325    pub label: String,
326    pub intro: String,
327    pub creative_type: i64,
328    pub request_id: String,
329    pub src_id: i64,
330    pub area: i64,
331    pub is_ad_loc: bool,
332    pub ad_cb: String,
333    pub title: String,
334    pub server_type: i64,
335    pub cm_mark: i64,
336    pub stime: i64,
337    pub mid: String,
338    pub activity_type: i64,
339    pub epid: i64,
340    pub sub_title: String,
341    pub ad_desc: String,
342    pub adver_name: String,
343    pub null_frame: bool,
344    pub pic_main_color: String,
345}