load offeredArticles from DB and display basic info
This commit is contained in:
parent
d4be2b9e94
commit
d8032c2bd7
Binary file not shown.
|
@ -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);
|
||||
|
|
|
@ -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<UImodelOfferedArticle> totals = new ArrayList<UImodelOfferedArticle>();
|
||||
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
||||
@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);
|
||||
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
<td><span th:text="${article.manufacturer}"></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><span th:text="${article.price}"></span></td>
|
||||
<td><span th:text="${article.price}"></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>
|
||||
</tr>
|
||||
|
|
Reference in New Issue