From bbdfb91b1d0bdc3b5d5d95685b4d6657460c9b94 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Wed, 31 Mar 2021 13:25:33 +0400 Subject: [PATCH] #17 - Redirect to filtering --- .../controller/BranchController.java | 28 +++++++++++++++++++ .../repository/BranchRepository.java | 4 +++ src/main/resources/templates/indexBranch.html | 24 ++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 src/main/java/ru/ulstu/extractor/controller/BranchController.java create mode 100644 src/main/resources/templates/indexBranch.html 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 @@ + + + + Проиндексированные репозитории + + +
+ + + + + + + + + + + +
Ветки
+
+