argos/dmp-backend/web/src/main/java/eu/eudat/migration/controllers/TemplateController.java

31 lines
1.1 KiB
Java
Raw Normal View History

package eu.eudat.migration.controllers;
import eu.eudat.migration.dao.TemplateRepository;
import eu.eudat.migration.entities.Template;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/template")
@ConditionalOnProperty(prefix = "roadmap", name="database.url")
public class TemplateController {
private final TemplateRepository templateRepository;
@Autowired
public TemplateController(TemplateRepository templateRepository) {
this.templateRepository = templateRepository;
}
@GetMapping(path = "/all", produces = "application/json")
public ResponseEntity<List<Template>> getAllTemplates() {
return ResponseEntity.ok(this.templateRepository.findAll());
}
}