Logs.go 2.5 KB

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