mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
Модуль DataBaseLMS рефакторинг
This commit is contained in:
@@ -15,13 +15,13 @@
|
||||
class DataBaseSettings
|
||||
{
|
||||
public:
|
||||
QString dbName = "DataBaseLMS";
|
||||
QString dbType = "QPSQL";
|
||||
QString connectionName = "Connection";
|
||||
QString dbUserName = "postgres";
|
||||
QString dbPassword = "12345678";
|
||||
QString dbName = "";
|
||||
QString dbType = "";
|
||||
QString connectionName = "";
|
||||
QString dbUserName = "";
|
||||
QString dbPassword = "";
|
||||
QString dbHostName = "";
|
||||
int dbPort = 5432;
|
||||
int dbPort = 0;
|
||||
};
|
||||
|
||||
class DataBaseLMS : public QObject
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "interfacedatabaselms.h"
|
||||
|
||||
InterfaceDataBaseLMS::InterfaceDataBaseLMS(QWidget *ownerWidget, QObject *parent):
|
||||
//QObject(parent),
|
||||
DataBaseLMS(ownerWidget, parent),
|
||||
ownerWidget(ownerWidget)
|
||||
{
|
||||
@@ -15,7 +14,6 @@ InterfaceDataBaseLMS::InterfaceDataBaseLMS(QWidget *ownerWidget, QObject *parent
|
||||
|
||||
bool InterfaceDataBaseLMS::connectionToDB()
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
if(!createConnection())
|
||||
{
|
||||
QMessageBox::critical(ownerWidget, dbSettings.dbName, tr("Connection error") /*+ db->lastError().text()*/);
|
||||
@@ -30,7 +28,6 @@ bool InterfaceDataBaseLMS::connectionToDB()
|
||||
|
||||
bool InterfaceDataBaseLMS::disConnectionFromDB()
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
deleteConnection();
|
||||
//QMessageBox::information(ownerWidget, dbName, tr("Disconnection is successful!"));
|
||||
return true;
|
||||
@@ -38,7 +35,6 @@ bool InterfaceDataBaseLMS::disConnectionFromDB()
|
||||
|
||||
bool InterfaceDataBaseLMS::DBisConnected()
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return isConnected();
|
||||
}
|
||||
|
||||
@@ -47,8 +43,6 @@ bool InterfaceDataBaseLMS::DBisConnected()
|
||||
|
||||
bool InterfaceDataBaseLMS::authorizationInstructor(QString login, QString password)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
|
||||
if(int id = selectUserID(DataBaseLMS::TypeUserDBInstructor, login, password))
|
||||
{
|
||||
if(selectUserArchived(DataBaseLMS::TypeUserDBInstructor, id) || selectUserLoggedIn(DataBaseLMS::TypeUserDBInstructor, id))
|
||||
@@ -62,8 +56,6 @@ bool InterfaceDataBaseLMS::authorizationInstructor(QString login, QString passwo
|
||||
|
||||
bool InterfaceDataBaseLMS::deAuthorizationInstructor(QString login)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
|
||||
if(int id = selectUserID(DataBaseLMS::TypeUserDBInstructor, login))
|
||||
{
|
||||
if(updateUserLoggedIn(DataBaseLMS::TypeUserDBInstructor, id, false))
|
||||
@@ -74,67 +66,56 @@ bool InterfaceDataBaseLMS::deAuthorizationInstructor(QString login)
|
||||
|
||||
bool InterfaceDataBaseLMS::deAuthorizationAllInstructors()
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return updateAllUsersLoggedIn(DataBaseLMS::TypeUserDBInstructor, false);
|
||||
}
|
||||
|
||||
QString InterfaceDataBaseLMS::getNameInstructorByLogin(QString login)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return selectUserNameByLogin(DataBaseLMS::TypeUserDBInstructor, login);
|
||||
}
|
||||
|
||||
int InterfaceDataBaseLMS::getIdInstructorByLogin(QString login)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return selectUserID(DataBaseLMS::TypeUserDBInstructor, login);
|
||||
}
|
||||
|
||||
QList<Instructor> InterfaceDataBaseLMS::getListInstructors()
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return selectAllInstructors();
|
||||
}
|
||||
|
||||
Instructor InterfaceDataBaseLMS::getInstructor(int id)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return selectInstructor(id);
|
||||
}
|
||||
|
||||
int InterfaceDataBaseLMS::newInstructor()
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return insertInstructor();
|
||||
}
|
||||
|
||||
int InterfaceDataBaseLMS::delInstructor(int id)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return deleteInstructor(id);
|
||||
}
|
||||
|
||||
int InterfaceDataBaseLMS::editInstructor(Instructor instructor)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return updateInstructor(instructor);
|
||||
}
|
||||
|
||||
bool InterfaceDataBaseLMS::isAdminInstructor(int id)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return selectInstructorIsAdmin(id);
|
||||
}
|
||||
|
||||
bool InterfaceDataBaseLMS::isArchivedInstructor(int id)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return selectUserArchived(DataBaseLMS::TypeUserDBInstructor, id);
|
||||
}
|
||||
|
||||
bool InterfaceDataBaseLMS::isLoggedInInstructor(int id)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return selectUserLoggedIn(DataBaseLMS::TypeUserDBInstructor, id);
|
||||
}
|
||||
|
||||
@@ -143,8 +124,6 @@ bool InterfaceDataBaseLMS::isLoggedInInstructor(int id)
|
||||
|
||||
bool InterfaceDataBaseLMS::authorizationTrainee(QString login, QString password, QString classroom_name, QString computer_name)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
|
||||
if(int id = selectUserID(DataBaseLMS::TypeUserDBTrainee, login, password))
|
||||
{
|
||||
if(selectUserArchived(DataBaseLMS::TypeUserDBTrainee, id) || selectUserLoggedIn(DataBaseLMS::TypeUserDBTrainee, id))
|
||||
@@ -158,8 +137,6 @@ bool InterfaceDataBaseLMS::authorizationTrainee(QString login, QString password,
|
||||
|
||||
bool InterfaceDataBaseLMS::deAuthorizationTrainee(QString login)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
|
||||
if(int id = selectUserID(DataBaseLMS::TypeUserDBTrainee, login))
|
||||
{
|
||||
if(updateUserLoggedIn(DataBaseLMS::TypeUserDBTrainee, id, false))
|
||||
@@ -170,14 +147,11 @@ bool InterfaceDataBaseLMS::deAuthorizationTrainee(QString login)
|
||||
|
||||
bool InterfaceDataBaseLMS::deAuthorizationAllTrainees()
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return updateAllUsersLoggedIn(DataBaseLMS::TypeUserDBTrainee, false);
|
||||
}
|
||||
|
||||
int InterfaceDataBaseLMS::entryTraineeOnSimulator(int id_trainee)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
|
||||
TimingOfTrainee timing(id_trainee);
|
||||
|
||||
timing = selectTimingTrainee(id_trainee);
|
||||
@@ -198,8 +172,6 @@ int InterfaceDataBaseLMS::entryTraineeOnSimulator(int id_trainee)
|
||||
|
||||
int InterfaceDataBaseLMS::exitTraineeFromSimulator(int id_trainee)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
|
||||
TimingOfTrainee timing(id_trainee);
|
||||
|
||||
timing = selectTimingTrainee(id_trainee);
|
||||
@@ -220,180 +192,150 @@ int InterfaceDataBaseLMS::exitTraineeFromSimulator(int id_trainee)
|
||||
|
||||
QString InterfaceDataBaseLMS::getNameTraineeOnComputer(QString computer_name)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return selectTraineeNameOnComputer(computer_name);
|
||||
}
|
||||
|
||||
Trainee InterfaceDataBaseLMS::getTraineeOnComputer(QString computer_name)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return selectTraineeOnComputer(computer_name);
|
||||
}
|
||||
|
||||
QString InterfaceDataBaseLMS::getNameTraineeByLogin(QString login)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return selectUserNameByLogin(DataBaseLMS::TypeUserDBTrainee, login);
|
||||
}
|
||||
|
||||
int InterfaceDataBaseLMS::getIdTraineeByLogin(QString login)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return selectUserID(DataBaseLMS::TypeUserDBTrainee, login);
|
||||
}
|
||||
|
||||
QList<Trainee> InterfaceDataBaseLMS::getListTraineesInGroup(int id)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return selectAllTraineesInGroup(id);
|
||||
}
|
||||
|
||||
QList<Group> InterfaceDataBaseLMS::getListGroups()
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return selectAllGroups();
|
||||
}
|
||||
|
||||
QList<Trainee> InterfaceDataBaseLMS::getListTrainees()
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return selectAllTrainees();
|
||||
}
|
||||
|
||||
Trainee InterfaceDataBaseLMS::getTrainee(int id)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return selectTrainee(id);
|
||||
}
|
||||
|
||||
Group InterfaceDataBaseLMS::getGroup(int id)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return selectGroup(id);
|
||||
}
|
||||
|
||||
int InterfaceDataBaseLMS::newGroup()
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return insertGroup();
|
||||
}
|
||||
|
||||
int InterfaceDataBaseLMS::delGroup(int id)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return deleteGroup(id);
|
||||
}
|
||||
|
||||
int InterfaceDataBaseLMS::editGroup(Group group)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return updateGroup(group);
|
||||
}
|
||||
|
||||
int InterfaceDataBaseLMS::newTaskAMM(TaskAmmFim task, int id_trainee)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return insertTaskAMM(task, id_trainee);
|
||||
}
|
||||
|
||||
int InterfaceDataBaseLMS::delTaskAMM(int id)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return deleteTaskAMM(id);
|
||||
}
|
||||
|
||||
int InterfaceDataBaseLMS::editTaskAMM(TaskAmmFim task)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return updateTaskAMM(task);
|
||||
}
|
||||
|
||||
QList<TaskAmmFim> InterfaceDataBaseLMS::getListTasksAMMofTrainee(int id_trainee)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return selectTasksAMMofTrainee(id_trainee);
|
||||
}
|
||||
|
||||
QList<TaskAmmFim> InterfaceDataBaseLMS::getListTasksFIMofTrainee(int id_trainee)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return selectTasksFIMofTrainee(id_trainee);
|
||||
}
|
||||
|
||||
TaskAmmFim InterfaceDataBaseLMS::getTaskAMMbyID(int id_task)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return selectTaskAMMbyID(id_task);
|
||||
}
|
||||
|
||||
TaskAmmFim InterfaceDataBaseLMS::getTaskFIMbyID(int id_task)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return selectTaskFIMbyID(id_task);
|
||||
}
|
||||
|
||||
int InterfaceDataBaseLMS::newTaskFIM(TaskAmmFim task, int id_trainee)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return insertTaskFIM(task, id_trainee);
|
||||
}
|
||||
|
||||
int InterfaceDataBaseLMS::delTaskFIM(int id)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return deleteTaskFIM(id);
|
||||
}
|
||||
|
||||
int InterfaceDataBaseLMS::editTaskFIM(TaskAmmFim task)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return updateTaskFIM(task);
|
||||
}
|
||||
|
||||
int InterfaceDataBaseLMS::replaceReportFIM(TaskAmmFim task)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return updateReportFIMforTask(task);
|
||||
}
|
||||
|
||||
int InterfaceDataBaseLMS::changeStatusTaskFIM(int id_task, QString status)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return updateStatusTaskFIM(id_task, status);
|
||||
}
|
||||
|
||||
int InterfaceDataBaseLMS::changeStatusTaskAMM(int id_task, QString status)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return updateStatusTaskAMM(id_task, status);
|
||||
}
|
||||
|
||||
int InterfaceDataBaseLMS::newTrainee(int id_group)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return insertTrainee(id_group);
|
||||
}
|
||||
|
||||
int InterfaceDataBaseLMS::delTrainee(int id)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return deleteTrainee(id);
|
||||
}
|
||||
|
||||
int InterfaceDataBaseLMS::editTrainee(Trainee trainee)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return updateTrainee(trainee);
|
||||
}
|
||||
|
||||
bool InterfaceDataBaseLMS::isArchivedTrainee(int id)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return selectUserArchived(DataBaseLMS::TypeUserDBTrainee, id);
|
||||
}
|
||||
|
||||
bool InterfaceDataBaseLMS::isLoggedInTrainee(int id)
|
||||
{
|
||||
//QMutexLocker mtxLocker(&mtxAccess);
|
||||
return selectUserLoggedIn(DataBaseLMS::TypeUserDBTrainee, id);
|
||||
}
|
||||
|
||||
@@ -8,10 +8,8 @@
|
||||
#include "DataBaseLMS_global.h"
|
||||
#include "databaselms.h"
|
||||
|
||||
class DATABASELMS_EXPORT InterfaceDataBaseLMS : public /*QObject,*/ DataBaseLMS
|
||||
class DATABASELMS_EXPORT InterfaceDataBaseLMS : public DataBaseLMS
|
||||
{
|
||||
//Q_OBJECT
|
||||
|
||||
public:
|
||||
InterfaceDataBaseLMS(QWidget *ownerWidget, QObject *parent = nullptr);
|
||||
|
||||
@@ -47,11 +45,7 @@ public:
|
||||
|
||||
bool authorizationTrainee(QString login, QString password, QString classroom_name, QString computer_name);
|
||||
bool deAuthorizationTrainee(QString login);
|
||||
bool deAuthorizationAllTrainees();
|
||||
|
||||
//Регистрация тайминга Обучаемого
|
||||
int entryTraineeOnSimulator(int id_trainee);
|
||||
int exitTraineeFromSimulator(int id_trainee);
|
||||
bool deAuthorizationAllTrainees();
|
||||
|
||||
QString getNameTraineeOnComputer(QString computer_name);
|
||||
Trainee getTraineeOnComputer(QString computer_name);
|
||||
@@ -71,6 +65,10 @@ public:
|
||||
bool isArchivedTrainee(int id);
|
||||
bool isLoggedInTrainee(int id);
|
||||
|
||||
//Регистрация тайминга Обучаемого
|
||||
int entryTraineeOnSimulator(int id_trainee);
|
||||
int exitTraineeFromSimulator(int id_trainee);
|
||||
|
||||
|
||||
//Группы
|
||||
|
||||
@@ -101,7 +99,6 @@ public:
|
||||
|
||||
private:
|
||||
QWidget* ownerWidget;
|
||||
//QMutex mtxAccess;
|
||||
};
|
||||
|
||||
#endif // INTERFACEDATABASELMS_H
|
||||
|
||||
Reference in New Issue
Block a user