-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
170 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/java/de/holarse/backend/db/repositories/TagGroupRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package de.holarse.backend.db.repositories; | ||
|
||
import de.holarse.backend.db.TagGroup; | ||
import java.util.List; | ||
import org.springframework.data.domain.Sort; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface TagGroupRepository extends JpaRepository<TagGroup, Integer> { | ||
|
||
@Query("from TagGroup tg join fetch tg.tags t") | ||
List<TagGroup> findAllTagGroups(final Sort sort); | ||
|
||
} |
5 changes: 0 additions & 5 deletions
5
src/main/java/de/holarse/backend/db/repositories/TagRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/main/java/de/holarse/web/controller/GameFinderController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package de.holarse.web.controller; | ||
|
||
import de.holarse.backend.db.repositories.SearchRepository; | ||
import de.holarse.backend.db.repositories.TagGroupRepository; | ||
import de.holarse.web.defines.WebDefines; | ||
import java.util.List; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Sort; | ||
import org.springframework.data.web.PageableDefault; | ||
import org.springframework.data.web.SortDefault; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.servlet.ModelAndView; | ||
|
||
@Controller | ||
@RequestMapping(value = {"/spielefinder", "/spielefinder/"}) | ||
public class GameFinderController { | ||
|
||
@Autowired | ||
private TagGroupRepository tagGroupRepository; | ||
|
||
@Autowired | ||
private SearchRepository searchRepository; | ||
|
||
@GetMapping | ||
public ModelAndView index( | ||
@PageableDefault(value = 25, page = 0) @SortDefault(sort="title", direction = Sort.Direction.ASC) Pageable pageable, | ||
@RequestParam(name = "t", defaultValue = "") final List<String> selectedTags, | ||
@RequestParam(name = "f", defaultValue = "") final String filter, | ||
final ModelAndView mv) { | ||
mv.setViewName("layouts/bare"); | ||
mv.addObject("title", "Die Linuxspiele-Seite für Linuxspieler"); | ||
mv.addObject(WebDefines.DEFAULT_VIEW_ATTRIBUTE_NAME, "sites/spielefinder/index"); | ||
|
||
// Ermitteln der Taggruppen und der dazugehörigen Tags | ||
var tagGroups = tagGroupRepository.findAllTagGroups(Sort.by(Sort.Direction.DESC, "weight")); | ||
|
||
// Suchergebnis ermitteln | ||
var searchResults = StringUtils.isAllBlank(filter) ? | ||
searchRepository.searchTags(String.join("~", selectedTags), pageable) : | ||
searchRepository.searchTags(String.join("~", selectedTags), filter, pageable); | ||
|
||
mv.addObject("count", searchResults.getTotalElements()); | ||
mv.addObject("tagGroups", tagGroups); | ||
mv.addObject("searchResults", searchResults); | ||
|
||
mv.addObject("t", selectedTags); | ||
mv.addObject("f", filter); | ||
|
||
return mv; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/webapp/WEB-INF/templates/sites/spielefinder/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col"> | ||
<h2>Spielefinder</h2> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div class="col"> | ||
Menü links | ||
|
||
<ul th:each="tagGroup : ${tagGroups}"> | ||
<li> | ||
<span th:text="${tagGroup.name}"></span> | ||
<ul th:each="tag : ${tagGroup.tags}"> | ||
<li><a href="#" th:text="${tag.name}"></a> | ||
</ul> | ||
</li> | ||
</ul> | ||
</div> | ||
<div class="col"> | ||
<div class="row"> | ||
Ergebnismenü | ||
<div class="col"> | ||
<ul> | ||
<li><a href="#">Sortieren nach Name</a></li> | ||
</ul> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
Gewählte Tags und Filter: | ||
<ul th:each="filter : ${t}"> | ||
<li><a href="" data-th-text="${filter}"></a></li> | ||
</ul> | ||
<form> | ||
<label for="f">Filter</label> | ||
<input type="text" data-th-value="${f}" name="f" placeholder="Suchergebnis eingrenzen" /> | ||
</form> | ||
</div> | ||
<div class="row"> | ||
<span data-th-text="${count}"></span> Suchergebnisse | ||
<ul th:each="searchResult : ${searchResults}"> | ||
<li><a href="" data-th-href="@{/{url}(url=${searchResult.url})}" data-th-text="${searchResult.title}"></a></li> | ||
</ul> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters