增加短信渠道
This commit is contained in:
@@ -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