diff --git a/prototype/e-commerce.db.copy b/prototype/e-commerce.db.copy new file mode 100644 index 0000000..e4c39c9 Binary files /dev/null and b/prototype/e-commerce.db.copy differ diff --git a/prototype/scripts/addarticles.sql b/prototype/scripts/addarticles.sql index f7e5f5b..b60497d 100644 --- a/prototype/scripts/addarticles.sql +++ b/prototype/scripts/addarticles.sql @@ -1,5 +1,5 @@ -INSERT INTO article_offers ("manufacturer", "article_number", "vat_percent", "should_be_advertised") -VALUES ("McDonalds", "1", 7, 1); +INSERT INTO article_offers ("manufacturer", "article_number", "price_per_unit_net", "title", "vat_percent", "should_be_advertised") +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") VALUES (1, 19.99, 10, 1, 15, "Huge Hamburger", "This huge Hamburger is awesome!", NULL); diff --git a/prototype/src/main/java/org/hso/ecommerce/controller/intern/suppliers/SupplierOfferController.java b/prototype/src/main/java/org/hso/ecommerce/controller/intern/suppliers/SupplierOfferController.java index 501d749..685f8f8 100644 --- a/prototype/src/main/java/org/hso/ecommerce/controller/intern/suppliers/SupplierOfferController.java +++ b/prototype/src/main/java/org/hso/ecommerce/controller/intern/suppliers/SupplierOfferController.java @@ -3,6 +3,10 @@ package org.hso.ecommerce.controller.intern.suppliers; import java.util.ArrayList; 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.ui.Model; import org.springframework.web.bind.annotation.GetMapping; @@ -14,29 +18,19 @@ import org.springframework.web.bind.annotation.RequestParam; @RequestMapping("/intern/") public class SupplierOfferController { + @Autowired + private final OffersRepository offersRepository = null; + @GetMapping("supplierOffers") public String internListedArticles(Model model) { List totals = new ArrayList(); - /* - * for (Article article : articleRepository.findAll()) { UImodelArticles tmp = - * new UImodelArticles(); tmp.addListedArticle(article, - * warehouseEntryRepository.getArticleStock(article.id).orElse(0)); - * 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); + for (ArticleOffer article : offersRepository.findAll()) { + UImodelOfferedArticle tmp = new UImodelOfferedArticle(); + tmp.addData(article,"supplierName01", 4884, 5); + totals.add(tmp); + } model.addAttribute("OfferedArticles", totals); return "intern/offeredArticles/index"; @@ -117,16 +111,15 @@ public class SupplierOfferController { this.listedArticleId = listedArticleId; } - public void addData(String title, String manufacturer, String articlenumber, String supplierName, - int supplierId, String price, String ads, int listedArticleId) { + public void addData(ArticleOffer article, String supplierName, int supplierId, int listedArticleId) { - this.title = title; - this.manufacturer = manufacturer; - this.articlenumber = articlenumber; + this.title = article.title; + this.manufacturer = article.manufacturer; + this.articlenumber = article.articleNumber; this.supplierName = supplierName; this.supplierId = supplierId; - this.price = price; - this.ads = ads; + this.price = String.format("%.2f", ((float) article.pricePerUnitNet / 100)); + this.ads = (article.shouldBeAdvertised) ? "Ja" : "Nein"; this.listedArticleId = listedArticleId; } diff --git a/prototype/src/main/java/org/hso/ecommerce/entities/supplier/ArticleOffer.java b/prototype/src/main/java/org/hso/ecommerce/entities/supplier/ArticleOffer.java index ae86659..405fb4a 100644 --- a/prototype/src/main/java/org/hso/ecommerce/entities/supplier/ArticleOffer.java +++ b/prototype/src/main/java/org/hso/ecommerce/entities/supplier/ArticleOffer.java @@ -14,6 +14,12 @@ public class ArticleOffer { @NotNull public String manufacturer; + + @NotNull + public String title; + + @NotNull + public int pricePerUnitNet; @NotNull public String articleNumber; @@ -21,4 +27,6 @@ public class ArticleOffer { public int vatPercent; public boolean shouldBeAdvertised; + + } diff --git a/prototype/src/main/java/org/hso/ecommerce/repos/shop/OffersRepository.java b/prototype/src/main/java/org/hso/ecommerce/repos/shop/OffersRepository.java new file mode 100644 index 0000000..b1d6f0a --- /dev/null +++ b/prototype/src/main/java/org/hso/ecommerce/repos/shop/OffersRepository.java @@ -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 { + + @Query("SELECT a FROM ArticleOffer a") + List findAll(); + +} diff --git a/prototype/src/main/java/org/hso/ecommerce/repos/warehouse/WarehouseBookingPositionSlotEntryRepository.java b/prototype/src/main/java/org/hso/ecommerce/repos/warehouse/WarehouseBookingPositionSlotEntryRepository.java index b342a06..cb9902e 100644 --- a/prototype/src/main/java/org/hso/ecommerce/repos/warehouse/WarehouseBookingPositionSlotEntryRepository.java +++ b/prototype/src/main/java/org/hso/ecommerce/repos/warehouse/WarehouseBookingPositionSlotEntryRepository.java @@ -15,7 +15,7 @@ public interface WarehouseBookingPositionSlotEntryRepository extends JpaReposito List 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 getArticleStock(long articleid); } diff --git a/prototype/src/main/resources/templates/intern/offeredArticles/index.html b/prototype/src/main/resources/templates/intern/offeredArticles/index.html index dfb36be..cfa6913 100644 --- a/prototype/src/main/resources/templates/intern/offeredArticles/index.html +++ b/prototype/src/main/resources/templates/intern/offeredArticles/index.html @@ -45,7 +45,7 @@ - +