mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-28 09:00:04 +08:00
发布v2.2.10版本,更新内容请查看:https://github.com/bufanyun/hotgo/tree/v2.0/docs/guide-zh-CN/addon-version-upgrade.md
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/gogf/gf/v2/os/gtimer"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/library/contexts"
|
||||
"hotgo/utility/simple"
|
||||
"sync"
|
||||
@@ -58,30 +59,30 @@ func allow(memberId int64) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// LastActive 更新用户最后活跃
|
||||
func (s *sHook) LastActive(r *ghttp.Request) {
|
||||
// lastAdminActive 更新后台用户最后活跃
|
||||
func (s *sHook) lastAdminActive(r *ghttp.Request) {
|
||||
if r.IsFileRequest() {
|
||||
return
|
||||
}
|
||||
|
||||
var (
|
||||
ctx = r.Context()
|
||||
memberId = contexts.GetUserId(ctx)
|
||||
ctx = r.Context()
|
||||
member = contexts.GetUser(ctx)
|
||||
)
|
||||
|
||||
if memberId == 0 {
|
||||
if member == nil || member.App != consts.AppAdmin {
|
||||
return
|
||||
}
|
||||
|
||||
if allow(memberId) {
|
||||
if allow(member.Id) {
|
||||
simple.SafeGo(ctx, func(ctx context.Context) {
|
||||
_, err := g.Model("admin_member").Ctx(ctx).
|
||||
Where("id", memberId).
|
||||
Where("id", member.Id).
|
||||
WhereLT("last_active_at", gtime.Now()).
|
||||
Data(g.Map{"last_active_at": gtime.Now()}).
|
||||
Update()
|
||||
if err != nil {
|
||||
g.Log().Warningf(ctx, "hook LastActive err:%+v, memberId:%v", err, memberId)
|
||||
g.Log().Warningf(ctx, "hook lastActive err:%+v, memberId:%v", err, member.Id)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user