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

import java.util.List;

import jakarta.transaction.Transactional;

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

import com.iqser.red.service.persistence.management.v1.processor.service.DossierManagementService;
import com.iqser.red.service.persistence.service.v1.api.internal.resources.DossierResource;
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.Dossier;

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

@Slf4j
@RestController
@RequiredArgsConstructor
public class DossierInternalController implements DossierResource {

    private final DossierManagementService dossierManagementService;


    @Override
    @Transactional
    public List<Dossier> getAllDossiers(@RequestParam(name = INCLUDE_ARCHIVED_PARAM, defaultValue = "false", required = false) boolean includeArchived,
                                        @RequestParam(name = INCLUDE_DELETED_PARAM, defaultValue = "false", required = false) boolean includeDeleted) {

        return dossierManagementService.getAllDossiers(includeArchived, includeDeleted);
    }


    @Override
    @Transactional
    public Dossier getDossierById(@Param(DOSSIER_ID_PARAM) @PathVariable(DOSSIER_ID_PARAM) String dossierId,
                                  @RequestParam(name = INCLUDE_ARCHIVED_PARAM, defaultValue = "false", required = false) boolean includeArchived,
                                  @RequestParam(name = INCLUDE_DELETED_PARAM, defaultValue = "false", required = false) boolean includeDeleted) {

        return dossierManagementService.getDossierById(dossierId, includeArchived, includeDeleted);
    }

}
