WIP feature/listedArticles #15
|
@ -22,10 +22,10 @@ public class RequestController {
|
||||||
|
|
||||||
static int notSoRandom = 0;
|
static int notSoRandom = 0;
|
||||||
|
|
||||||
@GetMapping("/")
|
// @GetMapping("/")
|
||||||
public String home() {
|
// public String home() {
|
||||||
return "redirect:/shop/";
|
// return "redirect:/shop/";
|
||||||
}
|
// }
|
||||||
|
|
||||||
@GetMapping("/login")
|
@GetMapping("/login")
|
||||||
public String login() {
|
public String login() {
|
||||||
|
@ -88,10 +88,10 @@ public class RequestController {
|
||||||
return "redirect:/";
|
return "redirect:/";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/shop/")
|
// @GetMapping("/shop/")
|
||||||
public String shop() {
|
// public String shop() {
|
||||||
return "shop/index";
|
// return "shop/index";
|
||||||
}
|
// }
|
||||||
|
|
||||||
@GetMapping("/shop/search")
|
@GetMapping("/shop/search")
|
||||||
public String shopSearch() {
|
public String shopSearch() {
|
||||||
|
@ -137,20 +137,20 @@ public class RequestController {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@GetMapping("/about")
|
// @GetMapping("/about")
|
||||||
public String about() {
|
// public String about() {
|
||||||
return "about";
|
// return "about";
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@GetMapping("/terms")
|
// @GetMapping("/terms")
|
||||||
public String terms() {
|
// public String terms() {
|
||||||
return "terms";
|
// return "terms";
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@GetMapping("/privacy")
|
// @GetMapping("/privacy")
|
||||||
public String privacy() {
|
// public String privacy() {
|
||||||
return "privacy";
|
// return "privacy";
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/intern/")
|
@GetMapping("/intern/")
|
||||||
|
|
|
@ -1,8 +1,83 @@
|
||||||
package org.hso.ecommerce.controller.shop;
|
package org.hso.ecommerce.controller.shop;
|
||||||
|
|
||||||
|
import org.hso.ecommerce.entities.shop.Article;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
//@RequestMapping("...")
|
@RequestMapping("/")
|
||||||
public class ShopIndexController {
|
public class ShopIndexController {
|
||||||
|
|
||||||
|
@GetMapping("/")
|
||||||
|
public String home() {
|
||||||
|
return "redirect:/shop/";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/shop/")
|
||||||
|
public String shop(Model model) {
|
||||||
|
|
||||||
|
ArrayList<Article> dummyArticles = getArticles();
|
||||||
|
|
||||||
|
model.addAttribute("articles", dummyArticles);
|
||||||
|
return "shop/index";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/about")
|
||||||
|
public String about() {
|
||||||
|
return "about";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/terms")
|
||||||
|
public String terms() {
|
||||||
|
return "terms";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/privacy")
|
||||||
|
public String privacy() {
|
||||||
|
return "privacy";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public ArrayList<Article> getArticles(){
|
||||||
|
ArrayList<Article> dummyArticles = new ArrayList<Article>();
|
||||||
|
|
||||||
|
Article d1 = new Article();
|
||||||
|
d1.description = "this is dummy1";
|
||||||
|
d1.title = "dummy1";
|
||||||
|
d1.shopPricePerUnitNetCent = 1500;
|
||||||
|
d1.id = 1234;
|
||||||
|
dummyArticles.add(d1);
|
||||||
|
|
||||||
|
Article d2 = new Article();
|
||||||
|
d2.description = "this is dummy2";
|
||||||
|
d2.title = "dummy2";
|
||||||
|
d2.shopPricePerUnitNetCent = 2000;
|
||||||
|
d2.id = 2345;
|
||||||
|
dummyArticles.add(d2);
|
||||||
|
|
||||||
|
Article d3 = new Article();
|
||||||
|
d3.description = "this is dummy3";
|
||||||
|
d3.title = "dummy3";
|
||||||
|
d3.shopPricePerUnitNetCent = 2500;
|
||||||
|
d3.id = 3456;
|
||||||
|
dummyArticles.add(d3);
|
||||||
|
|
||||||
|
Article d4 = new Article();
|
||||||
|
d4.description = "this is dummy4";
|
||||||
|
d4.title = "dummy4";
|
||||||
|
d4.shopPricePerUnitNetCent = 3000;
|
||||||
|
d4.id = 4567;
|
||||||
|
dummyArticles.add(d4);
|
||||||
|
|
||||||
|
return dummyArticles;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,54 +18,13 @@
|
||||||
<script th:src="@{/js/back.js}"></script>
|
<script th:src="@{/js/back.js}"></script>
|
||||||
<div class="back" data-group="shop" data-name="Zurück zur Startseite." data-insert="false"></div>
|
<div class="back" data-group="shop" data-name="Zurück zur Startseite." data-insert="false"></div>
|
||||||
<div class='grid m base shadow'>
|
<div class='grid m base shadow'>
|
||||||
<section><a th:href="@{/shop/articles/1234}" class="section">
|
<section th:each="article: ${articles}">
|
||||||
|
<a th:href="@{/shop/articles/{id}(id=${article.id})}" class="section">
|
||||||
|
|
||||||
<img th:src="@{/img/product-1.jpg}"/>
|
<img th:src="@{/img/product-1.jpg}"/>
|
||||||
<h2>Lorem Ipsum</h2>
|
<h2 th:text="${article.title}" />
|
||||||
<p class='price'> 25.14 EUR</p>
|
<p class='price' th:text="${article.shopPricePerUnitNetCent}" />
|
||||||
<p>
|
<p th:text="${article.description}" />
|
||||||
Als Gregor Samsa eines Morgens aus unruhigen Träumen erwachte.
|
|
||||||
</p>
|
|
||||||
</a>
|
|
||||||
</section>
|
|
||||||
<section><a th:href="@{/shop/articles/1234}" class="section">
|
|
||||||
|
|
||||||
<img th:src="@{/img/product-2.jpg}"/>
|
|
||||||
<h2>Lorem Ipsum</h2>
|
|
||||||
<p class='price'> 10.14 EUR</p>
|
|
||||||
<p>
|
|
||||||
Als Gregor Samsa eines Morgens aus unruhigen Träumen erwachte.
|
|
||||||
</p>
|
|
||||||
</a>
|
|
||||||
</section>
|
|
||||||
<section><a th:href="@{/shop/articles/1234}" class="section">
|
|
||||||
|
|
||||||
<img th:src="@{/img/product-3.jpg}"/>
|
|
||||||
<h2>Lorem Ipsum</h2>
|
|
||||||
<p class='price'> 25.14 EUR</p>
|
|
||||||
<p>
|
|
||||||
Als Gregor Samsa eines Morgens aus unruhigen Träumen erwachte.
|
|
||||||
</p>
|
|
||||||
</a>
|
|
||||||
</section>
|
|
||||||
<section><a th:href="@{/shop/articles/1234}" class="section">
|
|
||||||
|
|
||||||
<img th:src="@{/img/product-4.jpg}"/>
|
|
||||||
<h2>Lorem Ipsum</h2>
|
|
||||||
<p class='price'> 10.14 EUR</p>
|
|
||||||
<p>
|
|
||||||
Als Gregor Samsa eines Morgens aus unruhigen Träumen erwachte.
|
|
||||||
</p>
|
|
||||||
</a>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<a th:href="@{/shop/articles/1234}" class="section">
|
|
||||||
<img th:src="@{/img/product-5.jpg}"/>
|
|
||||||
<h2>Lorem Ipsum</h2>
|
|
||||||
<p class='price'> 44.14 EUR</p>
|
|
||||||
<p>
|
|
||||||
Als Gregor Samsa eines Morgens aus unruhigen Träumen erwachte.
|
|
||||||
</p>
|
|
||||||
</a>
|
</a>
|
||||||
</section>
|
</section>
|
||||||
<section class="spacer"></section>
|
<section class="spacer"></section>
|
||||||
|
|
Reference in New Issue