1
0
mirror of https://github.com/mgerb/go-discord-bot synced 2026-01-11 09:32:50 +00:00

feat: add user event log to admin page

This commit is contained in:
2019-08-24 12:47:53 -05:00
parent 72ba1e5621
commit 55a4bb73af
18 changed files with 230 additions and 26 deletions

View File

@@ -0,0 +1,33 @@
package routes
import (
"strconv"
"github.com/gin-gonic/gin"
"github.com/mgerb/go-discord-bot/server/db"
"github.com/mgerb/go-discord-bot/server/webserver/middleware"
"github.com/mgerb/go-discord-bot/server/webserver/model"
"github.com/mgerb/go-discord-bot/server/webserver/response"
)
// AddUserEventLogRoutes -
func AddUserEventLogRoutes(group *gin.RouterGroup) {
group.GET("/user-event-log", middleware.AuthorizedJWT(), middleware.AuthPermissions(middleware.PermAdmin), listEventLogHandler)
}
func listEventLogHandler(c *gin.Context) {
page, err := strconv.Atoi(c.Query("page"))
if err != nil {
page = 0
}
userEventLogs, err := model.UserEventLogGet(db.GetConn(), page)
if err != nil {
response.InternalError(c, err)
} else {
response.Success(c, userEventLogs)
}
}