chore: cache username

This commit is contained in:
CaIon
2024-01-11 18:39:21 +08:00
parent 64e9e9cc20
commit f07b9f8ab2
4 changed files with 40 additions and 8 deletions

View File

@@ -452,7 +452,7 @@ func updateUserRequestCount(id int, count int) {
}
}
func GetUsernameById(id int) (username string) {
DB.Model(&User{}).Where("id = ?", id).Select("username").Find(&username)
return username
func GetUsernameById(id int) (username string, err error) {
err = DB.Model(&User{}).Where("id = ?", id).Select("username").Find(&username).Error
return username, err
}