package org.qinan.safetyeval.infrastructure.adapter.auth;

import com.jjb.saas.framework.auth.model.SSOUser;
import lombok.Builder;
import lombok.Value;

/**
 * 稳定的登录用户视图，屏蔽 SSOUser 字段变更对业务代码的影响。
 */
@Value
@Builder
public class AuthUserInfo {

    Long userId;
    String userName;
    Long tenantId;
    Long orgId;
    String mobile;
    String account;

    public static AuthUserInfo from(SSOUser user) {
        if (user == null) {
            return null;
        }
        return AuthUserInfo.builder()
                .userId(user.getUserId())
                .userName(user.getName())
                .tenantId(user.getTenantId())
                .orgId(user.getOrgId())
                .mobile(user.getMobile())
                .account(user.getAccount())
                .build();
    }
}
