f004408ca0
Co-authored-by: Cursor <cursoragent@cursor.com>
89 lines
3.8 KiB
Go
89 lines
3.8 KiB
Go
package smscli
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
)
|
|
|
|
// AdminListTemplates 管理员获取模板列表,可按 UserID、Status 筛选。
|
|
// GET /api/sms/admin/template/list
|
|
func (c *Client) AdminListTemplates(ctx context.Context, q TemplateListQuery) (PaginationResult[SmsTemplate], error) {
|
|
params := mergeParams(paginationParams(q.PaginationQuery), map[string]interface{}{
|
|
"user_id": q.UserID,
|
|
"status": q.Status,
|
|
})
|
|
return get[PaginationResult[SmsTemplate]](c, ctx, "/api/sms/admin/template/list", buildQuery(params))
|
|
}
|
|
|
|
// AdminListRecommendedTemplates 管理员获取推荐模板列表(分页)。
|
|
// GET /api/sms/admin/template/recommended
|
|
func (c *Client) AdminListRecommendedTemplates(ctx context.Context, q PaginationQuery) (PaginationResult[SmsRecommendedTemplate], error) {
|
|
params := paginationParams(q)
|
|
return get[PaginationResult[SmsRecommendedTemplate]](c, ctx, "/api/sms/admin/template/recommended", buildQuery(params))
|
|
}
|
|
|
|
// AdminGetTemplate 管理员获取指定模板详情。
|
|
// GET /api/sms/admin/template/:id
|
|
func (c *Client) AdminGetTemplate(ctx context.Context, id uint) (SmsTemplate, error) {
|
|
return get[SmsTemplate](c, ctx, fmt.Sprintf("/api/sms/admin/template/%d", id), nil)
|
|
}
|
|
|
|
// AdminCreateTemplate 管理员创建模板(可指定 UserID)。
|
|
// POST /api/sms/admin/template
|
|
func (c *Client) AdminCreateTemplate(ctx context.Context, req AdminCreateTemplateReq) (SmsTemplate, error) {
|
|
return post[SmsTemplate](c, ctx, "/api/sms/admin/template", req)
|
|
}
|
|
|
|
// AdminUpdateTemplate 管理员更新指定模板。
|
|
// PUT /api/sms/admin/template/:id
|
|
func (c *Client) AdminUpdateTemplate(ctx context.Context, id uint, req AdminUpdateTemplateReq) (SmsTemplate, error) {
|
|
return put[SmsTemplate](c, ctx, fmt.Sprintf("/api/sms/admin/template/%d", id), req)
|
|
}
|
|
|
|
// AdminDeleteTemplate 管理员删除指定模板。
|
|
// DELETE /api/sms/admin/template/:id
|
|
func (c *Client) AdminDeleteTemplate(ctx context.Context, id uint) error {
|
|
_, err := del[any](c, ctx, fmt.Sprintf("/api/sms/admin/template/%d", id))
|
|
return err
|
|
}
|
|
|
|
// AdminSubmitTemplate 管理员提交模板进入审核。
|
|
// POST /api/sms/admin/template/:id/submit
|
|
func (c *Client) AdminSubmitTemplate(ctx context.Context, id uint) error {
|
|
_, err := post[any](c, ctx, fmt.Sprintf("/api/sms/admin/template/%d/submit", id), nil)
|
|
return err
|
|
}
|
|
|
|
// ApproveTemplate 管理员审核通过模板。
|
|
// POST /api/sms/admin/template/:id/approve
|
|
func (c *Client) ApproveTemplate(ctx context.Context, id uint) error {
|
|
_, err := post[any](c, ctx, fmt.Sprintf("/api/sms/admin/template/%d/approve", id), nil)
|
|
return err
|
|
}
|
|
|
|
// RejectTemplate 管理员驳回模板,需提供驳回原因。
|
|
// POST /api/sms/admin/template/:id/reject
|
|
func (c *Client) RejectTemplate(ctx context.Context, id uint, req RejectReq) error {
|
|
_, err := post[any](c, ctx, fmt.Sprintf("/api/sms/admin/template/%d/reject", id), req)
|
|
return err
|
|
}
|
|
|
|
// CreateRecommendedTemplate 管理员创建推荐模板。
|
|
// POST /api/sms/admin/template/recommended
|
|
func (c *Client) CreateRecommendedTemplate(ctx context.Context, req CreateRecommendedTemplateReq) (SmsRecommendedTemplate, error) {
|
|
return post[SmsRecommendedTemplate](c, ctx, "/api/sms/admin/template/recommended", req)
|
|
}
|
|
|
|
// UpdateRecommendedTemplate 管理员更新推荐模板。
|
|
// PUT /api/sms/admin/template/recommended/:id
|
|
func (c *Client) UpdateRecommendedTemplate(ctx context.Context, id uint, req UpdateRecommendedTemplateReq) (SmsRecommendedTemplate, error) {
|
|
return put[SmsRecommendedTemplate](c, ctx, fmt.Sprintf("/api/sms/admin/template/recommended/%d", id), req)
|
|
}
|
|
|
|
// DeleteRecommendedTemplate 管理员删除推荐模板。
|
|
// DELETE /api/sms/admin/template/recommended/:id
|
|
func (c *Client) DeleteRecommendedTemplate(ctx context.Context, id uint) error {
|
|
_, err := del[any](c, ctx, fmt.Sprintf("/api/sms/admin/template/recommended/%d", id))
|
|
return err
|
|
}
|