/admin/communication/templates
为当前租户创建消息发送模板。支持短信、邮件、推送三种渠道,模板内容可使用 {{变量}} 或 Go template 语法定义变量占位符(如 {{code}}),后续发送时由传入的变量值替换。模板支持多语言(locale)。参考:ePrivacy Directive 2002/58/EC、CAN-SPAM Act。
请求体
Schema: service-communication/internal/handler/dto.CreateTemplateRequest
| 字段 | 类型 | 必填 | 示例 | 约束 | 描述 |
|---|---|---|---|---|---|
channel |
string |
是 | sms |
enum: `sms`, `email`, `push` | |
code |
string |
是 | verify_code |
||
content |
string |
是 | 您的验证码是{code},5分钟内有效 |
||
name |
string |
是 | 验证码模板 |
||
content_type |
string |
否 | text |
||
description |
string |
否 | 用于发送登录验证码 |
||
format |
string |
否 | simple |
||
subject |
string |
否 | 验证码通知 |
||
text_content |
string |
否 | Your code is {code} |
||
variables |
array of string |
否 | ['["code"]'] |
响应
| 状态 | 描述 | Schema |
|---|---|---|
| 201 | 模板创建成功,返回模板详情 | service-communication/internal/handler/dto.CreateTemplateResponse |
| 400 | 请求参数错误 | dto.SimpleResponse |
| 401 | 未认证或令牌无效 | dto.SimpleResponse |
| 403 | 无权访问该资源 | dto.SimpleResponse |
| 404 | 资源不存在 | dto.SimpleResponse |
| 500 | 服务内部错误 | dto.SimpleResponse |
引用的 Schema
dto.SimpleResponse
| 字段 | 类型 | 必填 | 示例 | 约束 | 描述 |
|---|---|---|---|---|---|
code |
integer |
否 | |||
message |
string |
否 | |||
timestamp |
string |
否 |
service-communication/internal/handler/dto.CreateTemplateResponse
| 字段 | 类型 | 必填 | 示例 | 约束 | 描述 |
|---|---|---|---|---|---|
code |
integer |
否 | 0 |
||
data |
service-communication/internal/handler/dto.MessageTemplateResponse |
否 | |||
message |
string |
否 | success |
service-communication/internal/handler/dto.MessageTemplateResponse
消息模板数据
| 字段 | 类型 | 必填 | 示例 | 约束 | 描述 |
|---|---|---|---|---|---|
channel |
string |
否 | sms |
||
code |
string |
否 | verify_code |
||
content |
string |
否 | 您的验证码是{code},5分钟内有效 |
||
content_type |
string |
否 | text |
||
created_at |
string |
否 | 2026-04-15T10:00:00Z |
||
description |
string |
否 | 用于发送登录验证码 |
||
id |
string |
否 | tpl_abc123 |
||
is_active |
boolean |
否 | True |
||
name |
string |
否 | 验证码模板 |
||
subject |
string |
否 | 验证码通知 |
||
tenant_id |
string |
否 | tnt_xyz789 |
||
updated_at |
string |
否 | 2026-04-15T10:00:00Z |
||
variables |
array of string |
否 | ['["code"]'] |
||
version |
integer |
否 | 1 |