kefu/controller/log.go

41 lines
776 B
Go
Raw Permalink Normal View History

2024-12-10 02:50:12 +00:00
package controller
import (
"github.com/gin-gonic/gin"
"kefu/models"
"strconv"
)
func GetLogList(c *gin.Context) {
roleId, _ := c.Get("role_id")
entId, _ := c.Get("ent_id")
page, _ := strconv.Atoi(c.Query("page"))
if page <= 0 {
page = 1
}
pagesize, _ := strconv.Atoi(c.Query("pagesize"))
if pagesize <= 0 || pagesize > 50 {
pagesize = 10
}
search := "1=1 "
var args = []interface{}{}
if roleId.(float64) != 1 {
search += "and pid = ? "
args = append(args, entId)
}
count := models.CountFlyLog(search, args...)
list := models.FindFlyLogs(page, pagesize, search, args...)
c.JSON(200, gin.H{
"code": 200,
"msg": "ok",
"result": gin.H{
"list": list,
"count": count,
"pagesize": uint(pagesize),
"page": page,
},
})
}