f004408ca0
Co-authored-by: Cursor <cursoragent@cursor.com>
316 lines
9.9 KiB
Go
316 lines
9.9 KiB
Go
package smscli
|
|
|
|
import "time"
|
|
|
|
// PaginationResult 分页返回。
|
|
type PaginationResult[T any] struct {
|
|
List []T `json:"list"`
|
|
Total int64 `json:"total"`
|
|
Page int `json:"page"`
|
|
}
|
|
|
|
// PaginationQuery 分页参数。
|
|
type PaginationQuery struct {
|
|
Page int `json:"page,omitempty"`
|
|
PageSize int `json:"page_size,omitempty"`
|
|
}
|
|
|
|
// GormModel 对应后端 gorm.Model。
|
|
type GormModel struct {
|
|
ID uint `json:"ID"`
|
|
CreatedAt time.Time `json:"CreatedAt"`
|
|
UpdatedAt time.Time `json:"UpdatedAt"`
|
|
DeletedAt *time.Time `json:"DeletedAt"`
|
|
}
|
|
|
|
const (
|
|
ReviewStatusDraft = 0
|
|
ReviewStatusReviewing = 1
|
|
ReviewStatusApproved = 2
|
|
ReviewStatusRejected = 3
|
|
)
|
|
|
|
const (
|
|
QuotaTypeLongTerm = 1
|
|
QuotaTypeShortTerm = 2
|
|
QuotaTypeCycle = 3
|
|
)
|
|
|
|
const (
|
|
SendStatusPending = 0
|
|
SendStatusSubmitted = 1
|
|
SendStatusSuccess = 2
|
|
SendStatusFailed = 3
|
|
SendStatusRejected = 4
|
|
)
|
|
|
|
const (
|
|
AuthTypeAuthToken = 1
|
|
AuthTypeServiceToken = 2
|
|
AuthTypeUserToken = 3
|
|
)
|
|
|
|
// SmsSignature 短信签名。Status: 0=草稿 1=审核中 2=已通过 3=已驳回
|
|
type SmsSignature struct {
|
|
GormModel
|
|
UserID uint `json:"user_id"`
|
|
Title string `json:"title"`
|
|
ApplicantName string `json:"applicant_name"`
|
|
ApplicantIDCard string `json:"applicant_id_card"`
|
|
ApplicantCompany string `json:"applicant_company"`
|
|
LicenseURL string `json:"license_url"`
|
|
Status int8 `json:"status"`
|
|
RejectReason string `json:"reject_reason"`
|
|
ReviewedBy *uint `json:"reviewed_by"`
|
|
ReviewedAt *time.Time `json:"reviewed_at"`
|
|
}
|
|
|
|
type AdminCreateSignatureReq struct {
|
|
UserID uint `json:"user_id"`
|
|
Title string `json:"title"`
|
|
ApplicantName string `json:"applicant_name"`
|
|
ApplicantIDCard string `json:"applicant_id_card,omitempty"`
|
|
ApplicantCompany string `json:"applicant_company,omitempty"`
|
|
LicenseURL string `json:"license_url,omitempty"`
|
|
}
|
|
|
|
type AdminUpdateSignatureReq struct {
|
|
Title string `json:"title,omitempty"`
|
|
ApplicantName string `json:"applicant_name,omitempty"`
|
|
ApplicantIDCard string `json:"applicant_id_card,omitempty"`
|
|
ApplicantCompany string `json:"applicant_company,omitempty"`
|
|
LicenseURL string `json:"license_url,omitempty"`
|
|
Status *int8 `json:"status,omitempty"`
|
|
}
|
|
|
|
type RejectReq struct {
|
|
RejectReason string `json:"reject_reason"`
|
|
}
|
|
|
|
type SignatureListQuery struct {
|
|
PaginationQuery
|
|
UserID *uint `json:"user_id,omitempty"`
|
|
Status *int8 `json:"status,omitempty"`
|
|
}
|
|
|
|
type TemplateParam struct {
|
|
Key string `json:"key"`
|
|
Type string `json:"type"`
|
|
MaxLen int `json:"max_len"`
|
|
}
|
|
|
|
// SmsTemplate 短信模板。Status: 0=草稿 1=审核中 2=已通过 3=已驳回
|
|
type SmsTemplate struct {
|
|
GormModel
|
|
UserID uint `json:"user_id"`
|
|
Name string `json:"name"`
|
|
Content string `json:"content"`
|
|
Params []TemplateParam `json:"params"`
|
|
RecommendedID *uint `json:"recommended_id"`
|
|
IsModified int8 `json:"is_modified"`
|
|
Status int8 `json:"status"`
|
|
RejectReason string `json:"reject_reason"`
|
|
ReviewedBy *uint `json:"reviewed_by"`
|
|
ReviewedAt *time.Time `json:"reviewed_at"`
|
|
}
|
|
|
|
type AdminCreateTemplateReq struct {
|
|
UserID uint `json:"user_id"`
|
|
Name string `json:"name"`
|
|
Content string `json:"content"`
|
|
Params []TemplateParam `json:"params,omitempty"`
|
|
RecommendedID *uint `json:"recommended_id,omitempty"`
|
|
}
|
|
|
|
type AdminUpdateTemplateReq struct {
|
|
Name string `json:"name,omitempty"`
|
|
Content string `json:"content,omitempty"`
|
|
Params []TemplateParam `json:"params,omitempty"`
|
|
Status *int8 `json:"status,omitempty"`
|
|
}
|
|
|
|
type TemplateListQuery struct {
|
|
PaginationQuery
|
|
UserID *uint `json:"user_id,omitempty"`
|
|
Status *int8 `json:"status,omitempty"`
|
|
}
|
|
|
|
type SmsRecommendedTemplate struct {
|
|
ID uint `json:"id"`
|
|
Name string `json:"name"`
|
|
Content string `json:"content"`
|
|
Params []TemplateParam `json:"params"`
|
|
Category string `json:"category"`
|
|
CreatedBy uint `json:"created_by"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type CreateRecommendedTemplateReq struct {
|
|
Name string `json:"name"`
|
|
Content string `json:"content"`
|
|
Params []TemplateParam `json:"params,omitempty"`
|
|
Category string `json:"category,omitempty"`
|
|
}
|
|
|
|
type UpdateRecommendedTemplateReq struct {
|
|
Name string `json:"name,omitempty"`
|
|
Content string `json:"content,omitempty"`
|
|
Params []TemplateParam `json:"params,omitempty"`
|
|
Category string `json:"category,omitempty"`
|
|
}
|
|
|
|
type SmsUserToken struct {
|
|
GormModel
|
|
UserID uint `json:"user_id"`
|
|
Token string `json:"token"`
|
|
Name string `json:"name"`
|
|
QuotaLimit *int `json:"quota_limit"`
|
|
QuotaUsed int `json:"quota_used"`
|
|
TemplateIDs []uint `json:"template_ids"`
|
|
ExpireAt *time.Time `json:"expire_at"`
|
|
IsActive int8 `json:"is_active"`
|
|
LastUsedAt *time.Time `json:"last_used_at"`
|
|
LastUsedIP string `json:"last_used_ip"`
|
|
}
|
|
|
|
type UpdateTokenReq struct {
|
|
Name string `json:"name,omitempty"`
|
|
QuotaLimit *int `json:"quota_limit,omitempty"`
|
|
TemplateIDs []uint `json:"template_ids,omitempty"`
|
|
ExpireAt string `json:"expire_at,omitempty"`
|
|
}
|
|
|
|
type AdminCreateTokenReq struct {
|
|
UserID uint `json:"user_id"`
|
|
Name string `json:"name,omitempty"`
|
|
QuotaLimit *int `json:"quota_limit,omitempty"`
|
|
TemplateIDs []uint `json:"template_ids,omitempty"`
|
|
ExpireAt string `json:"expire_at,omitempty"`
|
|
}
|
|
|
|
type TokenListQuery struct {
|
|
PaginationQuery
|
|
UserID *uint `json:"user_id,omitempty"`
|
|
Status *int8 `json:"status,omitempty"`
|
|
}
|
|
|
|
// SmsQuota 短信额度。QuotaType: 1=长期 2=短期 3=周期
|
|
type SmsQuota struct {
|
|
GormModel
|
|
UserID uint `json:"user_id"`
|
|
QuotaType int8 `json:"quota_type"`
|
|
Total int `json:"total"`
|
|
Used int `json:"used"`
|
|
ExpireAt *time.Time `json:"expire_at"`
|
|
CycleUnit string `json:"cycle_unit"`
|
|
CycleValue int `json:"cycle_value"`
|
|
NextRefreshAt *time.Time `json:"next_refresh_at"`
|
|
IsActive int8 `json:"is_active"`
|
|
}
|
|
|
|
type CreateQuotaReq struct {
|
|
UserID uint `json:"user_id"`
|
|
QuotaType int8 `json:"quota_type"`
|
|
Total int `json:"total"`
|
|
ExpireAt string `json:"expire_at,omitempty"`
|
|
CycleUnit string `json:"cycle_unit,omitempty"`
|
|
CycleValue int `json:"cycle_value,omitempty"`
|
|
}
|
|
|
|
type UpdateQuotaReq struct {
|
|
Total *int `json:"total,omitempty"`
|
|
ExpireAt string `json:"expire_at,omitempty"`
|
|
CycleUnit string `json:"cycle_unit,omitempty"`
|
|
CycleValue *int `json:"cycle_value,omitempty"`
|
|
IsActive *int8 `json:"is_active,omitempty"`
|
|
}
|
|
|
|
type QuotaListQuery struct {
|
|
PaginationQuery
|
|
UserID *uint `json:"user_id,omitempty"`
|
|
}
|
|
|
|
type QuotaSummary struct {
|
|
TotalRemaining int `json:"total_remaining"`
|
|
LongTerm int `json:"long_term"`
|
|
ShortTerm int `json:"short_term"`
|
|
Cycle int `json:"cycle"`
|
|
}
|
|
|
|
type SendBatchReq struct {
|
|
UserID uint `json:"user_id,omitempty"`
|
|
SignatureID uint `json:"signature_id"`
|
|
TemplateID uint `json:"template_id"`
|
|
Params map[string]string `json:"params,omitempty"`
|
|
Phones []string `json:"phones"`
|
|
Adapter string `json:"adapter,omitempty"`
|
|
}
|
|
|
|
type SendMultiReq struct {
|
|
UserID uint `json:"user_id,omitempty"`
|
|
SignatureID uint `json:"signature_id"`
|
|
TemplateID uint `json:"template_id"`
|
|
Items []SendMultiItem `json:"items"`
|
|
Adapter string `json:"adapter,omitempty"`
|
|
}
|
|
|
|
type SendMultiItem struct {
|
|
Phone string `json:"phone"`
|
|
Params map[string]string `json:"params,omitempty"`
|
|
}
|
|
|
|
type SendResp struct {
|
|
RecordID uint `json:"record_id"`
|
|
MsgID string `json:"msg_id"`
|
|
FeeCount int `json:"fee_count"`
|
|
PhoneCount int `json:"phone_count"`
|
|
}
|
|
|
|
type SmsSendRecord struct {
|
|
ID uint `json:"id"`
|
|
UserID uint `json:"user_id"`
|
|
AuthType int8 `json:"auth_type"`
|
|
TokenID *uint `json:"token_id"`
|
|
SignatureID uint `json:"signature_id"`
|
|
TemplateID uint `json:"template_id"`
|
|
SendType int8 `json:"send_type"`
|
|
Params map[string]interface{} `json:"params"`
|
|
FinalContent string `json:"final_content"`
|
|
PhoneNumbers []string `json:"phone_numbers"`
|
|
SourceIP string `json:"source_ip"`
|
|
AdapterName string `json:"adapter_name"`
|
|
AdapterMsgID string `json:"adapter_msg_id"`
|
|
Status int8 `json:"status"`
|
|
CallbackRaw map[string]interface{} `json:"callback_raw"`
|
|
FeeCount int `json:"fee_count"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type SendRecordQuery struct {
|
|
PaginationQuery
|
|
SignatureID uint `json:"signature_id,omitempty"`
|
|
TemplateID uint `json:"template_id,omitempty"`
|
|
Phone string `json:"phone,omitempty"`
|
|
Status *int `json:"status,omitempty"`
|
|
StartTime string `json:"start_time,omitempty"`
|
|
EndTime string `json:"end_time,omitempty"`
|
|
}
|
|
|
|
type AdminSendRecordQuery struct {
|
|
PaginationQuery
|
|
UserID *uint `json:"user_id,omitempty"`
|
|
SignatureID uint `json:"signature_id,omitempty"`
|
|
TemplateID uint `json:"template_id,omitempty"`
|
|
Phone string `json:"phone,omitempty"`
|
|
Status *int `json:"status,omitempty"`
|
|
StartTime string `json:"start_time,omitempty"`
|
|
EndTime string `json:"end_time,omitempty"`
|
|
}
|
|
|
|
type AdapterBalance struct {
|
|
Adapter string `json:"adapter"`
|
|
Balance interface{} `json:"balance"`
|
|
}
|