update environment mode handling, refactor user registration logic, and add username/email existence checks

This commit is contained in:
2025-07-22 10:04:42 +08:00
parent 08872ea015
commit f07200b0b9
7 changed files with 51 additions and 24 deletions

View File

@ -43,3 +43,19 @@ func (user *userRepo) Update(userModel *model.User) error {
}
return nil
}
func (user *userRepo) CheckUsernameExists(username string) (bool, error) {
var count int64
if err := GetDB().Model(&model.User{}).Where("username = ?", username).Count(&count).Error; err != nil {
return false, err
}
return count > 0, nil
}
func (user *userRepo) CheckEmailExists(email string) (bool, error) {
var count int64
if err := GetDB().Model(&model.User{}).Where("email = ?", email).Count(&count).Error; err != nil {
return false, err
}
return count > 0, nil
}