initial commit
This commit is contained in:
49
internal/application/auth/account_info.go
Normal file
49
internal/application/auth/account_info.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"base/internal/domain/auth"
|
||||
"base/internal/dto"
|
||||
)
|
||||
|
||||
func (s *service) GetUserInfo(ctx context.Context, userID uuid.UUID) (*dto.UserInfoResponse, error) {
|
||||
user, err := s.userRepo.FindByID(ctx, userID)
|
||||
if err != nil {
|
||||
return nil, ErrUserNotFound
|
||||
}
|
||||
|
||||
var profileID *uuid.UUID
|
||||
prof, err := s.profileRepo.FindByUserID(ctx, userID)
|
||||
if err == nil && prof != nil {
|
||||
profileID = &prof.ID
|
||||
}
|
||||
|
||||
return &dto.UserInfoResponse{
|
||||
ID: user.ID,
|
||||
Email: user.Email,
|
||||
FirstName: user.FirstName,
|
||||
LastName: user.LastName,
|
||||
PhoneNumber: user.PhoneNumber,
|
||||
EmailVerified: user.EmailVerified,
|
||||
Status: userStatusToString(user.Status),
|
||||
ProfileID: profileID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func userStatusToString(s auth.UserStatus) string {
|
||||
switch s {
|
||||
case auth.UserStatusActive:
|
||||
return "active"
|
||||
case auth.UserStatusInactive:
|
||||
return "inactive"
|
||||
case auth.UserStatusPending:
|
||||
return "pending"
|
||||
case auth.UserStatusDeleted:
|
||||
return "deleted"
|
||||
default:
|
||||
return "unknown"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user