refactor: create updateAccountInfo
This commit is contained in:
parent
6f61f09ba4
commit
23113d0f9c
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue