[Fix]: Include Traffic Light into Mosh
This commit is contained in:
parent
318f25ae2b
commit
f5315d72ae
|
@ -1,45 +0,0 @@
|
|||
package de.mstock.monolith.web;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import de.mstock.monolith.service.ShopService;
|
||||
|
||||
@Controller
|
||||
public class HomepageController {
|
||||
|
||||
private static final String TEMPLATE = "homepage";
|
||||
|
||||
@Autowired
|
||||
private ShopService shopService;
|
||||
private final String STOCKADMINFRONTENDTEMPLATE = "https://stock.pub.warehost.de/index.html";
|
||||
|
||||
/**
|
||||
* Redirect
|
||||
*
|
||||
* @param model Template model
|
||||
* @return The constant template name for the stock admin frontend.
|
||||
*/
|
||||
@RequestMapping(value = "/stockadmin", method = RequestMethod.GET)
|
||||
public String redirect(Model model) {return "redirect:"+ this.STOCKADMINFRONTENDTEMPLATE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Homepage
|
||||
*
|
||||
* @param model Template model
|
||||
* @param locale Current locale
|
||||
* @return The template's name.
|
||||
*/
|
||||
@RequestMapping(value = "/", method = RequestMethod.GET)
|
||||
public String homepage(Model model, Locale locale) {
|
||||
model.addAttribute("categories", shopService.getCategories(locale));
|
||||
return TEMPLATE;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head th:replace="fragments/skeleton :: head">
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link href="../static/css/bootstrap.min.css" rel="stylesheet" />
|
||||
<link href="../static/css/mosh.css" rel="stylesheet" />
|
||||
</head>
|
||||
<body>
|
||||
<div th:replace="fragments/skeleton :: navigation">
|
||||
<div class="container">
|
||||
<nav>Navigation</nav>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container product">
|
||||
|
||||
<div class="row info">
|
||||
<div class="col-md-4">
|
||||
<img class="featurette-image img-responsive center-block"
|
||||
src="../static/images/rach-new_packaging-cc_by_2_0.jpg"
|
||||
th:src="@{/images/rach-new_packaging-cc_by_2_0.jpg}"
|
||||
alt="Generic placeholder image" />
|
||||
<div>
|
||||
<small class="text-muted" th:inline="text">
|
||||
[[#{general.sampleImage}]]: Rach. <span
|
||||
class="text-emphasized">New Packaging.</span> CC BY 2.0
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<h2 th:text="${product.name}">Product Name</h2>
|
||||
<img class="icon" th:src="${'https://stock.pub.warehost.de/api/good/availablity/'+product.id}"/>
|
||||
<p class="text-info text-uppercase" th:text="${product.price}">0,00 Euro</p>
|
||||
<p class="lead" th:text="${product.description}">Description.</p>
|
||||
<div th:replace="fragments/reviews :: reviews"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer th:replace="fragments/skeleton :: footer">
|
||||
<p>© 2017</p>
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="../static/js/jquery-3.1.1.min.js"
|
||||
th:src="@{/js/jquery-3.1.1.min.js}"></script>
|
||||
<!-- Include all compiled plugins (below), or include individual files as needed -->
|
||||
<script src="../static/js/bootstrap.min.js"
|
||||
th:src="@{/js/bootstrap.min.js}"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
% ---- Farben -----------------------------------------------------------------------------------------------
|
||||
\definecolor{listings}{RGB}{226,226,226}
|
||||
|
||||
\StopCensoring
|
||||
\definecolor{hs-blau}{RGB}{10,85,140}
|
||||
\definecolor{hs-tuerkis}{RGB}{50,180,200}
|
||||
\definecolor{hs-rot}{RGB}{195,5,50}
|
||||
|
|
|
@ -126,7 +126,14 @@ Neben den bisherigen Packages, die bereits Whitebox-Tests umfassen, ist in dem P
|
|||
|
||||
\subsection{Anpassung des Monolithen}
|
||||
\label{subsec: Anpassung des Monolithen}
|
||||
Damit der Microservice Warenwirtschaft durch den bestehenden Monolithen des Webshops Mosh genutzt werden kann, wurden hier die nachfolgend aufgeführten Änderungen vorgenommen. Zunächst wurde für den Aufruf des Admin-Frontends über die URL des Monolithen \texttt{/stockadmin} das nachfolgende Mapping in der Java-Datei \texttt{HomepageController.java} ergänzt.
|
||||
Damit der Microservice Warenwirtschaft durch den bestehenden Monolithen des Webshops Mosh genutzt werden kann, wurden hier die nachfolgend aufgeführten Änderungen vorgenommen.
|
||||
\begin{itemize}
|
||||
\item Anpassung der \texttt{HomepageController.java}, sodass der Microservice Warenwirtschaft über die URL des Monolithen mit der Erweiterung \texttt{/stockadmin} aufgerufen werden kann
|
||||
\item Einfügen der Ampeldarstellung für die Verfügbarkeit auf den Produktseiten unter \texttt{products.html}
|
||||
\item Anpassung der \texttt{ProductDTO.java} um die Rückgabe der Produkt-ID, sodass diese für die Ampeldarstellung abgerufen werden kann
|
||||
\item Anpassung der \texttt{DataTransferObjectFactory.java} um die Rückgabe der Produkt-ID, sodass diese für die Ampeldarstellung abgerufen werden kann
|
||||
\item Anpassung der \texttt{ProductController.java} um eine JSON-Schnittstelle
|
||||
\end{itemize}
|
||||
|
||||
\begin{lstlisting}[caption=Anpassung in HomepageController.java, language=Java]
|
||||
private final String STOCKADMINFRONTENDTEMPLATE = "https://stock.pub.warehost.de/index.html";
|
||||
|
@ -137,7 +144,7 @@ private final String STOCKADMINFRONTENDTEMPLATE = "https://stock.pub.warehost.de
|
|||
}
|
||||
\end{lstlisting}
|
||||
|
||||
Weiter wurde die Ampeldarstellung der Verfügbarkeit unter \texttt{products.html} eingefügt. Hierfür wurde das \texttt{ProductDTO.java} um die Rückgabe der Produkt-ID erweitert.
|
||||
\texttt{ProductDTO.java} um die Rückgabe der Produkt-ID erweitert.
|
||||
|
||||
\begin{lstlisting}[caption=Anpassung products.html, language=HTML]
|
||||
<div class="col-md-8">
|
||||
|
@ -152,10 +159,33 @@ Weiter wurde die Ampeldarstellung der Verfügbarkeit unter \texttt{products.html
|
|||
\end{lstlisting}
|
||||
|
||||
|
||||
|
||||
\begin{lstlisting}[caption=Anpassung ProductDTO.java, language=Java]
|
||||
|
||||
|
||||
public class ProductDTO {
|
||||
private int id;
|
||||
[...]
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
\end{lstlisting}
|
||||
|
||||
\begin{lstlisting}[caption=Anpassung DataTransferObjectFactory.java, language=Java]
|
||||
|
||||
private ProductDTO createProductWithoutReviewsDTO(Product product, Locale locale,
|
||||
[...]
|
||||
productDTO.setId(product.getId());
|
||||
[...]
|
||||
}\end{lstlisting}
|
||||
|
||||
|
||||
\begin{lstlisting}[caption=Anpassung ProductControlle.java, language=Java]
|
||||
@RequestMapping(value = "/products/{prettyUrlFragment:[\\w-]+}.json", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public ProductDTO productJson(@PathVariable String prettyUrlFragment, Locale locale) {
|
||||
return shopService.getProduct(locale, prettyUrlFragment);
|
||||
}
|
||||
}\end{lstlisting}
|
||||
|
||||
|
|
Reference in New Issue