package com.eactive.kakao.rolling.impl;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;

import com.eactive.kakao.rolling.CurrentCommitIdService;
import com.eactive.kakao.rolling.RollingSuffixService;
import com.eactive.kakao.rolling.TableSuffixResolver;

public class TableSuffixResolverImpl implements TableSuffixResolver {

	private String currentSuffix;

	@Autowired
	private RollingSuffixService rollingSuffixService;

	@Autowired
	private CurrentCommitIdService currentCommitIdService;

	@PostConstruct
	public void init() {
		String systemCommitId = currentCommitIdService.getSystemCommitId();
		currentSuffix = rollingSuffixService.getCurrentSuffixByCommitId(systemCommitId);
	}

	@Override
	public String getCurrentSuffix() {
		return currentSuffix;
	}

}