refactor: create updateAccountInfo

This commit is contained in:
Derrick Hammer 2024-02-13 19:49:08 -05:00
parent 6f61f09ba4
commit 23113d0f9c
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 5 additions and 1 deletions

View File

@ -102,11 +102,15 @@ func (s *AccountServiceDefault) CreateAccount(email string, password string) (*m
} }
func (s AccountServiceDefault) UpdateAccountName(userId uint, firstName string, lastName string) error { func (s AccountServiceDefault) UpdateAccountName(userId uint, firstName string, lastName string) error {
return s.updateAccountInfo(userId, models.User{FirstName: firstName, LastName: lastName})
}
func (s AccountServiceDefault) updateAccountInfo(userId uint, info interface{}) error {
var user models.User var user models.User
user.ID = userId user.ID = userId
result := s.db.Model(&models.User{}).Where(&user).Updates(&models.User{FirstName: firstName, LastName: lastName}) result := s.db.Model(&models.User{}).Where(&user).Updates(info)
if result.Error != nil { if result.Error != nil {
return result.Error return result.Error