package com.social.media.application.shared.security;

import com.social.media.domain.user.UserId;
import com.social.media.domain.company.valueobject.CompanyId;
import com.social.media.domain.shared.enums.UserType;

import java.util.UUID;

/**
 * Record representing authenticated user information
 */
public record AuthenticatedUserInfo(
    UserId userId,
    CompanyId companyId,
    UserType userType,
    String username,
    boolean isActive
) {
    
    /**
     * Check if user is admin
     */
    public boolean isAdmin() {
        // UserType doesn't have ADMIN or SUPER_ADMIN, this needs to be implemented based on UserRole
        return false; // TODO: Implement based on UserRole
    }
    
    /**
     * Check if user is super admin
     */
    public boolean isSuperAdmin() {
        // UserType doesn't have ADMIN or SUPER_ADMIN, this needs to be implemented based on UserRole
        return false; // TODO: Implement based on UserRole
    }
    
    /**
     * Get user ID as UUID
     */
    public java.util.UUID getUserUUID() {
        return userId.getValue();
    }
    
    /**
     * Get user ID as Long for repository queries
     * This is a temporary solution for compatibility with Long-based repository methods
     */
    public Long getUserIdAsLong() {
        // Convert UUID to Long - this is a temporary hack
        // In production, you should ensure consistency between domain and persistence layers
        UUID uuid = userId.getValue();
        return Math.abs(uuid.getMostSignificantBits()) % Long.MAX_VALUE;
    }
    
    /**
     * Get company ID as Long for repository queries
     */
    public Long companyIdAsLong() {
        return companyId.value();
    }
}
