Files
oci-portal/internal/api/systemlog.go
T
2026-07-09 19:18:04 +08:00

38 lines
953 B
Go

package api
import (
"net/http"
"strconv"
"github.com/gin-gonic/gin"
"oci-portal/internal/service"
)
// systemLogHandler 处理面板系统操作日志的查询请求。
type systemLogHandler struct {
svc *service.SystemLogService
}
// list 分页倒序返回系统日志,支持路径 / 用户名关键字模糊过滤。
//
// @Summary 系统操作日志列表
// @Tags 设置
// @Success 200 {object} map[string]any "items 与 total"
// @Security BearerAuth
// @Router /api/v1/system-logs [get]
func (h *systemLogHandler) list(c *gin.Context) {
page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
pageSize, _ := strconv.Atoi(c.DefaultQuery("pageSize", "20"))
items, total, err := h.svc.List(c.Request.Context(), service.SystemLogQuery{
Page: page,
PageSize: pageSize,
Keyword: c.Query("keyword"),
})
if err != nil {
respondError(c, err)
return
}
c.JSON(http.StatusOK, gin.H{"items": items, "total": total})
}