package controllers
|
|
|
|
import (
|
|
"lapp_-wy/utils"
|
|
"lapp_-wy/web/middleware/jwts"
|
|
"lapp_-wy/web/models"
|
|
"lapp_-wy/web/supports"
|
|
"github.com/kataras/iris"
|
|
)
|
|
|
|
//日志列表
|
|
func Loglist(ctx iris.Context) {
|
|
user, ok := jwts.ParseToken(ctx)
|
|
utils.TrimStruct(user, *user)
|
|
if !ok {
|
|
supports.Error(ctx, iris.StatusBadRequest, supports.ParseParamsFailur, nil)
|
|
return
|
|
}
|
|
|
|
search := models.SerchData{}
|
|
search.Userid = user.Userid
|
|
search.Key = ctx.URLParam("searchKey")
|
|
search.Val = ctx.URLParam("searchValue")
|
|
|
|
var pageSize = 10
|
|
var pageIndex = 1
|
|
|
|
size := ctx.URLParam("pageSize")
|
|
if size != "" {
|
|
pageSize = utils.ValueToInt(size, 0)
|
|
}
|
|
|
|
index := ctx.URLParam("pageIndex")
|
|
if index != "" {
|
|
pageIndex = utils.ValueToInt(index, 0)
|
|
}
|
|
|
|
limit := int64(pageSize) * (int64(pageIndex)-1)
|
|
offet := int64(pageSize) * int64(pageIndex)
|
|
|
|
logs := new(models.LeitServerLog)
|
|
result, count := logs.FindLog(search, limit, offet)
|
|
res := make(map[string]interface{})
|
|
res["data"] = result
|
|
res["count"] = count
|
|
res["pageIndex"] = pageIndex
|
|
res["pageSize"] = pageSize
|
|
supports.Ok(ctx, supports.OptionSuccess, res)
|
|
}
|