规范化插件代码

This commit is contained in:
蒋吉兆
2021-08-28 12:38:26 +08:00
parent f5e0268d0f
commit 5964d70023
9 changed files with 187 additions and 26 deletions

View File

@@ -3,6 +3,7 @@ package api
import (
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
notify_response "github.com/flipped-aurora/gin-vue-admin/server/plugin/notify/model/response"
"github.com/flipped-aurora/gin-vue-admin/server/plugin/notify/service"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
@@ -11,9 +12,53 @@ import (
type Api struct {
}
//
// @Tags Notify
// @Summary 发送文字消息接口
// @Security ApiKeyAuth
// @Produce application/json
// @Param data body notify_response.TextNotify true "发送文字消息的参数"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"发送成功"}"
// @Router /notify/sendTextMessage [post]
func (s *Api) SendTextMessage(c *gin.Context) {
if err := service.ServiceGroupApp.SendTextMessage("notify", []string{}, false); err != nil {
var textNotify notify_response.TextNotify
_ = c.ShouldBindJSON(&textNotify)
if err := service.ServiceGroupApp.SendTextMessage(textNotify.Content, textNotify.AtMobiles, textNotify.IsAtAll); err != nil {
global.GVA_LOG.Error("发送失败!", zap.Any("err", err))
response.FailWithMessage("发送失败", c)
} else {
response.OkWithData("发送成功", c)
}
}
// @Tags Notify
// @Summary 发送图文链接消息接口
// @Security ApiKeyAuth
// @Produce application/json
// @Param data body notify_response.LinkNotify true "发送图文链接消息的参数"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"发送成功"}"
// @Router /notify/sendLinkMessage [post]
func (s *Api) SendLinkMessage(c *gin.Context) {
var linkNotify notify_response.LinkNotify
_ = c.ShouldBindJSON(&linkNotify)
if err := service.ServiceGroupApp.SendLinkMessage(linkNotify.Content, linkNotify.Title, linkNotify.PicUrl, linkNotify.MessageUrl); err != nil {
global.GVA_LOG.Error("发送失败!", zap.Any("err", err))
response.FailWithMessage("发送失败", c)
} else {
response.OkWithData("发送成功", c)
}
}
// @Tags Notify
// @Summary 发送markdown消息接口
// @Security ApiKeyAuth
// @Produce application/json
// @Param data body notify_response.MarkdownNotify true "发送markdown消息的参数"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"发送成功"}"
// @Router /notify/sendMarkdownMessage [post]
func (s *Api) SendMarkdownMessage(c *gin.Context) {
var markdownNotify notify_response.MarkdownNotify
_ = c.ShouldBindJSON(&markdownNotify)
if err := service.ServiceGroupApp.SendMarkdownMessage(markdownNotify.Content, markdownNotify.Title, markdownNotify.AtMobiles, markdownNotify.IsAtAll); err != nil {
global.GVA_LOG.Error("发送失败!", zap.Any("err", err))
response.FailWithMessage("发送失败", c)
} else {