refactor: split backend transport and domain modules
This commit is contained in:
@@ -13,33 +13,6 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func registerEmailRoutes(group *gin.RouterGroup, svc *service.EmailService) {
|
||||
email := group.Group("/email")
|
||||
email.POST("/emailTest", func(c *gin.Context) {
|
||||
if err := svc.Test(c.Request.Context()); err != nil {
|
||||
fail(c, "发送失败:"+err.Error())
|
||||
return
|
||||
}
|
||||
writeResult(c, codeSuccess, gin.H{}, "发送成功")
|
||||
})
|
||||
email.POST("/sendEmail", func(c *gin.Context) {
|
||||
var req struct {
|
||||
To string `json:"to"`
|
||||
Subject string `json:"subject"`
|
||||
Body string `json:"body"`
|
||||
}
|
||||
if c.ShouldBindJSON(&req) != nil {
|
||||
fail(c, "参数错误")
|
||||
return
|
||||
}
|
||||
if err := svc.Send(c.Request.Context(), req.To, req.Subject, req.Body); err != nil {
|
||||
fail(c, "发送失败:"+err.Error())
|
||||
return
|
||||
}
|
||||
writeResult(c, codeSuccess, gin.H{}, "发送成功")
|
||||
})
|
||||
}
|
||||
|
||||
func emailErrorAlert(svc *service.EmailService, logger *slog.Logger) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
if strings.Contains(c.Request.URL.Path, "/email/") {
|
||||
|
||||
Reference in New Issue
Block a user