package v1

import (
	"cmdb-backend/models"
	"cmdb-backend/pkg/utils"
	"github.com/gin-gonic/gin"
	"net/http"
	"strconv"
)

func GetOperatorLog(c *gin.Context) {
	opType := c.Query("type")
	opName := c.Query("operator_name")
	pageNum, _ := strconv.Atoi(c.Query("page_number"))
	pageSize, _ := strconv.Atoi(c.Query("page_size"))

	opRecords := models.GetOperatorLog(opType, opName, utils.GetPage(pageNum, pageSize), pageSize)
	total := models.GetOperatorLogTotal(opType, opName)
	c.JSON(http.StatusOK, utils.AmisResponse{
		Data: map[string]interface{}{
			"items": opRecords,
			"total": total,
		},
	})
}
