wp-go/actions/common/users.go

27 lines
575 B
Go
Raw Normal View History

2022-10-06 13:33:04 +00:00
package common
import (
"context"
2022-10-06 13:33:04 +00:00
"github.com/gin-gonic/gin"
"github/fthvgb1/wp-go/logs"
"github/fthvgb1/wp-go/models"
2022-11-05 02:32:57 +00:00
"github/fthvgb1/wp-go/models/wp"
2022-10-06 13:33:04 +00:00
"time"
)
func getUsers(a ...any) (m map[uint64]wp.Users, err error) {
2022-11-05 14:40:02 +00:00
m = make(map[uint64]wp.Users)
ctx := a[0].(context.Context)
r, err := models.SimpleFind[wp.Users](ctx, nil, "*")
2022-10-06 13:33:04 +00:00
for _, user := range r {
m[user.Id] = user
}
return
}
2022-11-05 14:40:02 +00:00
func GetUser(ctx *gin.Context, uid uint64) wp.Users {
r, err := usersCache.GetCache(ctx, uid, time.Second, ctx, uid)
2022-10-06 13:33:04 +00:00
logs.ErrPrintln(err, "get user", uid)
return r
}