def getAllItem(): UserId = '1' q = 'select * from foods, TopRecent where TopRecent.UserId = \"' + UserId + '\" and foods.FoodId = TopRecent.FoodId ;' maindata = invertData(query_exec(q)) maindata = db_handler.removeUserId(maindata) q = 'select * from Bag where UserId = \"' + UserId + '\";' tempdata = db_handler.removeUserId(query_exec(q)) result = db_handler.joindata(maindata, tempdata, 'FoodId', 'quantity', 0) return result
def getSomeFoods(FoodType): UserId = '1' q = 'select * from foods where FoodType = \"' + FoodType + '\";' maindata = query_exec(q) q = 'select * from Bag where UserId = \"' + UserId + '\";' tempdata = db_handler.removeUserId(query_exec(q)) result = db_handler.joindata(maindata, tempdata, 'FoodId', 'quantity', 0) return result
def removePromotion(code): UserId = '1' if len( db_handler.removeUserId( db.query_exec('select * from promotion where code = \"' + code + '\";'))) == 0: raise HTTPException(status_code=500, detail='Code not found') q = 'delete from promotion where UserId = \"' + UserId + '\" and code = \"' + str( code) + '\"' db.query_exec(q) return {'status': 'oke'}
def updateTopRecent(FoodId): UserId = '1' int(FoodId) limitTopRecent = 5 q = 'delete from TopRecent where FoodId = \"' + FoodId + '\";' query_exec(q) q = "select count(*) as cur_num from TopRecent;" result = query_exec(q) cur_num = int(result[0]['cur_num']) if cur_num >= limitTopRecent: q = 'select * from TopRecent;' last_id = query_exec(q)[0]['FoodId'] q = 'delete from TopRecent where FoodId = \"' + last_id + '\";' query_exec(q) q = 'insert into TopRecent values(\"' + FoodId + '\", \"1\")' result = query_exec(q) q = 'select * from foods, TopRecent where TopRecent.UserId = \"' + UserId + '\" and foods.FoodId = TopRecent.FoodId ;' maindata = invertData(query_exec(q)) maindata = db_handler.removeUserId(maindata) q = 'select * from Bag where UserId = \"' + UserId + '\";' tempdata = db_handler.removeUserId(query_exec(q)) result = db_handler.joindata(maindata, tempdata, 'FoodId', 'quantity', 0) return result
def getAllItem(): UserId = '1' q = 'select * from promotion where UserId = \"' + UserId + '\";' result = db_handler.removeUserId(db.query_exec(q)) return result
def getItem(code: str): q = 'select * from promotion where code = \"' + code + '\";' result = db_handler.removeUserId(db.query_exec(q)) if len(result) == 0: raise HTTPException(status_code=500, detail='Code not found') return result[0]
def getAllItem(): UserId = '1' q = 'select * from foods, Bag where Bag.UserId = \"' + UserId + '\" and Bag.FoodId = foods.FoodId;' result = query_exec(q) result = db_handler.removeUserId(result) return result