package com.gcsc.connection.user.dto;

import com.gcsc.connection.user.entity.SnpUser;

import java.time.LocalDateTime;

public record UserResponse(
    Long userId,
    Long tenantId,
    String tenantName,
    String loginId,
    String userName,
    String email,
    String role,
    Boolean isActive,
    LocalDateTime lastLoginAt,
    LocalDateTime createdAt
) {

    public static UserResponse from(SnpUser u) {
        return new UserResponse(
            u.getUserId(),
            u.getTenant() != null ? u.getTenant().getTenantId() : null,
            u.getTenant() != null ? u.getTenant().getTenantName() : null,
            u.getLoginId(),
            u.getUserName(),
            u.getEmail(),
            u.getRole().name(),
            u.getIsActive(),
            u.getLastLoginAt(),
            u.getCreatedAt()
        );
    }
}
