feat: merge sms branch,add DuanXinBao sms service implemetation

This commit is contained in:
RockYang
2024-01-23 16:16:47 +08:00
17 changed files with 194 additions and 35 deletions

View File

@@ -507,7 +507,7 @@ func (h *ChatHandler) doRequest(ctx context.Context, req types.ApiRequest, platf
} else {
client = http.DefaultClient
}
logger.Debugf("Sending %s request, ApiURL:%s, ApiKey:%s, PROXY: %s, Model: %s", platform, apiURL, apiKey.Value, proxyURL, req.Model)
logger.Debugf("Sending %s request, ApiURL:%s, Password:%s, PROXY: %s, Model: %s", platform, apiURL, apiKey.Value, proxyURL, req.Model)
switch platform {
case types.Azure:
request.Header.Set("api-key", apiKey.Value)

View File

@@ -247,7 +247,7 @@ func (h *FunctionHandler) Dall3(c *gin.Context) {
} else {
request = req.C().R()
}
logger.Debugf("Sending %s request, ApiURL:%s, ApiKey:%s, PROXY: %s", apiKey.Platform, apiKey.ApiURL, apiKey.Value, h.proxyURL)
logger.Debugf("Sending %s request, ApiURL:%s, Password:%s, PROXY: %s", apiKey.Platform, apiKey.ApiURL, apiKey.Value, h.proxyURL)
r, err := request.SetHeader("Content-Type", "application/json").
SetHeader("Authorization", "Bearer "+apiKey.Value).
SetBody(imgReq{

View File

@@ -311,7 +311,7 @@ func (h *PaymentHandler) notify(orderNo string, tradeNo string) error {
user.ImgCalls += remark.ImgCalls
}
} else { // 非 VIP 用户
} else { // 非 VIP 用户
if remark.Days > 0 { // vip 套餐days > 0, calls == 0
user.ExpiredTime = time.Now().AddDate(0, 0, remark.Days).Unix()
user.Calls += h.App.SysConfig.VipMonthCalls

View File

@@ -4,6 +4,7 @@ import (
"chatplus/core"
"chatplus/core/types"
"chatplus/service"
"chatplus/service/sms"
"chatplus/utils"
"chatplus/utils/resp"
"strings"
@@ -17,7 +18,7 @@ const CodeStorePrefix = "/verify/codes/"
type SmsHandler struct {
BaseHandler
redis *redis.Client
sms *service.AliYunSmsService
sms *sms.ServiceManager
smtp *service.SmtpService
captcha *service.CaptchaService
}
@@ -25,7 +26,7 @@ type SmsHandler struct {
func NewSmsHandler(
app *core.AppServer,
client *redis.Client,
sms *service.AliYunSmsService,
sms *sms.ServiceManager,
smtp *service.SmtpService,
captcha *service.CaptchaService) *SmsHandler {
handler := &SmsHandler{redis: client, sms: sms, captcha: captcha, smtp: smtp}
@@ -63,7 +64,8 @@ func (h *SmsHandler) SendCode(c *gin.Context) {
resp.ERROR(c, "系统已禁用手机号注册!")
return
}
err = h.sms.SendVerifyCode(data.Receiver, code)
err = h.sms.GetService().SendVerifyCode(data.Receiver, code)
}
if err != nil {
resp.ERROR(c, err.Error())