refactor: split backend transport and domain modules

This commit is contained in:
2026-08-14 01:04:21 +08:00
parent acba9624d7
commit e6775f0966
59 changed files with 2733 additions and 1963 deletions
+34
View File
@@ -0,0 +1,34 @@
package handler
import (
"kra/internal/server/httpx"
"kra/internal/service"
"kra/internal/service/dto"
"github.com/gin-gonic/gin"
)
type Email struct{ service *service.EmailService }
func NewEmail(service *service.EmailService) *Email { return &Email{service: service} }
func (h *Email) Test(c *gin.Context) {
if err := h.service.Test(c.Request.Context()); err != nil {
httpx.Fail(c, "发送失败:"+err.Error())
return
}
httpx.Write(c, httpx.CodeSuccess, gin.H{}, "发送成功")
}
func (h *Email) Send(c *gin.Context) {
var req dto.SendEmailRequest
if c.ShouldBindJSON(&req) != nil {
httpx.Fail(c, "参数错误")
return
}
if err := h.service.Send(c.Request.Context(), req.To, req.Subject, req.Body); err != nil {
httpx.Fail(c, "发送失败:"+err.Error())
return
}
httpx.Write(c, httpx.CodeSuccess, gin.H{}, "发送成功")
}