wp-go/actions/common/users.go

24 lines
511 B
Go
Raw Normal View History

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