working order overview, design not done yet

Signed-off-by: Johannes Theiner <j.theiner@live.de>
This commit is contained in:
Johannes Theiner 2019-06-06 06:55:39 +02:00
parent ad17d0d80c
commit 6cf6e2f6e3
8 changed files with 15 additions and 20 deletions

View File

@ -26,9 +26,9 @@ public class AddressDB {
} }
/** /**
* get all addresses of specified user. * getAll all addresses of specified user.
* *
* @param user user to get addresses from * @param user user to getAll addresses from
* @return list of users addresses * @return list of users addresses
*/ */
@Nullable @Nullable
@ -54,7 +54,7 @@ public class AddressDB {
} }
/** /**
* get specific address. * getAll specific address.
* *
* @param id address id * @param id address id
* @return specific address * @return specific address

View File

@ -18,7 +18,7 @@ public class OrderDB {
} }
@Nullable @Nullable
public Order get(long id) { private Order get(long id, @NotNull User user) {
Map.Entry<ResultSet, Connection> entry = database.getResultSetById(database.tableOrder, id); Map.Entry<ResultSet, Connection> entry = database.getResultSetById(database.tableOrder, id);
assert entry != null; assert entry != null;
@ -30,7 +30,6 @@ public class OrderDB {
while (rs.next()) { while (rs.next()) {
List<OrderItem> items = getItems(id); List<OrderItem> items = getItems(id);
User user = database.user().get(rs.getLong("user"));
Payment payment = database.payment().get(rs.getLong("payment"), user); Payment payment = database.payment().get(rs.getLong("payment"), user);
Address address = database.address().get(rs.getLong("address"), user); Address address = database.address().get(rs.getLong("address"), user);
order = new Order(id, user, items, rs.getDate("date"), rs.getLong("price"), payment, address); order = new Order(id, user, items, rs.getDate("date"), rs.getLong("price"), payment, address);
@ -53,7 +52,7 @@ public class OrderDB {
ResultSet rs = entry.getKey(); ResultSet rs = entry.getKey();
rs.beforeFirst(); rs.beforeFirst();
while (rs.next()) { while (rs.next()) {
list.add(get(rs.getLong("id"))); list.add(get(rs.getLong("id"), user));
} }
} catch (SQLException ex) { } catch (SQLException ex) {
ex.printStackTrace(); ex.printStackTrace();

View File

@ -47,7 +47,7 @@ public class PaymentDB {
} }
@NotNull @NotNull
public List<? extends Payment> get(@NotNull User user) { public List<? extends Payment> getAll(@NotNull User user) {
List<Payment> list = new ArrayList<>(); List<Payment> list = new ArrayList<>();
Map.Entry<ResultSet, Connection> entry = database.getResultSetByValue(database.tableUserPayment, "user", user.getId()); Map.Entry<ResultSet, Connection> entry = database.getResultSetByValue(database.tableUserPayment, "user", user.getId());
if(entry == null) return list; if(entry == null) return list;
@ -55,7 +55,6 @@ public class PaymentDB {
try { try {
ResultSet rs = entry.getKey(); ResultSet rs = entry.getKey();
rs.beforeFirst(); rs.beforeFirst();
System.out.println(user);
while(rs.next()) { while(rs.next()) {
list.add(get(rs.getLong("id"), user)); list.add(get(rs.getLong("id"), user));
} }
@ -64,7 +63,6 @@ public class PaymentDB {
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
return list; return list;
} }
@ -73,8 +71,6 @@ public class PaymentDB {
Map.Entry<User, PaymentType> metadata = getMetadata(id); Map.Entry<User, PaymentType> metadata = getMetadata(id);
assert metadata != null; assert metadata != null;
System.out.println(user);
switch (metadata.getValue().getName()) { switch (metadata.getValue().getName()) {
case "PayPal": case "PayPal":
return getPayPal(id, user); return getPayPal(id, user);

View File

@ -28,9 +28,9 @@ public class ShoppingCartDB {
} }
/** /**
* get all items from users shopping cart. * getAll all items from users shopping cart.
* *
* @param user which users shopping cart to get. * @param user which users shopping cart to getAll.
* @return list of shopping cart items. * @return list of shopping cart items.
*/ */
@NotNull @NotNull

View File

@ -34,12 +34,12 @@ public class Order {
@NonNull private Payment payment; @NonNull private Payment payment;
@NonNull private Address address; @NonNull private Address address;
public List<String> getItemNames() { public String getItemNames() {
List<String> titles = new ArrayList<>(); List<String> titles = new ArrayList<>();
for(OrderItem item : items) { for(OrderItem item : items) {
titles.add(item.getBook().getTitle()); titles.add(item.getBook().getTitle());
} }
return titles; return String.join(", ", titles);
} }
} }

View File

@ -25,7 +25,6 @@ public class OrderBean {
} }
public List<Order> getOrders() { public List<Order> getOrders() {
System.out.println(getUser());
return Database.getInstance().order().getAll(getUser()); return Database.getInstance().order().getAll(getUser());
} }
} }

View File

@ -30,7 +30,7 @@ public class PaymentBean {
public List<CreditCardPayment> getCreditCard() { public List<CreditCardPayment> getCreditCard() {
List<CreditCardPayment> list = new ArrayList<>(); List<CreditCardPayment> list = new ArrayList<>();
for(Payment payment : Database.getInstance().payment().get(getUser())) { for(Payment payment : Database.getInstance().payment().getAll(getUser())) {
if(payment instanceof CreditCardPayment) if(payment instanceof CreditCardPayment)
list.add((CreditCardPayment) payment); list.add((CreditCardPayment) payment);
} }
@ -39,7 +39,7 @@ public class PaymentBean {
public List<DebitCardPayment> getDebitCard() { public List<DebitCardPayment> getDebitCard() {
List<DebitCardPayment> list = new ArrayList<>(); List<DebitCardPayment> list = new ArrayList<>();
for(Payment payment : Database.getInstance().payment().get(getUser())) { for(Payment payment : Database.getInstance().payment().getAll(getUser())) {
if(payment instanceof DebitCardPayment) if(payment instanceof DebitCardPayment)
list.add((DebitCardPayment) payment); list.add((DebitCardPayment) payment);
} }
@ -48,7 +48,7 @@ public class PaymentBean {
public List<PayPalPayment> getPayPal() { public List<PayPalPayment> getPayPal() {
List<PayPalPayment> list = new ArrayList<>(); List<PayPalPayment> list = new ArrayList<>();
for (Payment payment : Database.getInstance().payment().get(getUser())) { for (Payment payment : Database.getInstance().payment().getAll(getUser())) {
if(payment instanceof PayPalPayment) if(payment instanceof PayPalPayment)
list.add((PayPalPayment) payment); list.add((PayPalPayment) payment);
} }
@ -57,7 +57,7 @@ public class PaymentBean {
public List<InvoicePayment> getInvoice() { public List<InvoicePayment> getInvoice() {
List<InvoicePayment> list = new ArrayList<>(); List<InvoicePayment> list = new ArrayList<>();
for(Payment payment : Database.getInstance().payment().get(getUser())) { for(Payment payment : Database.getInstance().payment().getAll(getUser())) {
if(payment instanceof InvoicePayment) if(payment instanceof InvoicePayment)
list.add((InvoicePayment) payment); list.add((InvoicePayment) payment);
} }

View File

@ -15,6 +15,7 @@
<div class="m-col-t-12"> <div class="m-col-t-12">
<div class="m-block m-primary"> <div class="m-block m-primary">
#{order.itemNames} #{order.itemNames}
#{order.payment.type.name}
</div> </div>
</div> </div>
</div> </div>