package com.its.op.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.AuditorAware;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

import java.util.Optional;

@EnableJpaAuditing
@Configuration
public class AuditorAwareConfig {

    // 로그인 사용자 정보 저장소 ......

    @Bean
    public AuditorAware<String> auditorAware() {
        return (AuditorAware) () -> {
            String userId = "ADMIN";
            return Optional.of(userId);
        };

//        return Optional.ofNullable(SecurityContextHolder.getContext())
//                .map(SecurityContext::getAuthentication)
//                .filter(Authentication::isAuthenticated)
//                .map(Authentication::getPrincipal)
//                .map(User.class::cast);
    }
}
