DomainTemplatesListController.java

package fr.tiogars.inception.domains.domaintemplate.controllers;

import java.util.List;

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

import fr.tiogars.inception.domains.domaintemplate.models.DomainTemplate;
import fr.tiogars.inception.domains.domaintemplate.services.DomainTemplateFindAllService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;

/**
 * Exposes the endpoint that lists records in a domain.
 *
 * @since 0.1.0
 */
@Tag(name = "DomainTemplates", description = "CRUD operations for the DomainTemplate business object.")
@RestController
public class DomainTemplatesListController {

    private final DomainTemplateFindAllService service;

    /**
     * Creates the domain query endpoint.
     *
     * @param service domain record listing service
     */
    public DomainTemplatesListController(DomainTemplateFindAllService service) {
        this.service = service;
    }

    /**
     * Lists all records.
     *
     * @return matching records ordered by key and version
     */
    @Operation(summary = "List records in a domain", description = "Returns all record versions stored in the supplied domain, ordered by key and version.")
    @ApiResponses(value = {
            @ApiResponse(responseCode = "200", description = "Records in the domain were returned.")
    })
    @GetMapping("/api/v1/domaintemplate")
    public List<DomainTemplate> listDomainTemplate() {
        return service.findAll();
    }
}