mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
106 lines
3.3 KiB
C++
106 lines
3.3 KiB
C++
#ifndef DATABASELMS_H
|
|
#define DATABASELMS_H
|
|
|
|
#include <QSqlDatabase>
|
|
#include <QMutex>
|
|
|
|
#include "instructor.h"
|
|
#include "trainee.h"
|
|
#include "group.h"
|
|
#include "tasksAmmFim.h"
|
|
|
|
class DataBaseLMS
|
|
{
|
|
public:
|
|
DataBaseLMS();
|
|
~DataBaseLMS();
|
|
|
|
protected:
|
|
//Подключение
|
|
bool createConnection();
|
|
void deleteConnection();
|
|
bool isConnected();
|
|
|
|
//Транзакции
|
|
bool transactionBegin();
|
|
bool transactionEnd();
|
|
|
|
//Списки
|
|
QList<Instructor> selectAllInstructors();
|
|
QList<Trainee> selectAllTrainees();
|
|
QList<Group> selectAllGroups();
|
|
|
|
//Инструктор
|
|
Instructor selectInstructor(int id_instructor);
|
|
int selectInstructorID(QString login, QString password = QStringLiteral(""));
|
|
QString selectInstructorNameByLogin(QString login);
|
|
bool selectInstructorIsAdmin(int id_instructor);
|
|
bool selectInstructorLoggedIn(int id_instructor);
|
|
bool selectInstructorArchived(int id_instructor);
|
|
int updateInstructorLoggedIn(int id_instructor, bool loggedIn);
|
|
bool updateAllInstructorsLoggedIn(bool loggedIn);
|
|
int updateInstructorArchived(int id_instructor, bool archived);
|
|
|
|
int insertInstructor();
|
|
int insertInstructor(Instructor instructor);
|
|
int deleteInstructor(int id_instructor);
|
|
int updateInstructor(Instructor instructor);
|
|
|
|
//Группа
|
|
Group selectGroup(int id_group);
|
|
int insertGroup();
|
|
int insertGroup(Group group);
|
|
int deleteGroup(int id_group);
|
|
int updateGroup(Group group);
|
|
|
|
//Задача AMM
|
|
int insertTaskAMM(TaskAmmFim task, int id_trainee);
|
|
int updateTaskAMM(TaskAmmFim task);
|
|
int deleteTaskAMM(int id_task);
|
|
QList<TaskAmmFim> selectTasksAMMofTrainee(int id_trainee);
|
|
//Задача FIM
|
|
int insertTaskFIM(TaskAmmFim task, int id_trainee);
|
|
int updateTaskFIM(TaskAmmFim task);
|
|
int deleteTaskFIM(int id_task);
|
|
QList<TaskAmmFim> selectTasksFIMofTrainee(int id_trainee);
|
|
|
|
//Обучаемый
|
|
Trainee selectTrainee(int id_trainee);
|
|
QList<Trainee> selectAllTraineesInGroup(int id_group);
|
|
int selectTraineeID(QString login, QString password = QStringLiteral(""));
|
|
QString selectTraineeNameByLogin(QString login);
|
|
QString selectTraineeNameOnComputer(QString computer_name);
|
|
Trainee selectTraineeOnComputer(QString computer_name);
|
|
bool selectTraineeArchived(int id_trainee);
|
|
bool selectTraineeLoggedIn(int id_trainee);
|
|
int updateTraineeLoggedIn(int id_trainee, bool loggedIn);
|
|
bool updateAllTraineesLoggedIn(bool loggedIn);
|
|
int updateTraineeArchived(int id_trainee, bool archived);
|
|
|
|
int insertTrainee(int id_group);
|
|
int insertTrainee(Trainee trainee);
|
|
int deleteTrainee(int id_trainee);
|
|
int updateTrainee(Trainee trainee);
|
|
|
|
private:
|
|
int queryExecInt(QString queryStr);
|
|
QString queryExecString(QString queryStr);
|
|
bool queryExecBool(QString queryStr);
|
|
bool queryExec(QString queryStr, QSqlQuery* query);
|
|
void messageWarningErrorQuery(QString queryStr, QSqlQuery* query);
|
|
|
|
protected:
|
|
QSqlDatabase* db;
|
|
const QString dbName = "DataBaseLMS";
|
|
const QString connectionName = "Connection_DataBaseLMS";
|
|
private:
|
|
bool transactionBegined;
|
|
const QString dbUserName = "postgres";
|
|
const QString dbPassword = "12345678";
|
|
const QString dbType = "QPSQL";
|
|
|
|
QMutex mtxAccess;
|
|
};
|
|
|
|
#endif // DATABASELMS_H
|