def get(self, menu_id): try: categorys = Categoty.objects(menu_id=menu_id) except Exception: return {'message': "this menu id is wrong"}, 404 return mlab.list2json(categorys), 200
def post(self): #Post trên server sẽ lấy đủ đơn hàng, post trên local sẽ thiếu đơn hàng body = parser.parse_args() items = body["items"] user_id = body.user_id total_spend = 0 order_item = [] dumps = json.dumps(items) ldumps = re.findall(r"[\w']+", dumps) print(len(items)) for i in range(0, len(items) + 1): try: good_id = ldumps[4 * i + 1][1:-1] count = int(ldumps[4 * i + 3]) good = Good.objects().with_id(good_id) price = good.price total_spend += price * count singleOrder = SingleOrder(good=good, count=count) order_item.append(singleOrder) except: print("Index error") print("order_item:", mlab.list2json(order_item)) customer = Customer.objects().with_id(user_id) order = Order(items=order_item, customer=customer, totalspend=total_spend) order.save() add_order = Order.objects().with_id(order.id) return mlab.item2json(add_order)
def get(self): restaurants = Restaurant.objects() if not restaurants: message = {"message": "No restaurant found"} resp = jsonify(message) resp.status_code = 200 else: resp = jsonify(mlab.list2json(restaurants)) resp.status_code = 200 # resp= mlab.list2json(restaurants) return resp
def get(self): return mlab.list2json(Account.objects)
def get(self): return mlab.list2json(Feedback.objects)
def get(self): orders = Order.objects() return mlab.list2json(orders)
def get(self): orders = Order.objects(is_Success=False) return mlab.list2json(orders)
def get(self): food = Food.objects() return mlab.list2json(food)
def get(self): good = Good.objects() return mlab.list2json(good), 200
def get(self): print("get all user") customer = Customer.objects() return mlab.list2json(customer), 200
def get(self): rage = Rage.objects() return mlab.list2json(rage), 200
def get(self): menu = Menu.objects() if menu is None: return {"message": "menu is null"} menu_json = mlab.list2json(menu) return menu_json
def get(self): cate = Categoty.objects() return mlab.list2json(cate)
def get(self): # get all item items = Item.objects() return mlab.list2json(items), 200
def get(self, id_user): movie_list = Movie.objects(id_user__istartswith=id_user) return mlab.list2json(movie_list)
def get(self, cate_id): item = Item.objects(cate_id=cate_id) return mlab.list2json(item)
def get(self, menu_id): items = Item.objects(menu_id=menu_id) return mlab.list2json(items)
def get(self, id): rage = Rage.objects().with_id(id) comments = Comment.objects(rage=rage) return mlab.list2json(comments), 200