This commit is contained in:
2021-12-22 16:38:38 +08:00
parent b8d1391bde
commit 05a5c7c82f
7 changed files with 249 additions and 147 deletions

View File

@@ -14,6 +14,7 @@ package user
import (
"github.com/jageros/hawox/attribute"
"github.com/jageros/hawox/logx"
"stock/module"
"sync"
)
@@ -37,6 +38,17 @@ func LoadAllUserIntoCache() error {
return nil
}
func SaveAll() {
mx.Lock()
defer mx.Unlock()
for _, u := range users {
err := u.attr.Save(true)
if err != nil {
logx.Error(err)
}
}
}
func GetUser(openId string) (*User, error) {
mx.RLock()
u, ok := users[openId]