diff --git a/prototype/src/main/java/org/hso/ecommerce/app/RequestController.java b/prototype/src/main/java/org/hso/ecommerce/app/RequestController.java index 6ef7624..3a1259e 100644 --- a/prototype/src/main/java/org/hso/ecommerce/app/RequestController.java +++ b/prototype/src/main/java/org/hso/ecommerce/app/RequestController.java @@ -157,6 +157,7 @@ public class RequestController { public String intern() { return "intern/index"; } + /* @GetMapping("/intern/listedArticles/") public String internListedArticles() { @@ -168,6 +169,7 @@ public class RequestController { return "intern/listedArticles/id"; } +*/ @GetMapping("/intern/articles/") public String internArticles() { diff --git a/prototype/src/main/java/org/hso/ecommerce/controller/intern/InternArticleController.java b/prototype/src/main/java/org/hso/ecommerce/controller/intern/InternArticleController.java index d078f54..29fe361 100644 --- a/prototype/src/main/java/org/hso/ecommerce/controller/intern/InternArticleController.java +++ b/prototype/src/main/java/org/hso/ecommerce/controller/intern/InternArticleController.java @@ -1,8 +1,57 @@ package org.hso.ecommerce.controller.intern; + + +import java.util.List; + +import org.hso.ecommerce.entities.shop.Article; +import org.hso.ecommerce.repos.shop.ArticleRepository; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.*; + + + @Controller -//@RequestMapping("...") +@RequestMapping("intern/listedArticles") public class InternArticleController { + + @Autowired + private final ArticleRepository articleRepository = null; + + /* + @Autowired + public InternArticleController(ArticleRepository articleRepository) + { + this.articleRepository = articleRepository; + } + */ + + @GetMapping("/") + public String internListedArticles(Model model) { + + + List
articles = articleRepository.findAll(); + + System.out.println(articles.size()); + + + + // model.addAttribute("ListedArticles", bookService.findAll()); + + + + return "intern/listedArticles/index"; + } + + + + @GetMapping("/{id}") + public String internListedArticlesId() { + return "intern/listedArticles/id"; + } + + } diff --git a/prototype/src/main/java/org/hso/ecommerce/repos/shop/ArticleRepository.java b/prototype/src/main/java/org/hso/ecommerce/repos/shop/ArticleRepository.java index 2a88b7e..27223db 100644 --- a/prototype/src/main/java/org/hso/ecommerce/repos/shop/ArticleRepository.java +++ b/prototype/src/main/java/org/hso/ecommerce/repos/shop/ArticleRepository.java @@ -11,19 +11,19 @@ import java.util.List; import java.util.Optional; @Repository -public interface ArticleRepository extends JpaRepository { +public interface ArticleRepository extends JpaRepository +{ - @Query("SELECT a FROM Article a WHERE a.id = :articleId") - Article findArticleById(@Param("articleId") long articleId); + @Query("SELECT a FROM Article a WHERE a.id = :articleId") + Article findArticleById(@Param("articleId") long articleId); + @Query("SELECT a FROM Article a") + List
findAll(); - @Query("SELECT a FROM Article a JOIN a.related ao WHERE ao.should_be_advertised = true") - List
getAdvertisedArticles(); - - - @Query("SELECT a FROM CustomerOrderPosition cop JOIN cop.order co JOIN co.customer c JOIN cop.article a ORDER BY co.id DESC") - List
getOrderedArticles(); + @Query("SELECT a FROM Article a JOIN a.related ao WHERE ao.should_be_advertised = true") + List
getAdvertisedArticles(); + @Query("SELECT a FROM CustomerOrderPosition cop JOIN cop.order co JOIN co.customer c JOIN cop.article a ORDER BY co.id DESC") + List
getOrderedArticles(); } - diff --git a/prototype/src/main/resources/templates/intern/listedArticles/index.html b/prototype/src/main/resources/templates/intern/listedArticles/index.html index ea62db9..adce5ef 100644 --- a/prototype/src/main/resources/templates/intern/listedArticles/index.html +++ b/prototype/src/main/resources/templates/intern/listedArticles/index.html @@ -51,7 +51,7 @@ - Kamera + KameraÖ 100,50 EUR (84.45 EUR) Úberwachung, Elektronik