-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
1,180 additions
and
151 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
archetype-empty/src/main/resources/archetype-resources/src/main/java/Init.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 16 additions & 15 deletions
31
archetype-empty/src/main/resources/archetype-resources/src/main/resources/banner.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
${AnsiColor.BRIGHT_GREEN} | ||
${AnsiColor.BRIGHT_GREEN} ██████ | ||
${AnsiColor.BRIGHT_GREEN} ██████ | ||
${AnsiColor.BRIGHT_GREEN} ██████ | ||
${AnsiColor.BRIGHT_GREEN} ███████ ███████████ ██████████ █████████ | ||
${AnsiColor.BRIGHT_GREEN} █████████ ███████████████ █████ ███████ █████████ | ||
${AnsiColor.BRIGHT_GREEN} █████████ █████████████████ ██████ ███████ █████████ | ||
${AnsiColor.BRIGHT_GREEN} ██████ ██████ ██████ █████████ ████ ██████ | ||
${AnsiColor.BRIGHT_GREEN} ██████ ██████ ███████ █████████ ████ ██████ | ||
${AnsiColor.BRIGHT_GREEN} █████████ ██████ ██████████ ██████ ███████ █████████ | ||
${AnsiColor.BRIGHT_GREEN} █████████ ██████ ████████ █████ ███████ ████████ | ||
${AnsiColor.BRIGHT_GREEN} ███████ ██████ ██████ ██████████ ██████ | ||
${AnsiColor.BRIGHT_GREEN} ██████ | ||
${AnsiColor.BRIGHT_GREEN} ██████ | ||
${AnsiColor.BRIGHT_GREEN} ██████ | ||
|
||
|
||
${AnsiColor.BRIGHT_GREEN} ██████████ | ||
${AnsiColor.BRIGHT_GREEN} ██████████████████ | ||
${AnsiColor.BRIGHT_GREEN} ██████████ ██████████████████████ ██████ ██████████ | ||
${AnsiColor.BRIGHT_GREEN} ████████████ ████████ ███████████ ████████ ███████████████ | ||
${AnsiColor.BRIGHT_GREEN} █████████████ ██████████ ██████████ █████████ ██████████████████ | ||
${AnsiColor.BRIGHT_GREEN} █████████████ █████████████ █████████ ██████████ ██████████████████ | ||
${AnsiColor.BRIGHT_GREEN} ████████ ███████████████ ███████ ████████ ████████ █████ | ||
${AnsiColor.BRIGHT_GREEN} ████████ ███████████████ ████████ ████████ ████████ ████ | ||
${AnsiColor.BRIGHT_GREEN} █████████████ █████████████ ██████████ ████████ ████████████████ | ||
${AnsiColor.BRIGHT_GREEN} █████████████ ██████████ ███████████ ████████ ████████████████ | ||
${AnsiColor.BRIGHT_GREEN} █████████████ ████████ ████████████ ████████ ████████████████ | ||
${AnsiColor.BRIGHT_GREEN} ████████████ ██████████████████████ ████████ ███████████████ | ||
${AnsiColor.BRIGHT_GREEN} ██████████████████ | ||
${AnsiColor.BRIGHT_GREEN} ██████████ | ||
|
||
${groupId}:${artifactId} ${application.version} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
spot-commerce-base/src/main/java/io/spotnext/commerce/facade/CartFacade.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.spotnext.commerce.facade; | ||
|
||
import io.spotnext.itemtype.commerce.order.CartData; | ||
import io.spotnext.itemtype.commerce.order.CartModificationResult; | ||
|
||
/** | ||
* <p> | ||
* CheckoutFacade interface. | ||
* </p> | ||
*/ | ||
public interface CartFacade { | ||
/** | ||
* Adds the product with the given ID and quantity to the current session cart | ||
* | ||
* @param productId | ||
* @param quantity | ||
*/ | ||
CartModificationResult addToCart(String productId, int quantity); | ||
|
||
/** | ||
* Returns the current session cart (creates a new one, if it doesn't exist) | ||
* | ||
* @return can never be null | ||
*/ | ||
CartData getCurrentCart(); | ||
|
||
/** | ||
* @return the amount of all items in the current session cart. | ||
*/ | ||
int getCurrentAmountOfCartItems(); | ||
} |
78 changes: 78 additions & 0 deletions
78
spot-commerce-base/src/main/java/io/spotnext/commerce/facade/impl/DefaultCartFacade.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package io.spotnext.commerce.facade.impl; | ||
|
||
import static io.spotnext.support.util.MiscUtil.$; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.stream.Collectors; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
|
||
import io.spotnext.commerce.facade.CartFacade; | ||
import io.spotnext.commerce.service.CartService; | ||
import io.spotnext.itemtype.commerce.enumeration.CartModificationOperation; | ||
import io.spotnext.itemtype.commerce.order.AbstractOrderEntry; | ||
import io.spotnext.itemtype.commerce.order.AbstractOrderEntryData; | ||
import io.spotnext.itemtype.commerce.order.Cart; | ||
import io.spotnext.itemtype.commerce.order.CartData; | ||
import io.spotnext.itemtype.commerce.order.CartEntryData; | ||
import io.spotnext.itemtype.commerce.order.CartModification; | ||
import io.spotnext.itemtype.commerce.order.CartModificationResult; | ||
import io.spotnext.itemtype.commerce.order.ProductData; | ||
|
||
public class DefaultCartFacade extends AbstractFacade implements CartFacade { | ||
|
||
@Autowired | ||
@Qualifier("cartService") | ||
private CartService cartService; | ||
|
||
@Override | ||
public CartModificationResult addToCart(String productId, int quantity) { | ||
final Optional<Cart> cart = cartService.getSessionCart(true); | ||
final Cart currentCart = cart.get(); | ||
|
||
final CartModification modification = new CartModification(); | ||
modification.setCartId(currentCart.getUid()); | ||
modification.setOperation(CartModificationOperation.ADD_ENTRY); | ||
modification.setProductId(productId); | ||
modification.setQuantity(quantity); | ||
|
||
return cartService.updateCart(modification); | ||
} | ||
|
||
@Override | ||
public CartData getCurrentCart() { | ||
return convertCart(cartService.getSessionCart(true).get()); | ||
} | ||
|
||
private CartData convertCart(Cart cart) { | ||
CartData cartData = new CartData(); | ||
|
||
cartData.setUid(cart.getUid()); | ||
cartData.setEntries((List<AbstractOrderEntryData>) cart.getEntries().stream().map(this::convertEntry).collect(Collectors.toList())); | ||
|
||
return cartData; | ||
} | ||
|
||
private AbstractOrderEntryData convertEntry(AbstractOrderEntry entry) { | ||
CartEntryData data = new CartEntryData(); | ||
|
||
data.setEntryNumber(entry.getEntryNumber()); | ||
data.setQuantity(entry.getQuantity()); | ||
|
||
ProductData product = new ProductData(); | ||
product.setUid(entry.getProduct().getUid()); | ||
product.setName($(() -> entry.getProduct().getName().get(), null)); | ||
product.setDescription($(() -> entry.getProduct().getDescription().get(), null)); | ||
|
||
data.setProduct(product); | ||
|
||
return data; | ||
} | ||
|
||
@Override | ||
public int getCurrentAmountOfCartItems() { | ||
return getCurrentCart().getEntries().stream().mapToInt(e -> e.getQuantity()).sum(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.