load offeredArticles from DB and display basic info
This commit is contained in:
parent
d4be2b9e94
commit
d8032c2bd7
BIN
prototype/e-commerce.db.copy
Normal file
BIN
prototype/e-commerce.db.copy
Normal file
Binary file not shown.
@ -1,5 +1,5 @@
|
|||||||
INSERT INTO article_offers ("manufacturer", "article_number", "vat_percent", "should_be_advertised")
|
INSERT INTO article_offers ("manufacturer", "article_number", "price_per_unit_net", "title", "vat_percent", "should_be_advertised")
|
||||||
VALUES ("McDonalds", "1", 7, 1);
|
VALUES ("McDonalds", "1", 4242, "McPizza", 7, 1);
|
||||||
|
|
||||||
INSERT INTO articles ("related_id", "shop_price_per_unit_net_cent", "warehouse_units_per_slot", "should_reorder", "reorder_max_price", "title", "description", "image_id")
|
INSERT INTO articles ("related_id", "shop_price_per_unit_net_cent", "warehouse_units_per_slot", "should_reorder", "reorder_max_price", "title", "description", "image_id")
|
||||||
VALUES (1, 19.99, 10, 1, 15, "Huge Hamburger", "This huge Hamburger is awesome!", NULL);
|
VALUES (1, 19.99, 10, 1, 15, "Huge Hamburger", "This huge Hamburger is awesome!", NULL);
|
||||||
|
@ -3,6 +3,10 @@ package org.hso.ecommerce.controller.intern.suppliers;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.hso.ecommerce.entities.supplier.ArticleOffer;
|
||||||
|
import org.hso.ecommerce.repos.shop.CategoryRepository;
|
||||||
|
import org.hso.ecommerce.repos.shop.OffersRepository;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@ -14,29 +18,19 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
@RequestMapping("/intern/")
|
@RequestMapping("/intern/")
|
||||||
public class SupplierOfferController {
|
public class SupplierOfferController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private final OffersRepository offersRepository = null;
|
||||||
|
|
||||||
@GetMapping("supplierOffers")
|
@GetMapping("supplierOffers")
|
||||||
public String internListedArticles(Model model) {
|
public String internListedArticles(Model model) {
|
||||||
|
|
||||||
List<UImodelOfferedArticle> totals = new ArrayList<UImodelOfferedArticle>();
|
List<UImodelOfferedArticle> totals = new ArrayList<UImodelOfferedArticle>();
|
||||||
|
|
||||||
/*
|
for (ArticleOffer article : offersRepository.findAll()) {
|
||||||
* for (Article article : articleRepository.findAll()) { UImodelArticles tmp =
|
UImodelOfferedArticle tmp = new UImodelOfferedArticle();
|
||||||
* new UImodelArticles(); tmp.addListedArticle(article,
|
tmp.addData(article,"supplierName01", 4884, 5);
|
||||||
* warehouseEntryRepository.getArticleStock(article.id).orElse(0));
|
totals.add(tmp);
|
||||||
* totals.add(tmp); }
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
UImodelOfferedArticle tmp01 = new UImodelOfferedArticle();
|
|
||||||
UImodelOfferedArticle tmp02 = new UImodelOfferedArticle();
|
|
||||||
UImodelOfferedArticle tmp03 = new UImodelOfferedArticle();
|
|
||||||
|
|
||||||
tmp01.addData("Title01", "manufacturer01", "articlenumber01", "supplierName01", 4884, "42,42 €", "ads01", 5);
|
|
||||||
tmp02.addData("Title02", "manufacturer02", "articlenumber02", "supplierName02", 4884, "42,42 €", "ads02", 6);
|
|
||||||
tmp03.addData("Title03", "manufacturer03", "articlenumber03", "supplierName03", 4884, "42,42 €", "ads03", 7);
|
|
||||||
|
|
||||||
totals.add(tmp01);
|
|
||||||
totals.add(tmp02);
|
|
||||||
totals.add(tmp03);
|
|
||||||
|
|
||||||
model.addAttribute("OfferedArticles", totals);
|
model.addAttribute("OfferedArticles", totals);
|
||||||
return "intern/offeredArticles/index";
|
return "intern/offeredArticles/index";
|
||||||
@ -117,16 +111,15 @@ public class SupplierOfferController {
|
|||||||
this.listedArticleId = listedArticleId;
|
this.listedArticleId = listedArticleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addData(String title, String manufacturer, String articlenumber, String supplierName,
|
public void addData(ArticleOffer article, String supplierName, int supplierId, int listedArticleId) {
|
||||||
int supplierId, String price, String ads, int listedArticleId) {
|
|
||||||
|
|
||||||
this.title = title;
|
this.title = article.title;
|
||||||
this.manufacturer = manufacturer;
|
this.manufacturer = article.manufacturer;
|
||||||
this.articlenumber = articlenumber;
|
this.articlenumber = article.articleNumber;
|
||||||
this.supplierName = supplierName;
|
this.supplierName = supplierName;
|
||||||
this.supplierId = supplierId;
|
this.supplierId = supplierId;
|
||||||
this.price = price;
|
this.price = String.format("%.2f", ((float) article.pricePerUnitNet / 100));
|
||||||
this.ads = ads;
|
this.ads = (article.shouldBeAdvertised) ? "Ja" : "Nein";
|
||||||
this.listedArticleId = listedArticleId;
|
this.listedArticleId = listedArticleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,12 @@ public class ArticleOffer {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String manufacturer;
|
public String manufacturer;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String title;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public int pricePerUnitNet;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String articleNumber;
|
public String articleNumber;
|
||||||
@ -21,4 +27,6 @@ public class ArticleOffer {
|
|||||||
public int vatPercent;
|
public int vatPercent;
|
||||||
|
|
||||||
public boolean shouldBeAdvertised;
|
public boolean shouldBeAdvertised;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
package org.hso.ecommerce.repos.shop;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.hso.ecommerce.entities.supplier.ArticleOffer;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface OffersRepository extends JpaRepository<ArticleOffer, Long> {
|
||||||
|
|
||||||
|
@Query("SELECT a FROM ArticleOffer a")
|
||||||
|
List<ArticleOffer> findAll();
|
||||||
|
|
||||||
|
}
|
@ -15,7 +15,7 @@ public interface WarehouseBookingPositionSlotEntryRepository extends JpaReposito
|
|||||||
List<WarehouseBookingPositionSlotEntry> getByArticle(long article);
|
List<WarehouseBookingPositionSlotEntry> getByArticle(long article);
|
||||||
|
|
||||||
|
|
||||||
@Query(value = "SELECT SUM(w.new_sum_articles) FROM warehouse_booking_position_entries as w WHERE w.article_id = :articleid", nativeQuery = true)
|
@Query(value = "SELECT SUM(w.new_sum_slot) FROM warehouse_booking_position_entries as w WHERE w.article_id = :articleid", nativeQuery = true)
|
||||||
Optional<Integer> getArticleStock(long articleid);
|
Optional<Integer> getArticleStock(long articleid);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
<td><span th:text="${article.manufacturer}"></span></td>
|
<td><span th:text="${article.manufacturer}"></span></td>
|
||||||
<td><span th:text="${article.articlenumber}"></span></td>
|
<td><span th:text="${article.articlenumber}"></span></td>
|
||||||
<td><a th:href="@{/intern/suppliers/{id}(id = ${article.supplierId})}" th:text="${article.supplierName}"></a></td>
|
<td><a th:href="@{/intern/suppliers/{id}(id = ${article.supplierId})}" th:text="${article.supplierName}"></a></td>
|
||||||
<td><span th:text="${article.price}"></span></td>
|
<td><span th:text="${article.price}"></span> €</td>
|
||||||
<td><span th:text="${article.ads}"></span></td>
|
<td><span th:text="${article.ads}"></span></td>
|
||||||
<td><a th:href="@{/intern/articles/{id}(id = ${article.listedArticleId})}" th:text="${article.listedArticleId}"></a></td>
|
<td><a th:href="@{/intern/articles/{id}(id = ${article.listedArticleId})}" th:text="${article.listedArticleId}"></a></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
Reference in New Issue
Block a user