xlogControllers.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package controllers
  2. import (
  3. "fwh-toolbox-server/logger"
  4. "fwh-toolbox-server/services"
  5. "strconv"
  6. "github.com/gofiber/fiber/v2"
  7. )
  8. // 获取站点分析管理名称表
  9. // /xlog/manage/siteList
  10. func GetXlogManageSiteList(c *fiber.Ctx) error {
  11. pageInt, _ := strconv.Atoi(c.Query("pageNum", "1"))
  12. sizeInt, _ := strconv.Atoi(c.Query("pageSize", "20"))
  13. if pageInt <= 0 || sizeInt <= 0 {
  14. return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
  15. "code": 400,
  16. "message": "Invalid request para",
  17. })
  18. }
  19. listPage := services.GetXlogManageList(uint(pageInt), uint(sizeInt))
  20. return JSONResponse(c, 0, "success", listPage)
  21. }
  22. // 发送命令
  23. // /xlog/terminal/:uuid
  24. func PostXlogTerminalSend(c *fiber.Ctx) error {
  25. uuid := c.Params("uuid")
  26. logger.Std.Println(uuid)
  27. var body string
  28. if err := c.BodyParser(&body); err != nil {
  29. return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
  30. "code": 400,
  31. "message": "Invalid request body",
  32. })
  33. }
  34. data, err := services.SendXlogCmd(uuid, body)
  35. if err != nil {
  36. return JSONResponseNoData(c, 500, err.Error())
  37. }
  38. return JSONResponse(c, 0, "success", data)
  39. }