implement only show Searchresults which are in Stock
This commit is contained in:
parent
8d6a1f4053
commit
bc350b3177
|
@ -33,14 +33,8 @@ public class ShopIndexController {
|
||||||
@GetMapping("/shop/")
|
@GetMapping("/shop/")
|
||||||
public String shop(Model model, HttpSession session) {
|
public String shop(Model model, HttpSession session) {
|
||||||
|
|
||||||
List<Article> commercialArticlesBefore = GetRandomArticlesAction.getRandomArticles(8, articleRepository.getAdvertisedArticles());
|
List<Article> commercialArticles = GetRandomArticlesAction.getRandomArticles(8, articleRepository.getAdvertisedArticles());
|
||||||
List<Article> commercialArticles = new ArrayList<Article>();
|
|
||||||
for (int i = 0; i < commercialArticlesBefore.size(); i++) { //check for stockamount
|
|
||||||
Article article = commercialArticlesBefore.get(i);
|
|
||||||
if (warehouseBookingPositionSlotEntryRepository.getByArticle(article.id).get(0).newSumSlot != 0) {
|
|
||||||
commercialArticles.add(article);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
model.addAttribute("commercialArticles", commercialArticles);
|
model.addAttribute("commercialArticles", commercialArticles);
|
||||||
|
|
||||||
boolean isLoggedIn = false;
|
boolean isLoggedIn = false;
|
||||||
|
@ -78,5 +72,4 @@ public class ShopIndexController {
|
||||||
public String privacy() {
|
public String privacy() {
|
||||||
return "privacy";
|
return "privacy";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ public interface ArticleRepository extends JpaRepository<Article, Long> {
|
||||||
@Query("SELECT a FROM Article a")
|
@Query("SELECT a FROM Article a")
|
||||||
List<Article> findAll();
|
List<Article> findAll();
|
||||||
|
|
||||||
@Query("SELECT a FROM Article a JOIN a.related ao WHERE ao.shouldBeAdvertised = true")
|
@Query(value = "Select a.* from articles as a, article_offers as ao, warehouse_booking_position_entries as wbpe where a.related_id = ao.id and wbpe.article_id = a.id and ao.should_be_advertised = true group by wbpe.slot_id having max(wbpe.id) and wbpe.new_sum_slot != 0", nativeQuery = true)
|
||||||
List<Article> getAdvertisedArticles();
|
List<Article> getAdvertisedArticles();
|
||||||
|
|
||||||
@Query("SELECT a FROM CustomerOrderPosition cop JOIN cop.order co JOIN co.customer c JOIN cop.article a ORDER BY co.id DESC")
|
@Query("SELECT a FROM CustomerOrderPosition cop JOIN cop.order co JOIN co.customer c JOIN cop.article a ORDER BY co.id DESC")
|
||||||
|
@ -26,9 +26,9 @@ public interface ArticleRepository extends JpaRepository<Article, Long> {
|
||||||
@Query("SELECT a FROM CustomerOrderPosition cop JOIN cop.order co JOIN co.customer c JOIN cop.article a WHERE c.id = :customerId ORDER BY co.id DESC")
|
@Query("SELECT a FROM CustomerOrderPosition cop JOIN cop.order co JOIN co.customer c JOIN cop.article a WHERE c.id = :customerId ORDER BY co.id DESC")
|
||||||
List<Article> getOrderedArticles(long customerId);
|
List<Article> getOrderedArticles(long customerId);
|
||||||
|
|
||||||
@Query("SELECT a FROM Article a WHERE a.title LIKE %:term%")
|
@Query(value = "Select a.* from articles as a, warehouse_booking_position_entries as wbpe where wbpe.article_id = a.id and a.title LIKE %:term% group by wbpe.slot_id having max(wbpe.id) and wbpe.new_sum_slot != 0", nativeQuery = true)
|
||||||
List<Article> getArticlesByTerm(String term);
|
List<Article> getArticlesByTerm(String term);
|
||||||
|
|
||||||
@Query("SELECT a FROM Article a JOIN a.categories c WHERE :category = c.name")
|
@Query(value = "Select a.* from articles as a, categories as c, article_categories_bindings as acb, warehouse_booking_position_entries as wbpe where wbpe.article_id = a.id and acb.articles_id = a.id and acb.categories_id = c.id and c.name = :category group by wbpe.slot_id having max(wbpe.id) and wbpe.new_sum_slot != 0", nativeQuery = true)
|
||||||
List<Article> getArticlesByCategory(String category);
|
List<Article> getArticlesByCategory(String category);
|
||||||
}
|
}
|
Reference in New Issue