Logs.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. )
  9. type LogsController struct {
  10. beego.Controller
  11. }
  12. // 列表 -
  13. func (c *LogsController) List() {
  14. page, _ := c.GetInt("page")
  15. println(page)
  16. if page < 1 {
  17. page = 1
  18. }
  19. Class_1 := c.GetString("Class_1")
  20. c.Data["Class_1"] = Class_1
  21. c.Data["Class_List"] = System.Read_Logs_Class()
  22. var cnt int64
  23. c.Data["List"], cnt = System.Read_Logs_ALL(page, Class_1)
  24. page_size := math.Ceil(float64(cnt) / float64(conf.Page_size))
  25. c.Data["Page"] = page
  26. c.Data["Page_size"] = page_size
  27. c.Data["Pages"] = lib.Func_page(int64(page), int64(page_size))
  28. c.Data["cnt"] = cnt
  29. c.TplName = "System/Logs.html"
  30. }
  31. // 列表 -
  32. func (c *LogsController) UserLogs() {
  33. page, _ := c.GetInt("page")
  34. println(page)
  35. if page < 1 {
  36. page = 1
  37. }
  38. Class_1 := c.GetString("Class_1")
  39. c.Data["Class_1"] = Class_1
  40. c.Data["Class_List"] = System.Read_UserLogs_Class()
  41. var cnt int64
  42. c.Data["List"], cnt = System.Read_UserLogs_ALL(page, Class_1)
  43. page_size := math.Ceil(float64(cnt) / float64(conf.Page_size))
  44. c.Data["Page"] = page
  45. c.Data["Page_size"] = page_size
  46. c.Data["Pages"] = lib.Func_page(int64(page), int64(page_size))
  47. c.Data["cnt"] = cnt
  48. c.TplName = "User/UserLogs.html"
  49. }
  50. // 列表 -
  51. func (c *LogsController) V2_UserLogsClass() {
  52. // 验证登录
  53. b_, _ := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  54. if !b_ {
  55. c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
  56. c.ServeJSON()
  57. return
  58. }
  59. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: System.Read_UserLogs_Class()}
  60. c.ServeJSON()
  61. return
  62. }
  63. // 列表 -
  64. func (c *LogsController) V2_UserLogs() {
  65. // 验证登录
  66. b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  67. if !b_ {
  68. c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
  69. c.ServeJSON()
  70. return
  71. }
  72. type R_JSONS struct {
  73. //必须的大写开头
  74. Data []System.UserLogs
  75. Num int64
  76. Page int
  77. Page_size int
  78. }
  79. var r_jsons R_JSONS
  80. page, _ := c.GetInt("page")
  81. println(page)
  82. if page < 1 {
  83. page = 1
  84. }
  85. page_z, _ := c.GetInt("page_z")
  86. if page_z < 1 {
  87. page_z = conf.Page_size
  88. }
  89. Class_1 := c.GetString("T_class")
  90. r_jsons.Data, r_jsons.Num = System.Read_V2_UserLogs_ALL(admin_r.Admin_uuid, Class_1, page, page_z)
  91. r_jsons.Page = page
  92. r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
  93. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
  94. c.ServeJSON()
  95. return
  96. }
  97. // 列表 -
  98. func (c *LogsController) LogsClass() {
  99. // 验证登录
  100. b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  101. if !b_ {
  102. c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
  103. c.ServeJSON()
  104. return
  105. }
  106. if admin_r.Admin_power > 6 {
  107. c.Data["json"] = lib.JSONS{Code: 205, Msg: "没有权限!"}
  108. c.ServeJSON()
  109. return
  110. }
  111. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: System.Read_Logs_Class()}
  112. c.ServeJSON()
  113. return
  114. }
  115. // 列表 -
  116. func (c *LogsController) LogsList() {
  117. // 验证登录
  118. b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  119. if !b_ {
  120. c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
  121. c.ServeJSON()
  122. return
  123. }
  124. if admin_r.Admin_power > 6 {
  125. c.Data["json"] = lib.JSONS{Code: 205, Msg: "没有权限!"}
  126. c.ServeJSON()
  127. return
  128. }
  129. type R_JSONS struct {
  130. //必须的大写开头
  131. Data []System.Logs
  132. Num int64
  133. Page int
  134. Page_size int
  135. }
  136. var r_jsons R_JSONS
  137. page, _ := c.GetInt("page")
  138. println(page)
  139. if page < 1 {
  140. page = 1
  141. }
  142. page_z, _ := c.GetInt("page_z")
  143. if page_z < 1 {
  144. page_z = conf.Page_size
  145. }
  146. Class_1 := c.GetString("T_class")
  147. r_jsons.Data, r_jsons.Num = System.Read_V2_Logs_ALL(Class_1, page, page_z)
  148. r_jsons.Page = page
  149. r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
  150. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
  151. c.ServeJSON()
  152. return
  153. }