增加短信渠道

This commit is contained in:
Yvan
2026-09-29 18:15:35 +08:00
parent a16b8f8e89
commit 89cc7761b5
38 changed files with 1469 additions and 39 deletions
+1
View File
@@ -10,5 +10,6 @@ var ProviderSet = wire.NewSet(
NewExport, NewVersion, NewDictionary, NewParameter, NewAPIToken,
NewSystemConfig, NewPublic, NewUser, NewNavigation, NewSession,
NewIntegrationConfig,
NewSMS,
wire.Struct(new(Set), "*"),
)
+2
View File
@@ -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
View File
@@ -1,6 +1,7 @@
package handler
type Set struct {
SMS *SMS
Authority *Authority
Menu *Menu
API *API
+27
View File
@@ -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)
}