monitor_online.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package admin
  2. import (
  3. "gfast/app/model/admin/user_online"
  4. "gfast/app/service/admin/monitor_service"
  5. "gfast/library/response"
  6. "github.com/gogf/gf/frame/g"
  7. "github.com/gogf/gf/net/ghttp"
  8. "github.com/gogf/gf/util/gvalid"
  9. )
  10. type MonitorOnline struct{}
  11. //用户状态列表
  12. func (c *MonitorOnline) List(r *ghttp.Request) {
  13. var req *user_online.ReqListSearch
  14. //获取参数
  15. if err := r.Parse(&req); err != nil {
  16. response.FailJson(true, r, err.(*gvalid.Error).FirstString())
  17. }
  18. total, page, list, err := monitor_service.GetOnlineListPage(req)
  19. if err != nil {
  20. response.FailJson(true, r, err.Error())
  21. }
  22. result := g.Map{
  23. "currentPage": page,
  24. "total": total,
  25. "list": list,
  26. }
  27. response.SusJson(true, r, "用户在线状态", result)
  28. }
  29. //强制退出
  30. func (c *MonitorOnline) ForceLogout(r *ghttp.Request) {
  31. ids := r.GetInts("ids")
  32. if len(ids) == 0 {
  33. response.FailJson(true, r, "参数错误")
  34. }
  35. if err := monitor_service.ForceLogout(ids); err != nil {
  36. response.FailJson(true, r, err.Error())
  37. }
  38. response.SusJson(true, r, "用户已退出")
  39. }