43 lines
898 B
Go
43 lines
898 B
Go
|
package api
|
||
|
|
||
|
import (
|
||
|
"github.com/gin-gonic/gin"
|
||
|
"wireguard-dashboard/http/param"
|
||
|
"wireguard-dashboard/model/entity"
|
||
|
"wireguard-dashboard/repository"
|
||
|
"wireguard-dashboard/utils"
|
||
|
)
|
||
|
|
||
|
type dashboard struct{}
|
||
|
|
||
|
func Dashboard() dashboard {
|
||
|
return dashboard{}
|
||
|
}
|
||
|
|
||
|
// List
|
||
|
// @description: 操作日志分页列表
|
||
|
// @receiver d
|
||
|
// @param c
|
||
|
func (d dashboard) List(c *gin.Context) {
|
||
|
var p param.OnlyPage
|
||
|
if err := c.ShouldBind(&p); err != nil {
|
||
|
utils.GinResponse(c).FailedWithErr("参数错误", err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// 如果不是超级管理员只能看自己的
|
||
|
userInfo, ok := c.Get("user")
|
||
|
if !ok {
|
||
|
utils.GinResponse(c).AuthorizationFailed()
|
||
|
return
|
||
|
}
|
||
|
|
||
|
data, count, err := repository.SystemLog().List(p, userInfo.(*entity.User))
|
||
|
if err != nil {
|
||
|
utils.GinResponse(c).FailedWithErr("获取失败", err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
utils.GinResponse(c).OkWithPage(data, count, p.Current, p.Size)
|
||
|
}
|