Logs.go 2.2 KB

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