package com.eactive.kakao.rolling;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.eactive.eai.data.jpa.AbstractDataService;

@Service
@Transactional
public class CurrentCommitIdService extends AbstractDataService<CurrentCommitId, Long, CurrentCommitIdRepository> {

	@Value("#{systemEnvironment['COMMIT_ID'] ?: systemProperties['COMMIT_ID']}")
	private String systemCommitId;

	public CurrentCommitId currentCommitId() {
		return repository.getReferenceById(CurrentCommitId.CURRENT_COMMIT_ID_ID);
	}

	public String getCurrentSuffix() {
		return currentCommitId().getRollingSuffix().getSuffix();
	}

	public String getCurrentCommitId() {
		return currentCommitId().getRollingSuffix().getCommitId();
	}

	public String getSystemCommitId() {
		return systemCommitId;
	}

}
