Fetch applicant from database

This commit is contained in:
Yuri Becker
2025-04-19 00:55:12 +02:00
parent 2832becccf
commit 0ae153617b
5 changed files with 45 additions and 61 deletions

View File

@@ -6,40 +6,30 @@ from PySide6.QtCore import QObject, Signal
class EmployeeDAO(QObject):
newEmployeeAdded = Signal(bool)
__cur = None
__all_cols = None
def __init__(self):
super().__init__()
self.__con = DbManager().getConnection()
if self.__con:
self.__cur = self.__con.cursor()
def getEmployees(self, enc_key, criterion="Alle", processed=False, fired=False, every_state=True):
try:
if self.__cur:
self.__cur.callproc("getEmployeeTable", (criterion, processed, fired, every_state, enc_key,))
self.__all_cols = [desc[0] for desc in self.__cur.description]
return self.__cur.fetchall(), self.__all_cols
else:
return None, None
except mariadb.Error as e:
print(str(e))
cursor = self.__con.cursor()
cursor.callproc("getEmployeeTable", (criterion, processed, fired, every_state, enc_key,))
self.__all_cols = [desc[0] for desc in cursor.description]
result = cursor.fetchall(), self.__all_cols
cursor.close()
return result
def getEmployee(self, employee_id, enc_key=None):
try:
if self.__cur:
self.__cur.callproc("getEmployee", (employee_id, enc_key,))
# self.__all_cols = [desc[0] for desc in self.__cur.description]
return self.__cur.fetchall() # , self.__all_cols
else:
return None
except mariadb.Error as e:
print(str(e))
def fetchApplicant(self, employee_id, enc_key=None) -> dict:
cursor = self.__con.cursor(dictionary=True)
cursor.callproc("getApplicant", (employee_id, enc_key))
it = cursor.fetchone()
cursor.close()
return it
def addEmployee(self, data, enc_key, applicant=True):
if self.__cur:
self.__cur.callproc("addApplicant", (json.dumps(data), applicant, enc_key,))
self.__con.commit()
self.newEmployeeAdded.emit(True)
cursor = self.__con.cursor()
cursor.callproc("addApplicant", (json.dumps(data), applicant, enc_key,))
self.__con.commit()
cursor.close()
self.newEmployeeAdded.emit(True)