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

import static com.knecon.fforesight.databasetenantcommons.providers.utils.MagicConverter.convert;

import java.util.List;

import jakarta.transaction.Transactional;

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

import com.iqser.red.service.persistence.management.v1.processor.service.persistence.LegalBasisMappingPersistenceService;
import com.iqser.red.service.persistence.service.v1.api.internal.resources.LegalBasisMappingResource;
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.legalbasis.LegalBasis;

import lombok.RequiredArgsConstructor;

@RestController
@RequiredArgsConstructor
public class LegalBasisMappingInternalController implements LegalBasisMappingResource {

    private final LegalBasisMappingPersistenceService legalBasisMappingPersistenceService;


    @Override
    @Transactional
    public List<LegalBasis> getLegalBasisMapping(@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId) {

        return convert(legalBasisMappingPersistenceService.getLegalBasisMapping(dossierTemplateId), LegalBasis.class);
    }


    @Override
    public long getVersion(@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId) {

        return legalBasisMappingPersistenceService.getVersion(dossierTemplateId);
    }

}
