package com.zioinfo.hrm.uiws.system.service;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * 현재 사용자 ID 추출(감사 컬럼 created_by/updated_by 세팅용). 원본 CurrentUser 대체.
 * CMS JwtFilter 가 username(String) 을 principal 로 설정 → getName() 으로 추출.
 */
public final class SysActor {

    private static final String SYSTEM = "SYSTEM";

    private SysActor() {
    }

    public static String id() {
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        if (auth != null && auth.getName() != null && !auth.getName().isBlank()) {
            return auth.getName();
        }
        return SYSTEM;
    }
}
