Logs.go 4.1 KB

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