支持统计用户的使用量

This commit is contained in:
Sakurasan
2023-04-27 18:08:05 +08:00
parent ecffae0a19
commit 33034a9db0
7 changed files with 442 additions and 25 deletions

View File

@@ -73,6 +73,15 @@ func GetUserByName(name string) (*User, error) {
return &user, nil
}
func GetUserID(authkey string) (int, error) {
var user User
result := db.Where(&User{Token: authkey}).First(&user)
if result.Error != nil {
return 0, result.Error
}
return int(user.ID), nil
}
func GetAllUsers() ([]*User, error) {
var users []*User
result := db.Find(&users)