Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def create_user():
"""注册用户
"""
data = request.get_json()
password = data.pop('password')
user = UserSchema().load(data)
user.password = password
session.add(user)
session.commit()
return json_response(user=UserSchema().dump(user))
def create_shop():
"""创建店铺
"""
data = request.get_json()
shop = ShopSchema().load(data)
session.add(shop)
session.commit()
return json_response(shop=ShopSchema().dump(shop))
def create_address():
"""添加地址
"""
data = request.get_json()
address = AddressSchema().load(data)
session.add(address)
session.commit()
return json_response(address=AddressSchema().dump(address))
def create_user():
"""注册用户
"""
data = request.get_json()
password = data.pop('password')
user = UserSchema().load(data)
user.password = password
session.add(user)
session.commit()
return json_response(user=UserSchema().dump(user))
def create_order():
"""创建订单,订单商品需要一起提交
"""
data = request.get_json()
if data.get('pay_amount') is None:
data['pay_amount'] = sum([x['price'] * x['amount']
for x in data['order_products']])
order = OrderSchema().load(data)
session.add(order)
session.commit()
return json_response(order=OrderSchema().dump(order))
def create_product():
"""创建商品
"""
data = request.get_json()
product = ProductSchema().load(data)
session.add(product)
session.commit()
return json_response(product=ProductSchema().dump(product))
def create_shop():
"""创建店铺
"""
data = request.get_json()
shop = ShopSchema().load(data)
session.add(shop)
session.commit()
return json_response(shop=ShopSchema().dump(shop))