SysLogs.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package controllers
  2. import (
  3. "bzd_server/conf"
  4. "bzd_server/lib"
  5. "bzd_server/models/Account"
  6. "bzd_server/models/System"
  7. beego "github.com/beego/beego/v2/server/web"
  8. "math"
  9. )
  10. type SysLogsController struct {
  11. beego.Controller
  12. }
  13. // 列表 -
  14. func (c *SysLogsController) List() {
  15. // 验证登录
  16. b_, admin_r := Account.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. if admin_r.T_power != "AAAAAAAA" {
  23. c.Data["json"] = lib.JSONS{Code: 301, Msg: "没有权限!"}
  24. c.ServeJSON()
  25. return
  26. }
  27. // 分页参数 初始化
  28. page, _ := c.GetInt("page")
  29. if page < 1 {
  30. page = 1
  31. }
  32. page_z, _ := c.GetInt("page_z")
  33. if page_z < 1 {
  34. page_z = conf.Page_size
  35. }
  36. // 查询
  37. T_class := c.GetString("T_class")
  38. T_title := c.GetString("T_title")
  39. R_List, R_cnt := System.Read_SysLogs_List_1(T_class, T_title, page, page_z)
  40. // 封装 返回数据
  41. type R_JSONS struct {
  42. //必须的大写开头
  43. Lite []System.SysLogs_R
  44. Num int64
  45. Page int
  46. Page_size int
  47. }
  48. var r_jsons R_JSONS
  49. r_jsons.Num = R_cnt
  50. r_jsons.Lite = R_List
  51. r_jsons.Page = page
  52. r_jsons.Page_size = int(math.Ceil(float64(R_cnt) / 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 *SysLogsController) List_DISTINCT_Class() {
  59. // 验证登录
  60. b_, admin_r := Account.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  61. if !b_ {
  62. c.Data["json"] = lib.JSONS{Code: 201, Msg: "User_tokey Err!"}
  63. c.ServeJSON()
  64. return
  65. }
  66. if admin_r.T_power != "AAAAAAAA" {
  67. c.Data["json"] = lib.JSONS{Code: 301, Msg: "没有权限!"}
  68. c.ServeJSON()
  69. return
  70. }
  71. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: System.Read_SysLogs_Class()}
  72. c.ServeJSON()
  73. return
  74. }