Skip to content

Commit

Permalink
fix: fix bug in UVStatisticWithLogin
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayanami1314 committed Nov 9, 2024
1 parent 88a6cfe commit aace119
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions middleware/statistic.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,19 @@ func UVStatisticWithLogin() gin.HandlerFunc {
// 这样避免了在每次请求的时候都去拿锁
// 但需要处理用户一直保持登录状态的情况, 目前还没想好怎么处理
user := GetCurrentUser(c)
defer c.Next()
if user == nil {

if user == nil {
// 对应登录的情况
c.Next()
user = GetCurrentUser(c)
if user == nil {
return
}
rbmMutex.Lock()
defer rbmMutex.Unlock()
rbm.Add(uint32(GetCurrentUser(c).ID)) // 如果id需要用64位int,则修改rbm;add 自带去重
} else {
c.Next()
}
}
}
Expand Down

0 comments on commit aace119

Please sign in to comment.