Logs.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. package controllers
  2. import (
  3. "Cold_Api/conf"
  4. "Cold_Api/controllers/lib"
  5. "Cold_Api/models/System"
  6. beego "github.com/beego/beego/v2/server/web"
  7. "math"
  8. "strings"
  9. )
  10. type LogsController struct {
  11. beego.Controller
  12. }
  13. // 列表 -
  14. func (c *LogsController) UserLogsClass() {
  15. // 验证登录
  16. b_, _ := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  17. if !b_ {
  18. c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
  19. c.ServeJSON()
  20. return
  21. }
  22. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: System.Read_UserLogs_Class()}
  23. c.ServeJSON()
  24. return
  25. }
  26. // 列表 -
  27. func (c *LogsController) UserLogsList() {
  28. // 验证登录
  29. b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  30. if !b_ {
  31. c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
  32. c.ServeJSON()
  33. return
  34. }
  35. type R_JSONS struct {
  36. //必须的大写开头
  37. Data []System.UserLogs
  38. Num int64
  39. Page int
  40. Page_size int
  41. }
  42. var r_jsons R_JSONS
  43. page, _ := c.GetInt("page")
  44. println(page)
  45. if page < 1 {
  46. page = 1
  47. }
  48. page_z, _ := c.GetInt("page_z")
  49. if page_z < 1 {
  50. page_z = conf.Page_size
  51. }
  52. Class_1 := c.GetString("T_class")
  53. Class_1 = strings.Replace(Class_1, "\"", "", -1)
  54. r_jsons.Data, r_jsons.Num = System.Read_UserLogs_ALL(admin_r.T_uuid, Class_1, page, page_z)
  55. r_jsons.Page = page
  56. r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
  57. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
  58. c.ServeJSON()
  59. return
  60. }
  61. // 列表 -
  62. func (c *LogsController) LogsClass() {
  63. // 验证登录
  64. b_, _ := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  65. if !b_ {
  66. c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
  67. c.ServeJSON()
  68. return
  69. }
  70. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: System.Read_Logs_Class()}
  71. c.ServeJSON()
  72. return
  73. }
  74. // 列表 -
  75. func (c *LogsController) LogsList() {
  76. // 验证登录
  77. b_, _ := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  78. if !b_ {
  79. c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
  80. c.ServeJSON()
  81. return
  82. }
  83. type R_JSONS struct {
  84. //必须的大写开头
  85. Data []System.Logs
  86. Num int64
  87. Page int
  88. Page_size int
  89. }
  90. var r_jsons R_JSONS
  91. page, _ := c.GetInt("page")
  92. println(page)
  93. if page < 1 {
  94. page = 1
  95. }
  96. page_z, _ := c.GetInt("page_z")
  97. if page_z < 1 {
  98. page_z = conf.Page_size
  99. }
  100. Class_1 := c.GetString("T_class")
  101. Class_1 = strings.Replace(Class_1, "\"", "", -1)
  102. r_jsons.Data, r_jsons.Num = System.Read_Logs_ALL(Class_1, page, page_z)
  103. r_jsons.Page = page
  104. r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
  105. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
  106. c.ServeJSON()
  107. return
  108. }