diff --git a/src/main/java/ru/ulstu/extractor/controller/BranchController.java b/src/main/java/ru/ulstu/extractor/controller/BranchController.java new file mode 100644 index 0000000..8254210 --- /dev/null +++ b/src/main/java/ru/ulstu/extractor/controller/BranchController.java @@ -0,0 +1,28 @@ +package ru.ulstu.extractor.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import ru.ulstu.extractor.repository.BranchRepository; +import ru.ulstu.extractor.repository.RepositoryRepository; + +@Controller +public class BranchController { + private final RepositoryRepository repositoryRepository; + private final BranchRepository branchRepository; + + public BranchController(RepositoryRepository repositoryRepository, BranchRepository branchRepository) { + this.repositoryRepository = repositoryRepository; + this.branchRepository = branchRepository; + } + + @GetMapping("/details") + public String indexBranch( + Model model, + @RequestParam int repositoryId) { + model.addAttribute("branches", branchRepository.findByRepositoryId(repositoryId)); + model.addAttribute("repository", repositoryRepository.findById(repositoryId).get()); + return "indexBranch"; + } +} diff --git a/src/main/java/ru/ulstu/extractor/repository/BranchRepository.java b/src/main/java/ru/ulstu/extractor/repository/BranchRepository.java index f893bb6..d16b1a2 100644 --- a/src/main/java/ru/ulstu/extractor/repository/BranchRepository.java +++ b/src/main/java/ru/ulstu/extractor/repository/BranchRepository.java @@ -4,6 +4,10 @@ import org.springframework.data.jpa.repository.JpaRepository; import ru.ulstu.extractor.model.Branch; import ru.ulstu.extractor.model.Repository; +import java.util.List; + public interface BranchRepository extends JpaRepository { Branch findByRepositoryAndName(Repository repository, String name); + + List findByRepositoryId(Integer repositoryId); } diff --git a/src/main/resources/templates/indexBranch.html b/src/main/resources/templates/indexBranch.html new file mode 100644 index 0000000..938b141 --- /dev/null +++ b/src/main/resources/templates/indexBranch.html @@ -0,0 +1,24 @@ + + + + Проиндексированные репозитории + + +
+ + + + + + + + + + + +
Ветки
+
+