28 lines
643 B
Go
28 lines
643 B
Go
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)
|
|
}
|