add line push message api
This commit is contained in:
parent
4b7149b66b
commit
3452662b72
@ -6,10 +6,32 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"git.trj.tw/golang/mtfosbot/model"
|
"git.trj.tw/golang/mtfosbot/model"
|
||||||
|
"git.trj.tw/golang/mtfosbot/module/apis/line"
|
||||||
"git.trj.tw/golang/mtfosbot/module/context"
|
"git.trj.tw/golang/mtfosbot/module/context"
|
||||||
"git.trj.tw/golang/mtfosbot/module/utils"
|
"git.trj.tw/golang/mtfosbot/module/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// PushMessage -
|
||||||
|
func PushLineMessage(c *context.Context) {
|
||||||
|
bodyData := struct {
|
||||||
|
Group string `json:"group,required"`
|
||||||
|
Message string `json:"message,required"`
|
||||||
|
}{}
|
||||||
|
|
||||||
|
err := c.BindData(&bodyData)
|
||||||
|
if err != nil {
|
||||||
|
c.DataFormat(nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
textObj := line.TextMessage{}
|
||||||
|
textObj.Text = bodyData.Message
|
||||||
|
|
||||||
|
line.PushMessage(bodyData.Group, textObj)
|
||||||
|
|
||||||
|
c.Success(nil)
|
||||||
|
}
|
||||||
|
|
||||||
// GetLineList -
|
// GetLineList -
|
||||||
func GetLineList(c *context.Context) {
|
func GetLineList(c *context.Context) {
|
||||||
ls, err := model.GetLineGroupList()
|
ls, err := model.GetLineGroupList()
|
||||||
|
@ -76,6 +76,7 @@ func SetRoutes(r *gin.Engine) {
|
|||||||
})
|
})
|
||||||
apiGroup.POST("/login", context.PatchCtx(api.UserLogin))
|
apiGroup.POST("/login", context.PatchCtx(api.UserLogin))
|
||||||
apiGroup.POST("/logout", context.PatchCtx(api.UserLogout))
|
apiGroup.POST("/logout", context.PatchCtx(api.UserLogout))
|
||||||
|
apiGroup.POST("/line/push", context.PatchCtx(api.CheckSession), context.PatchCtx(api.PushLineMessage))
|
||||||
apiGroup.GET("/line/logs", context.PatchCtx(api.CheckSession), context.PatchCtx(api.GetLineMessageLog))
|
apiGroup.GET("/line/logs", context.PatchCtx(api.CheckSession), context.PatchCtx(api.GetLineMessageLog))
|
||||||
apiGroup.GET("/line/groups", context.PatchCtx(api.CheckSession), context.PatchCtx(api.GetLineList))
|
apiGroup.GET("/line/groups", context.PatchCtx(api.CheckSession), context.PatchCtx(api.GetLineList))
|
||||||
apiGroup.GET("/line/cmds", context.PatchCtx(api.CheckSession), context.PatchCtx(api.GetCommandList))
|
apiGroup.GET("/line/cmds", context.PatchCtx(api.CheckSession), context.PatchCtx(api.GetCommandList))
|
||||||
|
Loading…
Reference in New Issue
Block a user