mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 12:17:24 +00:00
Add statistics.
This commit is contained in:
@@ -61,6 +61,9 @@ func GetUserByUsername(username string) (model.User, error) {
|
||||
func GetUserByID(id uint) (model.User, error) {
|
||||
var user model.User
|
||||
if err := db.First(&user, id).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return user, model.NewNotFoundError("User not found")
|
||||
}
|
||||
return user, err
|
||||
}
|
||||
return user, nil
|
||||
|
Reference in New Issue
Block a user