Skip to main content

openlark_platform/
admin.rs

1//! 系统管理模块
2//!
3//! 提供系统配置、后台管理、平台工具等功能 (14 APIs)
4
5use crate::PlatformConfig;
6use std::sync::Arc;
7
8/// 系统管理服务
9///
10/// 提供系统管理相关 API 的访问入口。
11#[derive(Debug, Clone)]
12pub struct AdminService {
13    /// 客户端配置
14    config: Arc<PlatformConfig>,
15}
16
17impl AdminService {
18    /// 创建新的系统管理服务实例
19    pub fn new(config: Arc<PlatformConfig>) -> Self {
20        Self { config }
21    }
22
23    /// 获取客户端配置
24    pub fn config(&self) -> Arc<PlatformConfig> {
25        self.config.clone()
26    }
27
28    /// V1 版本 API
29    pub fn v1(&self) -> crate::admin::v1::AdminV1 {
30        crate::admin::v1::AdminV1::new(self.config.clone())
31    }
32}
33
34pub mod v1;
35
36#[cfg(test)]
37mod tests {
38    use crate::{PlatformConfig, admin::AdminService};
39
40    #[test]
41    fn test_service_creation() {
42        let config = PlatformConfig::builder()
43            .app_id("test_app_id")
44            .app_secret("test_app_secret")
45            .build();
46
47        let service = AdminService::new(std::sync::Arc::new(config));
48        // PlatformConfig 实现了 Deref,可以直接访问 app_id
49        assert_eq!(service.config().app_id(), "test_app_id");
50    }
51}