refactor: remove user-level API methods, keep admin and send only
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -5,53 +5,6 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ──────────────────────────────────────────────
|
||||
// 用户接口
|
||||
// ──────────────────────────────────────────────
|
||||
|
||||
// CreateUserToken 创建用户令牌。
|
||||
// POST /api/sms/token
|
||||
func (c *Client) CreateUserToken(ctx context.Context, req CreateTokenReq) (SmsUserToken, error) {
|
||||
return post[SmsUserToken](c, ctx, "/api/sms/token", req)
|
||||
}
|
||||
|
||||
// ListUserTokens 获取当前用户的令牌列表(分页)。
|
||||
// GET /api/sms/token/list
|
||||
func (c *Client) ListUserTokens(ctx context.Context, q PaginationQuery) (PaginationResult[SmsUserToken], error) {
|
||||
params := paginationParams(q)
|
||||
return get[PaginationResult[SmsUserToken]](c, ctx, "/api/sms/token/list", buildQuery(params))
|
||||
}
|
||||
|
||||
// GetUserToken 获取指定令牌详情。
|
||||
// GET /api/sms/token/:id
|
||||
func (c *Client) GetUserToken(ctx context.Context, id uint) (SmsUserToken, error) {
|
||||
return get[SmsUserToken](c, ctx, fmt.Sprintf("/api/sms/token/%d", id), nil)
|
||||
}
|
||||
|
||||
// UpdateUserToken 更新指定令牌。
|
||||
// PUT /api/sms/token/:id
|
||||
func (c *Client) UpdateUserToken(ctx context.Context, id uint, req UpdateTokenReq) (SmsUserToken, error) {
|
||||
return put[SmsUserToken](c, ctx, fmt.Sprintf("/api/sms/token/%d", id), req)
|
||||
}
|
||||
|
||||
// DeleteUserToken 删除指定令牌。
|
||||
// DELETE /api/sms/token/:id
|
||||
func (c *Client) DeleteUserToken(ctx context.Context, id uint) error {
|
||||
_, err := del[any](c, ctx, fmt.Sprintf("/api/sms/token/%d", id))
|
||||
return err
|
||||
}
|
||||
|
||||
// ToggleUserToken 切换令牌的启用/禁用状态。
|
||||
// POST /api/sms/token/:id/toggle
|
||||
func (c *Client) ToggleUserToken(ctx context.Context, id uint) error {
|
||||
_, err := post[any](c, ctx, fmt.Sprintf("/api/sms/token/%d/toggle", id), nil)
|
||||
return err
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────
|
||||
// 管理员接口
|
||||
// ──────────────────────────────────────────────
|
||||
|
||||
// AdminListUserTokens 管理员获取令牌列表,可按 UserID、Status 筛选。
|
||||
// GET /api/sms/admin/token/list
|
||||
func (c *Client) AdminListUserTokens(ctx context.Context, q TokenListQuery) (PaginationResult[SmsUserToken], error) {
|
||||
|
||||
Reference in New Issue
Block a user