This commit is contained in:
laodaming 2023-10-31 14:47:56 +08:00
parent 33f8742ad1
commit 4c4e1c1cc6

View File

@ -4,6 +4,7 @@ import (
"context"
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"sync"
"fusenapi/server/websocket/internal/svc"
"fusenapi/server/websocket/internal/types"
@ -28,11 +29,14 @@ func NewGetStatLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetStatLo
// 处理进入前逻辑w,r
// func (l *GetStatLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
// }
var GetStatMutex sync.Mutex
func (l *GetStatLogic) GetStat(req *types.GetStatReq, userinfo *auth.UserInfo) (resp *basic.Response) {
if req.Password != "fusen1314" {
return resp.SetStatusWithMessage(basic.CodeOK, "你干嘛,哎哟")
}
GetStatMutex.Lock()
defer GetStatMutex.Unlock()
userStat := make(map[string]int)
mapUserWsStat.Range(func(key, value any) bool {
userStat[key.(string)] = value.(int)