✨ Init
This commit is contained in:
7
plugin/email/api/enter.go
Normal file
7
plugin/email/api/enter.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package api
|
||||
|
||||
type ApiGroup struct {
|
||||
EmailApi
|
||||
}
|
||||
|
||||
var ApiGroupApp = new(ApiGroup)
|
53
plugin/email/api/sys_email.go
Normal file
53
plugin/email/api/sys_email.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
"miniapp/global"
|
||||
"miniapp/model/common/response"
|
||||
email_response "miniapp/plugin/email/model/response"
|
||||
"miniapp/plugin/email/service"
|
||||
)
|
||||
|
||||
type EmailApi struct{}
|
||||
|
||||
// EmailTest
|
||||
// @Tags System
|
||||
// @Summary 发送测试邮件
|
||||
// @Security ApiKeyAuth
|
||||
// @Produce application/json
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"发送成功"}"
|
||||
// @Router /email/emailTest [post]
|
||||
func (s *EmailApi) EmailTest(c *gin.Context) {
|
||||
err := service.ServiceGroupApp.EmailTest()
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("发送失败!", zap.Error(err))
|
||||
response.FailWithMessage("发送失败", c)
|
||||
return
|
||||
}
|
||||
response.OkWithMessage("发送成功", c)
|
||||
}
|
||||
|
||||
// SendEmail
|
||||
// @Tags System
|
||||
// @Summary 发送邮件
|
||||
// @Security ApiKeyAuth
|
||||
// @Produce application/json
|
||||
// @Param data body email_response.Email true "发送邮件必须的参数"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"发送成功"}"
|
||||
// @Router /email/sendEmail [post]
|
||||
func (s *EmailApi) SendEmail(c *gin.Context) {
|
||||
var email email_response.Email
|
||||
err := c.ShouldBindJSON(&email)
|
||||
if err != nil {
|
||||
response.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
err = service.ServiceGroupApp.SendEmail(email.To, email.Subject, email.Body)
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("发送失败!", zap.Error(err))
|
||||
response.FailWithMessage("发送失败", c)
|
||||
return
|
||||
}
|
||||
response.OkWithMessage("发送成功", c)
|
||||
}
|
Reference in New Issue
Block a user