Files
pyqcrm/lib/DB/EmployeeDAO.py
2025-04-19 00:55:12 +02:00

36 lines
1.2 KiB
Python

from .DbManager import DbManager
import json
import mariadb
from PySide6.QtCore import QObject, Signal
class EmployeeDAO(QObject):
newEmployeeAdded = Signal(bool)
__all_cols = None
def __init__(self):
super().__init__()
self.__con = DbManager().getConnection()
def getEmployees(self, enc_key, criterion="Alle", processed=False, fired=False, every_state=True):
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 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):
cursor = self.__con.cursor()
cursor.callproc("addApplicant", (json.dumps(data), applicant, enc_key,))
self.__con.commit()
cursor.close()
self.newEmployeeAdded.emit(True)