Logs.go 2.1 KB

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