admin_config/
sms_config.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
4pub struct SmsConfig {
5    /// 短信提供商 (tencent/aliyun)
6    pub provider: String,
7    /// 应用 ID
8    pub app_id: String,
9    /// 应用 Key
10    pub app_key: String,
11    /// 签名名称
12    pub sign_name: String,
13    /// 模板 ID
14    pub template_id: String,
15    /// 腾讯云短信配置
16    pub tencent: Option<TencentSmsConfig>,
17    /// 阿里云短信配置
18    pub aliyun: Option<AliyunSmsConfig>,
19}
20
21#[derive(Debug, Clone, Serialize, Deserialize)]
22pub struct TencentSmsConfig {
23    /// SDK App ID
24    pub sdk_app_id: String,
25    /// Secret ID
26    pub secret_id: String,
27    /// Secret Key
28    pub secret_key: String,
29    /// 区域
30    pub region: String,
31}
32
33impl Default for TencentSmsConfig {
34    fn default() -> Self {
35        Self {
36            sdk_app_id: "".to_string(),
37            secret_id: "".to_string(),
38            secret_key: "".to_string(),
39            region: "ap-guangzhou".to_string(),
40        }
41    }
42}
43
44#[derive(Debug, Clone, Serialize, Deserialize)]
45pub struct AliyunSmsConfig {
46    /// Access Key ID
47    pub access_key_id: String,
48    /// Access Key Secret
49    pub access_key_secret: String,
50    /// 区域
51    pub region: String,
52}
53
54impl Default for AliyunSmsConfig {
55    fn default() -> Self {
56        Self {
57            access_key_id: "".to_string(),
58            access_key_secret: "".to_string(),
59            region: "".to_string(),
60        }
61    }
62}
63
64impl Default for SmsConfig {
65    fn default() -> Self {
66        Self {
67            provider: "tencent".to_string(),
68            app_id: "".to_string(),
69            app_key: "".to_string(),
70            sign_name: "您的应用".to_string(),
71            template_id: "123456".to_string(),
72            tencent: Some(TencentSmsConfig::default()),
73            aliyun: Some(AliyunSmsConfig::default()),
74        }
75    }
76}