This commit is contained in:
Sakurasan
2023-04-24 22:44:03 +08:00
parent 365bc37487
commit 5ce5466723
5 changed files with 183 additions and 35 deletions
+9
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)