mirror of https://github.com/go-sonic/sonic.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
672 B
Go
28 lines
672 B
Go
package admin
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/go-sonic/sonic/model/param"
|
|
"github.com/go-sonic/sonic/service"
|
|
"github.com/go-sonic/sonic/util/xerr"
|
|
)
|
|
|
|
type EmailHandler struct {
|
|
EmailService service.EmailService
|
|
}
|
|
|
|
func NewEmailHandler(emailService service.EmailService) *EmailHandler {
|
|
return &EmailHandler{
|
|
EmailService: emailService,
|
|
}
|
|
}
|
|
|
|
func (e *EmailHandler) Test(ctx *gin.Context) (interface{}, error) {
|
|
p := ¶m.TestEmail{}
|
|
if err := ctx.ShouldBindJSON(p); err != nil {
|
|
return nil, xerr.WithStatus(err, xerr.StatusBadRequest).WithMsg("param error ")
|
|
}
|
|
return nil, e.EmailService.SendTextEmail(ctx, p.To, p.Subject, p.Content)
|
|
}
|