32 lines
611 B
Go
32 lines
611 B
Go
package userrepository
|
|
|
|
import (
|
|
"errors"
|
|
userdomain "legalgo-BE-go/internal/domain/user"
|
|
)
|
|
|
|
func (ur *UserRepository) GetUserProfile(email string) (*userdomain.UserProfile, error) {
|
|
var user *userdomain.User
|
|
|
|
if email == "" {
|
|
return nil, errors.New("email is empty")
|
|
}
|
|
|
|
if err := ur.DB.
|
|
Preload("Subscribe").
|
|
Preload("Subscribe.SubscribePlan").
|
|
First(&user, "email = ?", email).
|
|
Error; err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
userProfile := &userdomain.UserProfile{
|
|
ID: user.ID,
|
|
Email: user.Email,
|
|
Phone: user.Phone,
|
|
Subscribe: user.Subscribe,
|
|
}
|
|
|
|
return userProfile, nil
|
|
}
|