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
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
def update_product_categories(): return jsonify(product_service.restore_category())
def get_metadata_by_product_code(): product_code = request.args.get('productCode') return jsonify(product_service.get_metadata_by_product_code(product_code))
def import_threedmodel(): data = request.get_json(silent=True) return jsonify(product_service.import_threedmodel(data))
def import_metadata(): data = request.get_json(silent=True) return jsonify(product_service.import_metadata(data))
def update_product_price(): return jsonify(product_service.update_prices())
def retrieve_prices(): return jsonify(product_service.retrieve_prices())
def search_products(): identifier = request.args.get('identifier') identifierType = request.args.get('identifierType') return jsonify(product_service.search_products(identifier, identifierType))
def get_barcode_product(): barcode = request.args.get('barcode') return jsonify(product_service.get_product_by_barcode(barcode))