def list_unhandled_order(platform): user = request.args.get("user") password = request.args.get("password") if not user or not password: raise exception.BizException("用户或者密码不存在") cookie = vova_merchant.login(user, password) order_list = vova_merchant.get_unhandled_order(cookie) response = json_util.obj2json(order_list) return Response(response, mimetype='application/json')
def search_goods_by_image(): image_url = request.args.get("image_url") max_price = request.args.get("max_price") if not image_url or not max_price: raise ValueError("无效参数") num = request.args.get("num") if not num: num = 5 start_time = datetime.datetime.now() response = json_util.obj2json( ali1688.search_goods_by_image(image_url, float(max_price), int(num))) end_time = datetime.datetime.now() logging.info("search_goods_by_image cost {}(s)".format( (end_time - start_time).seconds)) return Response(response, mimetype='application/json')
def list_category_goods(platform): category_name = request.args.get("category") if not category_name: raise exception.BizException("类目不能为空") sort = request.args.get("sort") if not sort: sort = "recommended" cursor = request.args.get("cursor") category_info = vova.get_category_by_name(category_name) if not category_info: raise exception.BizException("无效的类目") start_time = datetime.datetime.now() response = json_util.obj2json( vova.get_category_goods(category_info, sort, cursor)) end_time = datetime.datetime.now() logging.info("list_category_goods cost {}(s)".format( (end_time - start_time).seconds)) return Response(response, mimetype='application/json')
def response_json_data(response): assert not isinstance(response, str) return Response(json_util.obj2json(response), mimetype='application/json')
def list_all_category(platform): category_list = vova.get_all_category() response = json_util.obj2json(category_list) return Response(response, mimetype='application/json')
def main(): goods_list = get_category_goods(_CATEGORY_BAG_WATCHES) print(json_util.obj2json(goods_list))