package com.eactive.eai.rms.data.jpa;

import java.util.Optional;

import org.springframework.data.domain.AuditorAware;
import org.springframework.stereotype.Component;

import com.eactive.eai.rms.common.login.LoginVo;
import com.eactive.eai.rms.common.login.SessionManager;

@Component
public class EMSAuditorAware implements AuditorAware<String> {

	@Override
	public Optional<String> getCurrentAuditor() {

		LoginVo loginVo = SessionManager.getLoginVo();

		if (loginVo == null) {
			return Optional.empty();
		}

		return Optional.ofNullable(loginVo.getUserId());
	}

}
