Add statistics.

This commit is contained in:
2025-05-13 18:59:23 +08:00
parent f1345f9a0c
commit 12c1e0e413
8 changed files with 98 additions and 28 deletions

View File

@@ -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