docs(README): 更新文档为中文并完善API参考
- 将README从英文翻译为中文 - 添加详细的API参考文档,包括所有管理接口和枚举值说明 - 补充安装、快速开始、认证方式等使用指南 refactor(client): 优化客户端代码结构并添加详细注释 - 为所有API方法添加中文注释和使用说明 - 改进Client结构体和Option配置的设计 - 统一错误处理和响应结构的文档说明
This commit is contained in:
+13
@@ -5,10 +5,17 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// CreateChannel 创建发件通道。Code 为唯一标识,发件请求的 channel 字段填写此 Code。
|
||||
// Strategy 可取 StrategyRoundRobin / StrategyWeight / StrategyLeastUsed。
|
||||
//
|
||||
// POST /api/v1/channels ServiceAuth
|
||||
func (c *Client) CreateChannel(ctx context.Context, req CreateChannelReq) (*Channel, error) {
|
||||
return post[*Channel](c, ctx, "/api/v1/channels", req)
|
||||
}
|
||||
|
||||
// ListChannels 分页查询通道,支持按状态与关键字过滤。
|
||||
//
|
||||
// GET /api/v1/channels?page=&page_size=&status=&keyword= ServiceAuth
|
||||
func (c *Client) ListChannels(ctx context.Context, q ChannelListQuery) (*PaginationResult[Channel], error) {
|
||||
params := mergeParams(paginationParams(q.PaginationQuery), map[string]interface{}{
|
||||
"status": q.Status,
|
||||
@@ -17,10 +24,16 @@ func (c *Client) ListChannels(ctx context.Context, q ChannelListQuery) (*Paginat
|
||||
return get[*PaginationResult[Channel]](c, ctx, "/api/v1/channels", buildQuery(params))
|
||||
}
|
||||
|
||||
// UpdateChannel 局部更新通道。Code 不可修改;修改 Status 可启用/禁用通道。
|
||||
//
|
||||
// PUT /api/v1/channels/{id} ServiceAuth
|
||||
func (c *Client) UpdateChannel(ctx context.Context, id uint, req UpdateChannelReq) (*Channel, error) {
|
||||
return put[*Channel](c, ctx, fmt.Sprintf("/api/v1/channels/%d", id), req)
|
||||
}
|
||||
|
||||
// DeleteChannel 删除通道(软删除)。通道下如有启用中的发信账号,建议先清空。
|
||||
//
|
||||
// DELETE /api/v1/channels/{id} ServiceAuth
|
||||
func (c *Client) DeleteChannel(ctx context.Context, id uint) error {
|
||||
_, err := del[any](c, ctx, fmt.Sprintf("/api/v1/channels/%d", id))
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user