def get_top_10_rank(cls) -> List[Dict[str, Any]]: query = (RFIDTable.select( RFIDTable.point, StudentTable.name).join(StudentTable).order_by( RFIDTable.point.desc()).limit(10)) rows = execute_sql(query) return rows
def get_info_by_token(cls, user_id: str) -> Dict[str, Any]: query = (RFIDTable.select(StudentTable.number, StudentTable.name, RFIDTable.point).join(StudentTable).where( StudentTable.id == user_id)) rows = execute_sql(query) return rows[0]
def get_info_by_rfid(cls, rfid: str) -> Dict[str, Any]: query = (RFIDTable.select( StudentTable.number, StudentTable.name, RFIDTable.point, RFIDTable.level).join(StudentTable).where(RFIDTable.rfid == rfid)) rows = execute_sql(query) if not rows: raise WrongAuthException() return rows[0]
def get_history(cls, user_id: str) -> List[Dict[str, Any]]: query = ( BoothTable .select(BoothTable.booth_name, HistoryTable.point) .join(HistoryTable, on=HistoryTable.used_booth == BoothTable.booth_id) .join(RFIDTable) .where(RFIDTable.student_id == user_id) ) rows = execute_sql(query) return rows
def is_used(cls, rfid: str, booth_id: int) -> bool: query = ( HistoryTable .select(HistoryTable.used_booth) .where( (HistoryTable.rfid == rfid) & (HistoryTable.used_booth == booth_id) ) ) row = execute_sql(query) if not row: return False return True