xlogControllers.go 904 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package controllers
  2. import (
  3. "fmt"
  4. "fwh-toolbox-server/networkEvents"
  5. )
  6. type XlogManageInfo = networkEvents.SiteInfo
  7. type XlogManagePage = ResPage[XlogManageInfo]
  8. func GetXlogManageList(page, size uint) XlogManagePage {
  9. infoList := networkEvents.GetConnectList()
  10. infoListLen := uint(len(infoList))
  11. resPage := XlogManagePage{
  12. Data: []XlogManageInfo{},
  13. PageNum: page,
  14. PageSize: size,
  15. Total: infoListLen,
  16. }
  17. if infoListLen == 0 {
  18. return resPage
  19. }
  20. if page < 1 {
  21. return resPage
  22. }
  23. startIndex := (page - 1) * size
  24. endIndex := page * size
  25. if endIndex > infoListLen {
  26. endIndex = infoListLen
  27. }
  28. if endIndex <= startIndex {
  29. return resPage
  30. }
  31. resPage.Data = infoList[startIndex:endIndex]
  32. return resPage
  33. }
  34. func SendXlogCmd(uuid, cmd string) (string, error) {
  35. fmt.Printf("Send xlog cmd: %s - %s\n", uuid, cmd)
  36. return networkEvents.SendXlogCmdDate(uuid, []byte(cmd))
  37. }