From 286edb33ed48fe24fbc541ee6a13508a0093c85b Mon Sep 17 00:00:00 2001 From: localhorst Date: Sat, 30 May 2020 11:52:30 +0200 Subject: [PATCH] show supplier name at offered article page --- .../suppliers/SupplierOfferController.java | 24 ++++++------------- .../entities/supplier/ArticleOffer.java | 3 ++- .../intern/offeredArticles/index.html | 2 +- 3 files changed, 10 insertions(+), 19 deletions(-) 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 3ef21bf..7d27059 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 @@ -30,7 +30,8 @@ public class SupplierOfferController { for (ArticleOffer article : offersRepository.findAll()) { UImodelOfferedArticle tmp = new UImodelOfferedArticle(); - tmp.addData(article, "supplierName01", 4884, articleRepository.findArticleIDByRelatedID(article.id)); //TODO display supplier name with link + tmp.addData(article, articleRepository.findArticleIDByRelatedID(article.id)); // TODO display supplier name + // with link totals.add(tmp); } @@ -40,16 +41,15 @@ public class SupplierOfferController { public class UImodelOfferedArticle { - long offer_id; + long offer_id; String title; String manufacturer; String articlenumber; String supplierName; - int supplierId; String price; String ads; int listedArticleId; - boolean offerIsListed; //true --> offered article is listed + boolean offerIsListed; // true --> offered article is listed public long getOffer_id() { return offer_id; @@ -58,7 +58,7 @@ public class SupplierOfferController { public void setOffer_id(long offer_id) { this.offer_id = offer_id; } - + public boolean isOfferIsListed() { return offerIsListed; } @@ -99,14 +99,6 @@ public class SupplierOfferController { this.supplierName = supplierName; } - public int getSupplierId() { - return supplierId; - } - - public void setSupplierId(int supplierId) { - this.supplierId = supplierId; - } - public String getPrice() { return price; } @@ -131,15 +123,13 @@ public class SupplierOfferController { this.listedArticleId = listedArticleId; } - public void addData(ArticleOffer article, String supplierName, int supplierId, - Optional listedArticleId) { + public void addData(ArticleOffer article, Optional listedArticleId) { this.offer_id = article.id; this.title = article.title; this.manufacturer = article.manufacturer; this.articlenumber = article.articleNumber; - this.supplierName = supplierName; - this.supplierId = supplierId; + this.supplierName = article.cheapestSupplier.name; this.price = String.format("%.2f", ((float) article.pricePerUnitNet / 100)); this.ads = (article.shouldBeAdvertised) ? "Ja" : "Nein"; 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 405fb4a..8c20099 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 @@ -28,5 +28,6 @@ public class ArticleOffer { public boolean shouldBeAdvertised; - + @ManyToOne(optional = false) + public Supplier cheapestSupplier; } diff --git a/prototype/src/main/resources/templates/intern/offeredArticles/index.html b/prototype/src/main/resources/templates/intern/offeredArticles/index.html index 79d926a..04d9a12 100644 --- a/prototype/src/main/resources/templates/intern/offeredArticles/index.html +++ b/prototype/src/main/resources/templates/intern/offeredArticles/index.html @@ -44,7 +44,7 @@ - +