feature/offeredArticle #23

Merged
Seil0 merged 6 commits from feature/offeredArticle into master 2020-05-21 20:25:54 +02:00
7 changed files with 46 additions and 29 deletions
Showing only changes of commit d8032c2bd7 - Show all commits

Binary file not shown.

View File

@ -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);

View File

@ -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;
} }

View File

@ -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;
} }

View File

@ -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();
}

View File

@ -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);
} }

View File

@ -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>