基础购物车微服务的实现与运行
1. 购物车模块的实现
首先,我们来看购物车模块的实现代码:
public class ShoppingCartModule : NancyModule
{
public ShoppingCartModule(
IShoppingCartStore shoppingCartStore,
IProductCatalogClient productCatalog,
IEventStore eventStore)
: base("/shoppingcart")
{
Get("/{userid:int}]", parameters => { ... });
Post("/{userid:int}/items",
async (parameters, _) => { ... });
Delete("/{userid:int}/items", parameters =>
{
var productCatalogIds = this.Bind<int[]>();
var userId = (int)parameters.userid;
var shoppingCart = shoppingCartStore.Get(userId);
shoppingCart.RemoveItems(productCatalogIds, eventSt
超级会员免费看
订阅专栏 解锁全文
168万+

被折叠的 条评论
为什么被折叠?



