48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
import database
|
|
from flask import Blueprint, jsonify, request
|
|
from flask_jwt_extended import get_jwt_identity
|
|
|
|
from routes.utils import jwt_protect_blueprint
|
|
import sipro.api.orders
|
|
|
|
orders_blueprint = jwt_protect_blueprint(Blueprint('orders', __name__))
|
|
|
|
|
|
@orders_blueprint.get('/<int:order_id>')
|
|
def get_order(order_id: int):
|
|
return jsonify(id=order_id)
|
|
|
|
|
|
@orders_blueprint.get('/getOrders')
|
|
def get_orders():
|
|
args = request.args
|
|
order_by = args.get('orderBy')
|
|
desc = int(args.get('desc'))
|
|
page = int(args.get('page'))
|
|
shipment_date = args.get('shipmentDate')
|
|
status = args.get('status')
|
|
shipment_warehouse_id = int(args.get('shipmentWarehouseId'))
|
|
response = sipro.api.orders.get_orders(order_by,
|
|
desc,
|
|
page,
|
|
shipment_date,
|
|
status,
|
|
shipment_warehouse_id)
|
|
return jsonify(response)
|
|
|
|
|
|
@orders_blueprint.get('/getByProductId')
|
|
def get_orders_by_supplier_product_id():
|
|
#user_id = get_jwt_identity()
|
|
#city_id = database.db.session.get(database.User, user_id).city_id
|
|
params = dict(request.args)
|
|
#params['city'] = city_id
|
|
return sipro.api.orders.get_orders_from_barcode(params=params)
|
|
|
|
|
|
@orders_blueprint.get('/getOrderById')
|
|
def get_order_by_id():
|
|
args = request.args
|
|
order_id = args.get('orderId')
|
|
return sipro.api.orders.get_order_by_id(order_id)
|