docs(README): 更新文档为中文并完善API参考
- 将README从英文翻译为中文 - 添加详细的API参考文档,包括所有管理接口和枚举值说明 - 补充安装、快速开始、认证方式等使用指南 refactor(client): 优化客户端代码结构并添加详细注释 - 为所有API方法添加中文注释和使用说明 - 改进Client结构体和Option配置的设计 - 统一错误处理和响应结构的文档说明
This commit is contained in:
@@ -5,12 +5,22 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// SendMail sends an email. Requires an AppClient (X-App-Key/X-App-Secret auth).
|
||||
// SendMail 发送邮件。必须使用 NewAppClient 构造的客户端(X-App-Key/X-App-Secret 认证)。
|
||||
//
|
||||
// req.Channel 可为空:
|
||||
// 1. 若指定且存在已启用通道,则校验该通道是否在账号 AllowedChannels 内;
|
||||
// 2. 若未指定,按 Account.DefaultChannelID → Account.AllowedChannels 顺序自动挑选。
|
||||
//
|
||||
// 返回的 Status 见 SendStatusQueued / SendStatusPendingAudit / SendStatusRejected。
|
||||
//
|
||||
// POST /api/v1/mail/send AppAuth
|
||||
func (c *Client) SendMail(ctx context.Context, req SendMailReq) (*SendMailResp, error) {
|
||||
return post[*SendMailResp](c, ctx, "/api/v1/mail/send", req)
|
||||
}
|
||||
|
||||
// ListMailLogs lists mail log records with filters (ServiceAuth).
|
||||
// ListMailLogs 分页查询邮件日志,支持按用户、账号、状态、时间范围、收件人、关键字过滤。
|
||||
//
|
||||
// GET /api/v1/mail-logs?page=&page_size=&user_id=&account_id=&status=&start_date=&end_date=&to=&keyword= ServiceAuth
|
||||
func (c *Client) ListMailLogs(ctx context.Context, q MailLogListQuery) (*PaginationResult[MailLog], error) {
|
||||
params := mergeParams(paginationParams(q.PaginationQuery), map[string]interface{}{
|
||||
"user_id": q.UserID,
|
||||
@@ -24,10 +34,16 @@ func (c *Client) ListMailLogs(ctx context.Context, q MailLogListQuery) (*Paginat
|
||||
return get[*PaginationResult[MailLog]](c, ctx, "/api/v1/mail-logs", buildQuery(params))
|
||||
}
|
||||
|
||||
// GetMailLog 获取邮件日志详情(包含完整正文 Body)。
|
||||
//
|
||||
// GET /api/v1/mail-logs/{id} ServiceAuth
|
||||
func (c *Client) GetMailLog(ctx context.Context, id uint) (*MailLogDetail, error) {
|
||||
return get[*MailLogDetail](c, ctx, fmt.Sprintf("/api/v1/mail-logs/%d", id), nil)
|
||||
}
|
||||
|
||||
// GetMailStats 按状态聚合的邮件计数,用于概览面板。
|
||||
//
|
||||
// GET /api/v1/mail-logs/stats ServiceAuth
|
||||
func (c *Client) GetMailStats(ctx context.Context) ([]MailStatItem, error) {
|
||||
return get[[]MailStatItem](c, ctx, "/api/v1/mail-logs/stats", nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user