增加短信渠道
This commit is contained in:
@@ -10,5 +10,6 @@ var ProviderSet = wire.NewSet(
|
||||
NewExport, NewVersion, NewDictionary, NewParameter, NewAPIToken,
|
||||
NewSystemConfig, NewPublic, NewUser, NewNavigation, NewSession,
|
||||
NewIntegrationConfig,
|
||||
NewSMS,
|
||||
wire.Struct(new(Set), "*"),
|
||||
)
|
||||
|
||||
@@ -138,6 +138,8 @@ func (h *Public) InitializeDatabase(engine *gin.Engine) gin.HandlerFunc {
|
||||
Write(c, CodeSuccess, gin.H{}, "自动创建数据库成功")
|
||||
return
|
||||
}
|
||||
// Preserve the underlying error for ErrorAudit without exposing it in the response.
|
||||
_ = c.Error(err).SetType(gin.ErrorTypePrivate)
|
||||
Fail(c, "自动创建数据库失败,请查看后台日志,检查后在进行初始化")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package handler
|
||||
|
||||
type Set struct {
|
||||
SMS *SMS
|
||||
Authority *Authority
|
||||
Menu *Menu
|
||||
API *API
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"kra/internal/service/dto"
|
||||
service "kra/internal/service/integration"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type SMS struct{ service *service.SMSService }
|
||||
|
||||
func NewSMS(s *service.SMSService) *SMS { return &SMS{service: s} }
|
||||
|
||||
func (h *SMS) Send(c *gin.Context) {
|
||||
c.Request.Body = http.MaxBytesReader(c.Writer, c.Request.Body, 16<<10)
|
||||
var req dto.SMSSendRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
Fail(c, "短信参数无效")
|
||||
return
|
||||
}
|
||||
result, err := h.service.Send(c.Request.Context(), c.Param("provider"), &req)
|
||||
if err != nil {
|
||||
Fail(c, err.Error())
|
||||
return
|
||||
}
|
||||
OKWithData(c, result)
|
||||
}
|
||||
Reference in New Issue
Block a user