u
This commit is contained in:
1 parent
4dcac7b5a0
commit
59d3be2299
25 files changed
+380
-125
No files matched your search
@@ -0,0 +1,27 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"cn/oneao/base-go/db"
|
||||
"cn/oneao/base-go/logx"
|
||||
"context"
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
)
|
||||
|
||||
func RefreshActive() app.HandlerFunc {
|
||||
return func(c context.Context, ctx *app.RequestContext) {
|
||||
// 先执行后续 handler
|
||||
ctx.Next(c)
|
||||
|
||||
userID := GetUserID(c)
|
||||
if userID == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
// 异步刷新活跃时间
|
||||
go func() {
|
||||
if err := db.Queries.UpdateUserActiveTime(c, userID); err != nil {
|
||||
logx.CtxError(c, "刷新用户活跃时间失败, userID=%d, err=%v", userID, err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user