Skip to main content

openlark_workflow/v2/comment/
models.rs

1//! 评论 API v2 的数据模型
2
3use serde::{Deserialize, Serialize};
4
5/// 可写评论字段。
6#[derive(Debug, Clone, Serialize, Default, PartialEq)]
7pub struct InputComment {
8    /// 评论内容。
9    #[serde(skip_serializing_if = "Option::is_none")]
10    pub content: Option<String>,
11    /// 被回复评论的 ID。
12    #[serde(skip_serializing_if = "Option::is_none")]
13    pub reply_to_comment_id: Option<String>,
14    /// 评论归属资源类型。
15    #[serde(skip_serializing_if = "Option::is_none")]
16    pub resource_type: Option<String>,
17    /// 评论归属资源 ID。
18    #[serde(skip_serializing_if = "Option::is_none")]
19    pub resource_id: Option<String>,
20}
21
22/// 创建评论请求体。
23pub type CreateCommentBody = InputComment;
24
25/// 更新评论请求体。
26#[derive(Debug, Clone, Serialize, Default, PartialEq)]
27pub struct UpdateCommentBody {
28    /// 要更新的评论字段。
29    pub comment: InputComment,
30    /// 要更新的字段名。
31    pub update_fields: Vec<String>,
32}
33
34/// 评论创建者。
35#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
36pub struct CommentCreator {
37    /// 成员 ID。
38    #[serde(default)]
39    pub id: Option<String>,
40    /// 成员类型。
41    #[serde(default)]
42    pub r#type: Option<String>,
43    /// 成员角色。
44    #[serde(default)]
45    pub role: Option<String>,
46    /// 成员名称。
47    #[serde(default)]
48    pub name: Option<String>,
49}
50
51/// 评论详情。
52#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
53pub struct CommentItem {
54    /// 评论 ID。
55    #[serde(default)]
56    pub id: Option<String>,
57    /// 评论内容。
58    #[serde(default)]
59    pub content: Option<String>,
60    /// 评论创建者。
61    #[serde(default)]
62    pub creator: Option<CommentCreator>,
63    /// 被回复评论的 ID。
64    #[serde(default)]
65    pub reply_to_comment_id: Option<String>,
66    /// 创建时间戳(毫秒)。
67    #[serde(default)]
68    pub created_at: Option<String>,
69    /// 更新时间戳(毫秒)。
70    #[serde(default)]
71    pub updated_at: Option<String>,
72    /// 资源类型。
73    #[serde(default)]
74    pub resource_type: Option<String>,
75    /// 资源 ID。
76    #[serde(default)]
77    pub resource_id: Option<String>,
78}
79
80/// 创建评论响应。
81#[derive(Debug, Clone, Deserialize)]
82pub struct CreateCommentResponse {
83    /// 创建的评论。
84    pub comment: CommentItem,
85}
86
87/// 获取评论响应。
88#[derive(Debug, Clone, Deserialize)]
89pub struct GetCommentResponse {
90    /// 评论详情。
91    pub comment: CommentItem,
92}
93
94/// 更新评论响应。
95#[derive(Debug, Clone, Deserialize)]
96pub struct UpdateCommentResponse {
97    /// 更新后的评论。
98    pub comment: CommentItem,
99}
100
101/// 删除评论响应。
102#[derive(Debug, Clone, Deserialize, Default)]
103pub struct DeleteCommentResponse {}
104
105/// 获取评论列表响应。
106#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
107pub struct ListCommentsResponse {
108    /// 是否还有更多项。
109    #[serde(default)]
110    pub has_more: bool,
111    /// 分页标记。
112    #[serde(default)]
113    pub page_token: Option<String>,
114    /// 列表项。
115    #[serde(default)]
116    pub items: Vec<CommentItem>,
117}