Merge remote-tracking branch 'origin/feature/start' into feature/basic_functions
This commit is contained in:
commit
a5152aaa3d
|
@ -22,10 +22,10 @@ public class RequestController {
|
|||
|
||||
static int notSoRandom = 0;
|
||||
|
||||
@GetMapping("/")
|
||||
public String home() {
|
||||
return "redirect:/shop/";
|
||||
}
|
||||
// @GetMapping("/")
|
||||
// public String home() {
|
||||
// return "redirect:/shop/";
|
||||
// }
|
||||
|
||||
@GetMapping("/login")
|
||||
public String login() {
|
||||
|
@ -88,10 +88,10 @@ public class RequestController {
|
|||
return "redirect:/";
|
||||
}
|
||||
|
||||
@GetMapping("/shop/")
|
||||
public String shop() {
|
||||
return "shop/index";
|
||||
}
|
||||
// @GetMapping("/shop/")
|
||||
// public String shop() {
|
||||
// return "shop/index";
|
||||
// }
|
||||
|
||||
@GetMapping("/shop/search")
|
||||
public String shopSearch() {
|
||||
|
@ -137,20 +137,20 @@ public class RequestController {
|
|||
// }
|
||||
// }
|
||||
|
||||
@GetMapping("/about")
|
||||
public String about() {
|
||||
return "about";
|
||||
}
|
||||
|
||||
@GetMapping("/terms")
|
||||
public String terms() {
|
||||
return "terms";
|
||||
}
|
||||
|
||||
@GetMapping("/privacy")
|
||||
public String privacy() {
|
||||
return "privacy";
|
||||
}
|
||||
// @GetMapping("/about")
|
||||
// public String about() {
|
||||
// return "about";
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/terms")
|
||||
// public String terms() {
|
||||
// return "terms";
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/privacy")
|
||||
// public String privacy() {
|
||||
// return "privacy";
|
||||
// }
|
||||
|
||||
|
||||
@GetMapping("/intern/")
|
||||
|
|
|
@ -1,8 +1,104 @@
|
|||
package org.hso.ecommerce.controller.shop;
|
||||
|
||||
import org.hso.ecommerce.entities.shop.Article;
|
||||
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.servlet.http.HttpSession;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Controller
|
||||
//@RequestMapping("...")
|
||||
@RequestMapping("/")
|
||||
public class ShopIndexController {
|
||||
|
||||
@GetMapping("/")
|
||||
public String home() {
|
||||
return "redirect:/shop/";
|
||||
}
|
||||
|
||||
@GetMapping("/shop/")
|
||||
public String shop(Model model, HttpSession session) {
|
||||
|
||||
//TODO: get commercialised Articles
|
||||
ArrayList<Article> commercialArticles = getArticles();
|
||||
model.addAttribute("commercialArticles", commercialArticles);
|
||||
|
||||
//check if logged in
|
||||
boolean isLoggedIn = false;
|
||||
boolean hasOrders = false;
|
||||
if (session != null && session.getAttribute("id") != null) {
|
||||
long userId = (long) session.getAttribute("id");
|
||||
isLoggedIn = true;
|
||||
if (false) {
|
||||
hasOrders = true; //TODO: Find out whether user has orders!
|
||||
}
|
||||
}
|
||||
model.addAttribute("isLoggedIn", isLoggedIn);
|
||||
model.addAttribute("hasOrders", hasOrders);
|
||||
|
||||
|
||||
if (hasOrders) {
|
||||
//TODO: get up to last 4 Orders
|
||||
ArrayList<Article> suggestedArticles = getArticles();
|
||||
model.addAttribute("suggestedArticles", suggestedArticles);
|
||||
}
|
||||
|
||||
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>
|
||||
<div class="back" data-group="shop" data-name="Zurück zur Startseite." data-insert="false"></div>
|
||||
<div class='grid m base shadow'>
|
||||
<section><a th:href="@{/shop/articles/1234}" class="section">
|
||||
<section th:each="article: ${commercialArticles}">
|
||||
<a th:href="@{/shop/articles/{id}(id=${article.id})}" class="section">
|
||||
|
||||
<img th:src="@{/img/product-1.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-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>
|
||||
<img th:src="@{/img/product-1.jpg}"/>
|
||||
<h2 th:text="${article.title}" />
|
||||
<p class='price' th:text="${article.shopPricePerUnitNetCent}" />
|
||||
<p th:text="${article.description}" />
|
||||
</a>
|
||||
</section>
|
||||
<section class="spacer"></section>
|
||||
|
@ -79,7 +38,9 @@
|
|||
<div class=''>
|
||||
<div class='content-width'>
|
||||
<h1>Personalisierte Empfehlungen</h1>
|
||||
<div class="grid l">
|
||||
|
||||
<!-- if a User is NOT logged in-->
|
||||
<div class="grid l" th:if="${isLoggedIn == false}">
|
||||
<img th:src="@{/img/undraw_successful_purchase_secondary.svg}"/>
|
||||
<div>
|
||||
<h2>Werde jetzt Kunde</h2>
|
||||
|
@ -90,6 +51,26 @@
|
|||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- If User is logged in but hasn't ordered anything yet-->
|
||||
<div th:if="$isLoggedIn == true and $hasOrders == false">
|
||||
<h1>Jetzt Shoppen und Empfehlungen erhalten!</h1>
|
||||
</div>
|
||||
|
||||
<!-- If User is logged in and has ordered something before-->
|
||||
<div th:if="$hasOrders == true">
|
||||
<div class='grid m base shadow'>
|
||||
<section th:each="article: ${suggestedArticles}">
|
||||
<a th:href="@{/shop/articles/{id}(id=${article.id})}" class="section">
|
||||
|
||||
<img th:src="@{/img/product-1.jpg}"/>
|
||||
<h2 th:text="${article.title}" />
|
||||
<p class='price' th:text="${article.shopPricePerUnitNetCent}" />
|
||||
<p th:text="${article.description}" />
|
||||
</a>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="vertical-spacer s"></div>
|
||||
</div>
|
||||
|
|
Reference in New Issue