初始化
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
package interfaces
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"code.yun.ink/pkg/smsx/entity"
|
||||
"github.com/yuninks/loggerx"
|
||||
)
|
||||
|
||||
type Smsx interface {
|
||||
InitSmsx(ctx context.Context, params entity.SmsConfigData,logger loggerx.LoggerInterface) (Smsx, error)
|
||||
// Send 发送短信
|
||||
// templateId: 短信模板ID
|
||||
// phone: 手机号(格式:+86xxx)
|
||||
// params: 模板参数
|
||||
Send(ctx context.Context, templateId string, phone string, params []SmsSendParam) error
|
||||
|
||||
// GetTemp 获取所有短信模板
|
||||
GetTemp(ctx context.Context) ([]TemplateInfo, error)
|
||||
|
||||
// TempDel 删除短信模板
|
||||
TempDel(ctx context.Context, tempId string) error
|
||||
}
|
||||
|
||||
type SmsSendParam struct {
|
||||
Field string `json:"field"` // 字段
|
||||
Value string `json:"value"` // 值
|
||||
}
|
||||
|
||||
type TemplateInfo struct {
|
||||
TempId string `json:"temp_id"` // 模板ID
|
||||
TempName string `json:"temp_name"` // 模板名称
|
||||
TempType entity.SmsTemplateType `json:"temp_type"` // 模板类型
|
||||
TempRange entity.SmsTemplateRange `json:"temp_range"` // 作用范围
|
||||
Content string `json:"content"` // 内容
|
||||
Status entity.SmsTemplateStatus `json:"status"` // 状态 (1.通过审核 2.审核中 3.未通过审核 4.取消审核)
|
||||
Params []entity.SmsTemplateParam `json:"params"` // 模板参数
|
||||
}
|
||||
|
||||
// 默认的实现
|
||||
type DefaultSmsx struct{}
|
||||
|
||||
func (l *DefaultSmsx) InitSmsx(ctx context.Context, params entity.SmsConfigData,logger loggerx.LoggerInterface) (Smsx, error) {
|
||||
return &DefaultSmsx{}, nil
|
||||
}
|
||||
|
||||
func (l *DefaultSmsx) Send(ctx context.Context, templateId string, phone string, params []SmsSendParam) error {
|
||||
return errors.New("not implemented")
|
||||
}
|
||||
|
||||
// GetTemp 获取模板
|
||||
func (l *DefaultSmsx) GetTemp(ctx context.Context) ([]TemplateInfo, error) {
|
||||
return nil, errors.New("not implemented")
|
||||
}
|
||||
|
||||
// TempDel 删除模板
|
||||
func (l *DefaultSmsx) TempDel(ctx context.Context, tempId string) error {
|
||||
return errors.New("not implemented")
|
||||
}
|
||||
Reference in New Issue
Block a user