wireguard-dashboard/http/api/dashboard.go

41 lines
797 B
Go
Raw Normal View History

2024-08-08 17:26:50 +08:00
package api
import (
"fmt"
"github.com/gin-gonic/gin"
"wireguard-ui/http/param"
"wireguard-ui/http/response"
"wireguard-ui/http/vo"
"wireguard-ui/service"
)
type DashboardApi struct{}
func Dashboard() DashboardApi {
return DashboardApi{}
}
// List
// @description: 操作日志
// @receiver DashboardApi
// @param c
func (DashboardApi) List(c *gin.Context) {
var p param.Page
if err := c.ShouldBind(&p); err != nil {
response.R(c).Validator(err)
return
}
var loginUser *vo.User
if loginUser = GetCurrentLoginUser(c); c.IsAborted() {
return
}
data, total, err := service.Log().List(p, loginUser)
if err != nil {
response.R(c).FailedWithError(fmt.Errorf("获取操作日志失败: %v", err.Error()))
return
}
response.R(c).Paginate(data, total, p.Current, p.Size)
}