Skip to main content

openlark_platform/common/
mod.rs

1//! 通用数据模型
2
3use serde::{Deserialize, Serialize};
4
5/// 应用信息
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct AppInfo {
8    /// 应用 ID
9    pub app_id: String,
10    /// 应用名称
11    pub app_name: String,
12    /// 应用描述
13    pub description: Option<String>,
14    /// 应用状态
15    pub status: String,
16}
17
18/// 目录项
19#[derive(Debug, Clone, Serialize, Deserialize)]
20pub struct DirectoryItem {
21    /// 项 ID
22    pub id: String,
23    /// 项名称
24    pub name: String,
25    /// 项类型
26    pub item_type: String,
27}
28
29/// 系统设置
30#[derive(Debug, Clone, Serialize, Deserialize)]
31pub struct SystemSettings {
32    /// 设置键
33    pub key: String,
34    /// 设置值
35    pub value: String,
36    /// 设置描述
37    pub description: Option<String>,
38}
39
40// API 端点定义
41pub mod api_endpoints;
42
43#[cfg(test)]
44mod tests {
45
46    use serde_json;
47
48    #[test]
49    fn test_serialization_roundtrip() {
50        // 基础序列化测试
51        let json = r#"{"test": "value"}"#;
52        assert!(serde_json::from_str::<serde_json::Value>(json).is_ok());
53    }
54
55    #[test]
56    fn test_deserialization_from_json() {
57        // 基础反序列化测试
58        let json = r#"{"field": "data"}"#;
59        let value: serde_json::Value = serde_json::from_str(json).unwrap();
60        assert_eq!(value["field"], "data");
61    }
62}