Resolve "Создать новые html страницы" #41
@ -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";
|
||||
}
|
||||
}
|
@ -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, Integer> {
|
||||
Branch findByRepositoryAndName(Repository repository, String name);
|
||||
|
||||
List<Branch> findByRepositoryId(Integer repositoryId);
|
||||
}
|
||||
|
24
src/main/resources/templates/indexBranch.html
Normal file
24
src/main/resources/templates/indexBranch.html
Normal file
@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
|
||||
<html xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="~{default}">
|
||||
<head>
|
||||
<title>Проиндексированные репозитории</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
</head>
|
||||
<div class="container" layout:fragment="content">
|
||||
<table class="table table-striped">
|
||||
<thead class="thead-dark">
|
||||
<tr>
|
||||
<th scope="col">Ветки</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="branch: ${branches}">
|
||||
<td><a th:href="@{'/filtering?branchName='+${branch.name}+'&repositoryUrl='+${repository.url}}"
|
||||
th:text="${branch.name}"/></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user