Esempio n. 1
0
def list_categories():
    parents, children = product_service.list_all_categories()
    categories = []
    for category in parents:
        p_cate_dict = category.__dict__
        if category.keyCategoryID not in children:
            p_cate_dict['Children'] = []
        else:
            p_cate_dict['Children'] = [
                child.__dict__ for child in children[category.keyCategoryID]
            ]
        categories.append(p_cate_dict)

    return jsonify(categories), 200
Esempio n. 2
0
def list_products_with_pagination():
    params = request.args
    category_id = params.get('cate')
    page = params.get('page')
    if category_id is not None:
        category_id = int(category_id)

    if page is not None:
        page = int(page)
    else:
        page = 1

    ret_set = product_service.list_all_products(category_id, page)

    items = [prod.basic_dict() for prod in ret_set['items']]
    ret_set['items'] = items
    return jsonify(ret_set), 200
Esempio n. 3
0
def update_product_categories():
    return jsonify(product_service.restore_category())
Esempio n. 4
0
def get_metadata_by_product_code():
    product_code = request.args.get('productCode')
    return jsonify(product_service.get_metadata_by_product_code(product_code))
Esempio n. 5
0
def import_threedmodel():
    data = request.get_json(silent=True)
    return jsonify(product_service.import_threedmodel(data))
Esempio n. 6
0
def import_metadata():
    data = request.get_json(silent=True)
    return jsonify(product_service.import_metadata(data))
Esempio n. 7
0
def update_product_price():
    return jsonify(product_service.update_prices())
Esempio n. 8
0
def retrieve_prices():
    return jsonify(product_service.retrieve_prices())
Esempio n. 9
0
def search_products():
    identifier = request.args.get('identifier')
    identifierType = request.args.get('identifierType')

    return jsonify(product_service.search_products(identifier, identifierType))
Esempio n. 10
0
def get_barcode_product():
    barcode = request.args.get('barcode')
    return jsonify(product_service.get_product_by_barcode(barcode))