WIP feature/listedArticles #15
|
@ -3,6 +3,9 @@ package org.hso.ecommerce.controller.intern;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.hso.ecommerce.entities.shop.Article;
|
import org.hso.ecommerce.entities.shop.Article;
|
||||||
import org.hso.ecommerce.repos.shop.ArticleRepository;
|
import org.hso.ecommerce.repos.shop.ArticleRepository;
|
||||||
import org.hso.ecommerce.repos.warehouse.WarehouseBookingPositionSlotEntryRepository;
|
import org.hso.ecommerce.repos.warehouse.WarehouseBookingPositionSlotEntryRepository;
|
||||||
|
@ -40,30 +43,52 @@ public class InternArticleController {
|
||||||
public String internListedArticlesId(Model model, @PathVariable String id) {
|
public String internListedArticlesId(Model model, @PathVariable String id) {
|
||||||
|
|
||||||
int articleid = Integer.parseInt(id);
|
int articleid = Integer.parseInt(id);
|
||||||
|
|
||||||
ListedArticlesListIdTotal total = new ListedArticlesListIdTotal();
|
ListedArticlesListIdTotal total = new ListedArticlesListIdTotal();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
total.addArticle(articleRepository.findArticleById(articleid),
|
total.addArticle(articleRepository.findArticleById(articleid),
|
||||||
warehouseEntryRepository.getArticleStock(articleid).orElse(0));
|
warehouseEntryRepository.getArticleStock(articleid).orElse(0));
|
||||||
|
|
||||||
|
|
||||||
|
// System.out.println("GETshouldReorder: " + articleRepository.findArticleById(articleid).shouldReorder);
|
||||||
|
|
||||||
model.addAttribute("ArticleID", total);
|
model.addAttribute("ArticleID", total);
|
||||||
|
|
||||||
return "intern/listedArticles/id";
|
return "intern/listedArticles/id";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/{id}/saveChanges")
|
|
||||||
public RedirectView saveChanges() {
|
|
||||||
|
|
||||||
System.out.println("\n------ POST -----\n");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/{id}/saveChanges")
|
||||||
|
public RedirectView saveChanges(@ModelAttribute ListedArticlesListIdTotal changedArticleTotal) {
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
articleRepository.save(oldArticle); // save updated article
|
||||||
return new RedirectView("../");
|
return new RedirectView("../");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class ListedArticlesListTotals {
|
public static class ListedArticlesListTotals {
|
||||||
|
|
||||||
|
@ -97,6 +122,102 @@ public class InternArticleController {
|
||||||
|
|
||||||
public static class ListedArticlesListIdTotal {
|
public static class ListedArticlesListIdTotal {
|
||||||
|
|
||||||
|
public String getImgPath() {
|
||||||
|
return imgPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImgPath(String imgPath) {
|
||||||
|
this.imgPath = imgPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrice() {
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrice(String price) {
|
||||||
|
this.price = price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrice_netto() {
|
||||||
|
return price_netto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrice_netto(String price_netto) {
|
||||||
|
this.price_netto = price_netto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getReorderMaxPrice() {
|
||||||
|
return reorderMaxPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReorderMaxPrice(int reorderMaxPrice) {
|
||||||
|
this.reorderMaxPrice = reorderMaxPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCategorie() {
|
||||||
|
return categorie;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategorie(String categorie) {
|
||||||
|
this.categorie = categorie;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStock() {
|
||||||
|
return stock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStock(int stock) {
|
||||||
|
this.stock = stock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getOffer_id() {
|
||||||
|
return offer_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOffer_id(long offer_id) {
|
||||||
|
this.offer_id = offer_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isShouldReorder() {
|
||||||
|
return shouldReorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShouldReorder(boolean shouldReorder) {
|
||||||
|
this.shouldReorder = shouldReorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWarehouseUnitsPerSlot() {
|
||||||
|
return warehouseUnitsPerSlot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWarehouseUnitsPerSlot(String warehouseUnitsPerSlot) {
|
||||||
|
this.warehouseUnitsPerSlot = warehouseUnitsPerSlot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
public String imgPath;
|
public String imgPath;
|
||||||
public String title;
|
public String title;
|
||||||
public String price;
|
public String price;
|
||||||
|
@ -107,7 +228,7 @@ public class InternArticleController {
|
||||||
public long offer_id;
|
public long offer_id;
|
||||||
public long id;
|
public long id;
|
||||||
public boolean shouldReorder;
|
public boolean shouldReorder;
|
||||||
public int warehouseUnitsPerSlot;
|
public String warehouseUnitsPerSlot;
|
||||||
public String description;
|
public String description;
|
||||||
|
|
||||||
void addArticle(Article article, int stock) {
|
void addArticle(Article article, int stock) {
|
||||||
|
@ -121,7 +242,7 @@ public class InternArticleController {
|
||||||
this.id = article.id;
|
this.id = article.id;
|
||||||
this.reorderMaxPrice = article.reorderMaxPrice;
|
this.reorderMaxPrice = article.reorderMaxPrice;
|
||||||
this.shouldReorder = article.shouldReorder;
|
this.shouldReorder = article.shouldReorder;
|
||||||
this.warehouseUnitsPerSlot = article.warehouseUnitsPerSlot;
|
this.warehouseUnitsPerSlot = String.valueOf(article.warehouseUnitsPerSlot);
|
||||||
this.description = article.description;
|
this.description = article.description;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,7 @@ import org.springframework.stereotype.Repository;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface ArticleRepository extends JpaRepository<Article, Long>
|
public interface ArticleRepository extends JpaRepository<Article, Long> {
|
||||||
{
|
|
||||||
|
|
||||||
@Query("SELECT a FROM Article a WHERE a.id = :articleId")
|
@Query("SELECT a FROM Article a WHERE a.id = :articleId")
|
||||||
Article findArticleById(@Param("articleId") long articleId);
|
Article findArticleById(@Param("articleId") long articleId);
|
||||||
|
|
|
@ -25,7 +25,11 @@
|
||||||
<nav th:replace="fragments/intern :: sidebar"></nav>
|
<nav th:replace="fragments/intern :: sidebar"></nav>
|
||||||
<div class="content-width">
|
<div class="content-width">
|
||||||
<h2>Gelisteter Artikel ID <span th:text="${ArticleID.id}"></span></h2>
|
<h2>Gelisteter Artikel ID <span th:text="${ArticleID.id}"></span></h2>
|
||||||
<form class="detailgrid" action="/intern/articles/5/saveChanges" method="POST">
|
|
||||||
|
|
||||||
|
<form class="detailgrid" action="#" th:action="@{/intern/articles/{id}/saveChanges(id = ${ArticleID.id})}" th:object="${ArticleID}" method="POST">
|
||||||
|
|
||||||
|
|
||||||
<p class="m">
|
<p class="m">
|
||||||
<label for="title">Titel</label>
|
<label for="title">Titel</label>
|
||||||
<input class=" full-width" type="text" name="title" th:value="${ArticleID.title}"/>
|
<input class=" full-width" type="text" name="title" th:value="${ArticleID.title}"/>
|
||||||
|
@ -33,7 +37,7 @@
|
||||||
<p class="s">
|
<p class="s">
|
||||||
<label for="ref-article">Refernzierter Artikel</label>
|
<label for="ref-article">Refernzierter Artikel</label>
|
||||||
<input class="" type="text" name="ref-article" th:value="${ArticleID.offer_id}" disabled/>
|
<input class="" type="text" name="ref-article" th:value="${ArticleID.offer_id}" disabled/>
|
||||||
<td><a th:href="@{/intern/articles/{id}(id = ${ArticleID.offer_id})}">Details</a></td>
|
<td><a th:href="@{/intern/suppliers/articles/{id}(id = ${ArticleID.offer_id})}">Details</a></td>
|
||||||
</p>
|
</p>
|
||||||
<div class="spacer"></div>
|
<div class="spacer"></div>
|
||||||
<div class="m">
|
<div class="m">
|
||||||
|
@ -80,7 +84,7 @@
|
||||||
<div class="s">
|
<div class="s">
|
||||||
<p>
|
<p>
|
||||||
<label for="price">Einheiten pro Lagerplatz</label>
|
<label for="price">Einheiten pro Lagerplatz</label>
|
||||||
<input class="" type="number" name="units-per-slot" th:value="${ArticleID.warehouseUnitsPerSlot}"/>
|
<input class="" type="number" name="units-per-slot" th:field="${ArticleID.warehouseUnitsPerSlot}"/>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<b>Lagerbestand: <span th:text="${ArticleID.stock}"></span></b>
|
<b>Lagerbestand: <span th:text="${ArticleID.stock}"></span></b>
|
||||||
|
|
Reference in New Issue
String[] separatedCategories
fixed with
a98782bc01