Logs.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package controllers
  2. import (
  3. "ColdVerify_local/conf"
  4. "ColdVerify_local/lib"
  5. "ColdVerify_local/models/System"
  6. beego "github.com/beego/beego/v2/server/web"
  7. "math"
  8. )
  9. type LogsController struct {
  10. beego.Controller
  11. }
  12. // 列表 -
  13. func (c *LogsController) List() {
  14. var log_jsons lib.LOG_JSONS
  15. page, _ := c.GetInt("page")
  16. if page < 1 {
  17. page = 1
  18. }
  19. page_z, _ := c.GetInt("page_z")
  20. if page_z < 1 {
  21. page_z = conf.Page_size
  22. }
  23. Class_1 := c.GetString("Class_1")
  24. var cnt int64
  25. List, cnt := System.Read_Logs_ALL(page, page_z, Class_1)
  26. page_size := math.Ceil(float64(cnt) / float64(page_z))
  27. log_jsons.Class_1 = Class_1
  28. log_jsons.Class_List = System.Read_Logs_Class()
  29. log_jsons.List = List
  30. log_jsons.Page = page
  31. log_jsons.Page_size = int(page_size)
  32. log_jsons.Pages = lib.Func_page(int64(page), int64(page_size))
  33. log_jsons.Num = int(cnt)
  34. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: log_jsons}
  35. c.ServeJSON()
  36. return
  37. }
  38. // 列表 -
  39. func (c *LogsController) UserLogs() {
  40. var log_jsons lib.LOG_JSONS
  41. page, _ := c.GetInt("page")
  42. if page < 1 {
  43. page = 1
  44. }
  45. page_z, _ := c.GetInt("page_z")
  46. if page_z < 1 {
  47. page_z = conf.Page_size
  48. }
  49. Class_1 := c.GetString("Class_1")
  50. var cnt int64
  51. List, cnt := System.Read_UserLogs_ALL(page, page_z, Class_1)
  52. page_size := math.Ceil(float64(cnt) / float64(page_z))
  53. log_jsons.Class_1 = Class_1
  54. log_jsons.Class_List = System.Read_UserLogs_Class()
  55. log_jsons.List = List
  56. log_jsons.Page = page
  57. log_jsons.Page_size = int(page_size)
  58. log_jsons.Pages = lib.Func_page(int64(page), int64(page_size))
  59. log_jsons.Num = int(cnt)
  60. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: log_jsons}
  61. c.ServeJSON()
  62. return
  63. }
  64. func (c *LogsController) Ping() {
  65. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  66. c.ServeJSON()
  67. return
  68. }