This commit is contained in:
hermes-$(hostname) committed 2026-07-08 08:53:48 +00:00
1 parent f5cf3f4440
commit 0fcdbc5f6c
29 files changed
+773 -264

No files matched your search

+21 -7
View File
@@ -13,20 +13,34 @@ import (
func ListAuditLogs(c *gin.Context) {
page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
pageSize, _ := strconv.Atoi(c.DefaultQuery("page_size", "20"))
if page < 1 { page = 1 }
if pageSize < 1 || pageSize > 100 { pageSize = 20 }
if page < 1 {
page = 1
}
if pageSize < 1 || pageSize > 100 {
pageSize = 20
}
var total int64
model.DB.Model(&model.AuditLog{}).Count(&total)
query := model.DB.Model(&model.AuditLog{})
if action := c.Query("action"); action != "" {
query = query.Where("action = ?", action)
}
if targetType := c.Query("target_type"); targetType != "" {
query = query.Where("target_type = ?", targetType)
}
if resultStatus := c.Query("result_status"); resultStatus != "" {
query = query.Where("result_status = ?", resultStatus)
}
query.Count(&total)
var logs []model.AuditLog
offset := (page - 1) * pageSize
model.DB.Order("id DESC").Offset(offset).Limit(pageSize).Find(&logs)
query.Order("id DESC").Offset(offset).Limit(pageSize).Find(&logs)
c.JSON(http.StatusOK, gin.H{
"items": logs,
"total": total,
"page": page,
"items": logs,
"total": total,
"page": page,
"page_size": pageSize,
})
}