package com.iqser.red.service.persistence.v1.internal.api.controller;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.iqser.red.service.persistence.management.v1.processor.entity.index.IndexInformationEntity;
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.IndexInformationPersistenceService;
import com.knecon.fforesight.databasetenantcommons.providers.utils.MagicConverter;
import com.iqser.red.service.persistence.service.v1.api.internal.resources.IndexInformationResource;
import com.iqser.red.service.persistence.service.v1.api.shared.model.index.IndexInformation;

import lombok.RequiredArgsConstructor;

@RestController
@RequiredArgsConstructor
public class IndexInformationInternalController implements IndexInformationResource {

    private final IndexInformationPersistenceService indexInformationPersistenceService;


    @Override
    public IndexInformation getIndexInformation() {

        return MagicConverter.convert(indexInformationPersistenceService.getIndexInformation(), IndexInformation.class);
    }


    @Override
    public void updateIndexInformation(@RequestBody IndexInformation indexInformation) {

        indexInformationPersistenceService.updateIndexInformation(MagicConverter.convert(indexInformation, IndexInformationEntity.class));
    }

}
