35 lines
666 B
Go
35 lines
666 B
Go
|
package api
|
||
|
|
||
|
import (
|
||
|
"github.com/gin-gonic/gin"
|
||
|
"wireguard-dashboard/http/param"
|
||
|
"wireguard-dashboard/repository"
|
||
|
"wireguard-dashboard/utils"
|
||
|
)
|
||
|
|
||
|
type clients struct{}
|
||
|
|
||
|
func Client() clients {
|
||
|
return clients{}
|
||
|
}
|
||
|
|
||
|
// List
|
||
|
// @description: 客户端列表
|
||
|
// @receiver clients
|
||
|
// @param c
|
||
|
func (clients) List(c *gin.Context) {
|
||
|
var p param.ClientList
|
||
|
if err := c.ShouldBind(&p); err != nil {
|
||
|
utils.GinResponse(c).FailedWithErr("参数错误", err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
data, total, err := repository.Client().List(p)
|
||
|
if err != nil {
|
||
|
utils.GinResponse(c).FailedWithMsg("获取失败")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
utils.GinResponse(c).OkWithPage(data, total, p.Current, p.Size)
|
||
|
}
|