Use ORM for applicants
This commit is contained in:
@@ -1,35 +1,41 @@
|
||||
from .DbManager import DbManager
|
||||
import json
|
||||
import mariadb
|
||||
|
||||
from PySide6.QtCore import QObject, Signal
|
||||
|
||||
from lib.domain.BaseModel import database
|
||||
|
||||
|
||||
class EmployeeDAO(QObject):
|
||||
newEmployeeAdded = Signal(bool)
|
||||
__all_cols = None
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.__con = DbManager().getConnection()
|
||||
self._connection = database.connection()
|
||||
|
||||
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
|
||||
cursor = self._connection.cursor()
|
||||
try:
|
||||
cursor.callproc("getEmployeeTable", (criterion, processed, fired, every_state, enc_key,))
|
||||
all_cols = [desc[0] for desc in cursor.description]
|
||||
result = cursor.fetchall(), all_cols
|
||||
return result
|
||||
finally:
|
||||
cursor.close()
|
||||
|
||||
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
|
||||
cursor = self._connection.cursor(dictionary=True)
|
||||
try:
|
||||
cursor.callproc("getApplicant", (employee_id, enc_key))
|
||||
it = cursor.fetchone()
|
||||
return it
|
||||
finally:
|
||||
cursor.close()
|
||||
|
||||
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)
|
||||
def addApplicant(self, data, enc_key, applicant=True):
|
||||
cursor = self._connection.cursor()
|
||||
try:
|
||||
cursor.callproc("addApplicant", (json.dumps(data), applicant, enc_key,))
|
||||
self._connection.commit()
|
||||
self.newEmployeeAdded.emit(True)
|
||||
finally:
|
||||
cursor.close()
|
||||
|
||||
Reference in New Issue
Block a user