package com.iqser.red.service.persistence.management.v1.processor.service;

import org.springframework.stereotype.Service;

import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.ApplicationConfigurationEntity;
import com.iqser.red.service.persistence.management.v1.processor.exception.NotFoundException;
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.ApplicationConfigRepository;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Service
@RequiredArgsConstructor
public class ApplicationConfigService {

    private final ApplicationConfigRepository applicationConfigRepository;


    public ApplicationConfigurationEntity getApplicationConfig() {

        return applicationConfigRepository.findById(ApplicationConfigurationEntity.ID).orElseThrow(() -> new NotFoundException("Application Configuration not found"));
    }


    public ApplicationConfigurationEntity saveApplicationConfiguration(ApplicationConfigurationEntity appConfig) {

        return applicationConfigRepository.save(appConfig);
    }

}
