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
*/
@Nullable
@ -54,7 +54,7 @@ public class AddressDB {
}
/**
* get specific address.
* getAll specific address.
*
* @param id address id
* @return specific address

View File

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

View File

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

View File

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

View File

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

View File

@ -30,7 +30,7 @@ public class PaymentBean {
public List<CreditCardPayment> getCreditCard() {
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)
list.add((CreditCardPayment) payment);
}
@ -39,7 +39,7 @@ public class PaymentBean {
public List<DebitCardPayment> getDebitCard() {
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)
list.add((DebitCardPayment) payment);
}
@ -48,7 +48,7 @@ public class PaymentBean {
public List<PayPalPayment> getPayPal() {
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)
list.add((PayPalPayment) payment);
}
@ -57,7 +57,7 @@ public class PaymentBean {
public List<InvoicePayment> getInvoice() {
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)
list.add((InvoicePayment) payment);
}

View File

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