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;
42pub mod api_utils;
43pub mod constants;
44
45#[cfg(test)]
46mod tests {
47
48    use serde_json;
49
50    #[test]
51    fn test_serialization_roundtrip() {
52        // 基础序列化测试
53        let json = r#"{"test": "value"}"#;
54        assert!(serde_json::from_str::<serde_json::Value>(json).is_ok());
55    }
56
57    #[test]
58    fn test_deserialization_from_json() {
59        // 基础反序列化测试
60        let json = r#"{"field": "data"}"#;
61        let value: serde_json::Value = serde_json::from_str(json).expect("JSON 反序列化失败");
62        assert_eq!(value["field"], "data");
63    }
64}