diff --git a/application/pom.xml b/application/pom.xml index 819af507..1f5dac81 100644 --- a/application/pom.xml +++ b/application/pom.xml @@ -205,7 +205,7 @@ it.smartcommunitylabdhub dh-runtime-base ${revision} - + it.smartcommunitylabdhub dh-framework-k8s @@ -313,6 +313,27 @@ + + maven-resources-plugin + + + templates package + + copy-resources + + generate-sources + + ${project.build.outputDirectory}/templates + + + ${project.basedir}/../templates + false + + + + + + org.springframework.boot spring-boot-maven-plugin diff --git a/application/src/main/java/it/smartcommunitylabdhub/core/controllers/v1/base/TemplateController.java b/application/src/main/java/it/smartcommunitylabdhub/core/controllers/v1/base/TemplateController.java new file mode 100644 index 00000000..952bad6c --- /dev/null +++ b/application/src/main/java/it/smartcommunitylabdhub/core/controllers/v1/base/TemplateController.java @@ -0,0 +1,69 @@ +package it.smartcommunitylabdhub.core.controllers.v1.base; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import it.smartcommunitylabdhub.commons.models.template.Template; +import it.smartcommunitylabdhub.core.ApplicationKeys; +import it.smartcommunitylabdhub.core.annotations.ApiVersion; +import it.smartcommunitylabdhub.core.models.queries.filters.abstracts.TemplateFilter; +import it.smartcommunitylabdhub.core.models.queries.services.SearchableTemplateService; +import jakarta.annotation.Nullable; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import org.springdoc.core.annotations.ParameterObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort.Direction; +import org.springframework.data.web.PageableDefault; +import org.springframework.data.web.SortDefault; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@ApiVersion("v1") +@RequestMapping("/templates") +//TODO evaluate permissions for project via lookup in dto +@PreAuthorize("hasAuthority('ROLE_USER')") +@Validated +@Tag(name = "Template base API", description = "Endpoints related to entity templates management") +public class TemplateController { + + @Autowired + SearchableTemplateService templateService; + + @Operation(summary = "List templates", description = "Return a list of all templates") + @GetMapping(path = "", produces = "application/json; charset=UTF-8") + public Page