diff --git a/dao/user.go b/dao/user.go index 63af652..88da718 100644 --- a/dao/user.go +++ b/dao/user.go @@ -19,7 +19,10 @@ type User struct { func CreateUser(name, password, email, gender string, age int) uint { user := User{Name: name, Email: email, Password: password, Gender: gender, Age: age} - DB.Create(&user) + res := DB.Debug().Create(&user) + if res.Error != nil { + return 0 + } return user.ID }