WIP feature/listedArticles #15
|
@ -27,10 +27,10 @@ public class InternArticleController {
|
|||
@GetMapping("/")
|
||||
public String internListedArticles(Model model) {
|
||||
|
||||
List<ListedArticlesListTotals> totals = new ArrayList<ListedArticlesListTotals>();
|
||||
List<UImodelArticles> totals = new ArrayList<UImodelArticles>();
|
||||
|
||||
for (Article article : articleRepository.findAll()) {
|
||||
ListedArticlesListTotals tmp = new ListedArticlesListTotals();
|
||||
UImodelArticles tmp = new UImodelArticles();
|
||||
tmp.addListedArticle(article, warehouseEntryRepository.getArticleStock(article.id).orElse(0));
|
||||
totals.add(tmp);
|
||||
}
|
||||
|
@ -44,16 +44,10 @@ public class InternArticleController {
|
|||
|
||||
int articleid = Integer.parseInt(id);
|
||||
|
||||
ListedArticlesListIdTotal total = new ListedArticlesListIdTotal();
|
||||
|
||||
|
||||
|
||||
UImodelArticle total = new UImodelArticle();
|
||||
|
||||
total.addArticle(articleRepository.findArticleById(articleid),
|
||||
warehouseEntryRepository.getArticleStock(articleid).orElse(0));
|
||||
|
||||
|
||||
// System.out.println("GETshouldReorder: " + articleRepository.findArticleById(articleid).shouldReorder);
|
||||
|
||||
model.addAttribute("ArticleID", total);
|
||||
|
||||
|
@ -61,36 +55,42 @@ public class InternArticleController {
|
|||
}
|
||||
|
||||
@PostMapping("/{id}/saveChanges")
|
||||
public RedirectView saveChanges(@ModelAttribute ListedArticlesListIdTotal changedArticleTotal) {
|
||||
public RedirectView saveChanges(
|
||||
@ModelAttribute UImodelArticle changedArticleTotal,
|
||||
@RequestParam("units-per-slot") String sWarehouseUnitsPerSlot,
|
||||
@RequestParam("price_netto") String sPrice_netto,
|
||||
@RequestParam("reorderMaxPrice") String sReorderMaxPrice,
|
||||
@RequestParam("autobuy") String sShouldReorder,
|
||||
@RequestParam("categories") String sCategories) {
|
||||
|
||||
Article oldArticle = articleRepository.findArticleById(changedArticleTotal.id);
|
||||
|
||||
//TODO img
|
||||
//TODO price
|
||||
//TODO reorder price
|
||||
//TODO categories
|
||||
|
||||
|
||||
|
||||
// oldArticle.shopPricePerUnitNetCent = changedArticleTotal.price_netto;
|
||||
// System.out.println("netto: " + changedArticleTotal.price_netto);
|
||||
|
||||
//System.out.println("POSTshouldReorder: " + oldArticle.shouldReorder);
|
||||
//oldArticle.shouldReorder = changedArticleTotal.shouldReorder;
|
||||
|
||||
System.out.println("POSTwarehouseUnitsPerSlot: " + oldArticle.warehouseUnitsPerSlot);
|
||||
|
||||
//oldArticle.warehouseUnitsPerSlot = Integer.parseInt(changedArticleTotal.warehouseUnitsPerSlot);
|
||||
|
||||
|
||||
oldArticle.title = changedArticleTotal.title; //works
|
||||
oldArticle.description = changedArticleTotal.description; //works
|
||||
// TODO img
|
||||
// TODO categories
|
||||
/*
|
||||
* String separatedCategories[] = sCategories.split("\\r?\\n");
|
||||
*
|
||||
*
|
||||
* for (int i = 0; i < separatedCategories.length; i++) {
|
||||
|
||||
*
|
||||
* oldArticle.categories.add(separatedCategories[i]);
|
||||
*
|
||||
* }
|
||||
*/
|
||||
|
||||
oldArticle.shouldReorder = (sShouldReorder.equals("true")) ? true : false;
|
||||
oldArticle.reorderMaxPrice = (int) (Float.parseFloat(sReorderMaxPrice) * 100);
|
||||
oldArticle.shopPricePerUnitNetCent = (int) (Float.parseFloat(sPrice_netto) * 100);
|
||||
oldArticle.warehouseUnitsPerSlot = Integer.parseInt(sWarehouseUnitsPerSlot);
|
||||
oldArticle.title = changedArticleTotal.title;
|
||||
oldArticle.description = changedArticleTotal.description;
|
||||
|
||||
articleRepository.save(oldArticle); // save updated article
|
||||
return new RedirectView("../");
|
||||
return new RedirectView("../"); //return to overview page
|
||||
}
|
||||
|
||||
public static class ListedArticlesListTotals {
|
||||
|
||||
public static class UImodelArticles {
|
||||
|
||||
public String imgPath;
|
||||
|
||||
|
@ -120,7 +120,7 @@ public class InternArticleController {
|
|||
}
|
||||
}
|
||||
|
||||
public static class ListedArticlesListIdTotal {
|
||||
public static class UImodelArticle {
|
||||
|
||||
public String getImgPath() {
|
||||
return imgPath;
|
||||
|
@ -154,11 +154,11 @@ public class InternArticleController {
|
|||
this.price_netto = price_netto;
|
||||
}
|
||||
|
||||
public int getReorderMaxPrice() {
|
||||
public String getReorderMaxPrice() {
|
||||
return reorderMaxPrice;
|
||||
}
|
||||
|
||||
public void setReorderMaxPrice(int reorderMaxPrice) {
|
||||
public void setReorderMaxPrice(String reorderMaxPrice) {
|
||||
this.reorderMaxPrice = reorderMaxPrice;
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ public class InternArticleController {
|
|||
public String title;
|
||||
public String price;
|
||||
public String price_netto;
|
||||
public int reorderMaxPrice;
|
||||
public String reorderMaxPrice;
|
||||
public String categorie;
|
||||
public int stock;
|
||||
public long offer_id;
|
||||
|
@ -240,7 +240,7 @@ public class InternArticleController {
|
|||
this.stock = stock;
|
||||
this.offer_id = article.related.id;
|
||||
Seil0
commented
Variablen Dekleration vor setter/getter? (Ich hab keine Ahnung ob wir da was ausgemacht haben) Variablen Dekleration vor setter/getter? (Ich hab keine Ahnung ob wir da was ausgemacht haben)
localhorst
commented
ist ja ne ui model klasse die nur in diesem controller gebraucht wird. Wenn es keine Getter+Setter gibt werden die auch nicht gebraucht. ist ja ne ui model klasse die nur in diesem controller gebraucht wird. Wenn es keine Getter+Setter gibt werden die auch nicht gebraucht.
Seil0
commented
Dann passt's so Dann passt's so
localhorst
commented
fixed with fixed with https://git.mosad.xyz/localhorst/e-commerce/commit/b1840dd84529acb8d4949913b35e1c1aea821b00
|
||||
this.id = article.id;
|
||||
this.reorderMaxPrice = article.reorderMaxPrice;
|
||||
this.reorderMaxPrice = String.format("%.2f", ((float) article.reorderMaxPrice / 100));
|
||||
this.shouldReorder = article.shouldReorder;
|
||||
this.warehouseUnitsPerSlot = String.valueOf(article.warehouseUnitsPerSlot);
|
||||
this.description = article.description;
|
||||
|
|
|
@ -42,6 +42,7 @@ public class Article
|
|||
@JoinTable(name = "article_categories_bindings")
|
||||
public Set<Category> categories = new HashSet<>();
|
||||
|
||||
// returns all categories as string
|
||||
public String getCategories()
|
||||
{
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
|
|
@ -52,14 +52,14 @@
|
|||
<div class="s">
|
||||
<p>
|
||||
<label for="price">Preis (Netto)</label>
|
||||
<input class="" type="number" step="0.01" name="price" th:value="${ArticleID.price_netto}"/> EUR <br/>
|
||||
<input class="" type="number" step="0.01" name="price_netto" th:value="${ArticleID.price_netto}"/> EUR <br/>
|
||||
(19% Mwst.)
|
||||
<!-- Info von article ref--> <br/>
|
||||
= <span th:text="${ArticleID.price}"></span> EUR Brutto
|
||||
</p>
|
||||
<p>
|
||||
<label for="max-price-buy">Maximaler Einkaufspreis (Netto)</label>
|
||||
<input class="" type="number" step="0.01" name="price" th:value="${ArticleID.reorderMaxPrice}"/> EUR
|
||||
<input class="" type="number" step="0.01" name="reorderMaxPrice" th:value="${ArticleID.reorderMaxPrice}"/> EUR
|
||||
</p>
|
||||
<div>
|
||||
<fieldset>
|
||||
|
@ -76,7 +76,7 @@
|
|||
<p>
|
||||
Bitte jede Kategorien in eine eigene Zeile
|
||||
</p>
|
||||
<textarea name="tags" class="full-width" rows="6"th:inline="text">[[${ArticleID.categorie}]]
|
||||
<textarea name="categories" class="full-width" rows="6"th:inline="text">[[${ArticleID.categorie}]]
|
||||
|
||||
</textarea>
|
||||
</div>
|
||||
|
@ -84,7 +84,7 @@
|
|||
<div class="s">
|
||||
<p>
|
||||
<label for="price">Einheiten pro Lagerplatz</label>
|
||||
<input class="" type="number" name="units-per-slot" th:field="${ArticleID.warehouseUnitsPerSlot}"/>
|
||||
<input class="" type="number" name="units-per-slot" th:value="${ArticleID.warehouseUnitsPerSlot}"/>
|
||||
</p>
|
||||
<p>
|
||||
<b>Lagerbestand: <span th:text="${ArticleID.stock}"></span></b>
|
||||
|
|
String[] separatedCategories
fixed with
a98782bc01