Compare commits
2 Commits
Новые-табл
...
3c2b8e7cf4
| Author | SHA1 | Date | |
|---|---|---|---|
| 3c2b8e7cf4 | |||
| 394c55ae5c |
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "redkbuild"]
|
||||||
|
path = redkbuild
|
||||||
|
url = ssh://git@gitea.redkit-lab.work:57322/redkit-lab/redkbuild.git
|
||||||
@@ -8,12 +8,14 @@ Project {
|
|||||||
// // "guiness/qbs",
|
// // "guiness/qbs",
|
||||||
// // "prerequisites/qbs",
|
// // "prerequisites/qbs",
|
||||||
// // "report/qbs",
|
// // "report/qbs",
|
||||||
// "redkbuild",
|
"redkbuild",
|
||||||
// // "ext_libs/openssl/qbs",
|
// // "ext_libs/openssl/qbs",
|
||||||
// "redkitty/lib/redkit-gen-integration/qbs",
|
// "redkitty/lib/redkit-gen-integration/qbs",
|
||||||
]
|
]
|
||||||
|
|
||||||
references: [
|
references: [
|
||||||
"src/cpp-opds.qbs",
|
"src/cpp-opds.qbs",
|
||||||
|
"src/database/database.qbs",
|
||||||
|
"src/restapi/restapi.qbs",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ Module {
|
|||||||
// "--include-prefix", FileInfo.cleanPath(input.filePath + "/../"),
|
// "--include-prefix", FileInfo.cleanPath(input.filePath + "/../"),
|
||||||
// "--output-dir", product.Qt.core.qmDir,
|
// "--output-dir", product.Qt.core.qmDir,
|
||||||
"--output-dir", FileInfo.cleanPath(input.filePath + "/../"),
|
"--output-dir", FileInfo.cleanPath(input.filePath + "/../"),
|
||||||
|
"-I/home/uzver/qt5.15/include",
|
||||||
input.filePath,
|
input.filePath,
|
||||||
]);
|
]);
|
||||||
cmd.description = "Generating ODB files for " + input.fileName;
|
cmd.description = "Generating ODB files for " + input.fileName;
|
||||||
@@ -44,5 +45,21 @@ Module {
|
|||||||
return [cmd];
|
return [cmd];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cpp.includePaths: [ project.sourceDirectory, product.Qt.core.qmDir ]
|
|
||||||
|
cpp.includePaths: [
|
||||||
|
project.sourceDirectory,
|
||||||
|
product.Qt.core.qmDir,
|
||||||
|
"/usr/include", // Общие заголовки
|
||||||
|
"/usr/include/odb" // Заголовки ODB
|
||||||
|
]
|
||||||
|
|
||||||
|
// Подключаем библиотеки ODB
|
||||||
|
cpp.libraryPaths: [
|
||||||
|
"/usr/lib" // Путь к библиотекам
|
||||||
|
]
|
||||||
|
|
||||||
|
cpp.dynamicLibraries: [
|
||||||
|
"odb",
|
||||||
|
"odb-sqlite"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
1
redkbuild
Submodule
1
redkbuild
Submodule
Submodule redkbuild added at 3adf92aad6
@@ -15,6 +15,7 @@ Application {
|
|||||||
|
|
||||||
Depends { name: "Qt"; submodules: [ "core", "sql", "network" ] }
|
Depends { name: "Qt"; submodules: [ "core", "sql", "network" ] }
|
||||||
Depends { name: "cpp" }
|
Depends { name: "cpp" }
|
||||||
|
Depends { name: "database" }
|
||||||
Depends { name: "odbModule"}
|
Depends { name: "odbModule"}
|
||||||
|
|
||||||
// Depends { name: "redkit_gen" }
|
// Depends { name: "redkit_gen" }
|
||||||
@@ -24,35 +25,10 @@ Application {
|
|||||||
Group {
|
Group {
|
||||||
name: "cpp"
|
name: "cpp"
|
||||||
files: [
|
files: [
|
||||||
"books.*",
|
|
||||||
"databasemanager.*",
|
|
||||||
"main.cpp",
|
"main.cpp",
|
||||||
"restapiserver.*",
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
Group {
|
|
||||||
name: "odb"
|
|
||||||
files: [
|
|
||||||
"author_s.h",
|
|
||||||
"book_s.h",
|
|
||||||
]
|
|
||||||
fileTags: ["odb"]
|
|
||||||
}
|
|
||||||
|
|
||||||
cpp.includePaths: [
|
|
||||||
"/usr/include", // Общие заголовки
|
|
||||||
"/usr/include/odb" // Заголовки ODB
|
|
||||||
]
|
|
||||||
|
|
||||||
// Подключаем библиотеки ODB
|
|
||||||
cpp.libraryPaths: [
|
|
||||||
"/usr/lib" // Путь к библиотекам
|
|
||||||
]
|
|
||||||
|
|
||||||
cpp.dynamicLibraries: [
|
|
||||||
"odb",
|
|
||||||
"odb-sqlite"
|
|
||||||
]
|
|
||||||
// }
|
// }
|
||||||
} // Project
|
} // Project
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
#ifndef AUTHOR_S_H
|
#ifndef AUTHOR_S_H
|
||||||
#define AUTHOR_S_H
|
#define AUTHOR_S_H
|
||||||
|
|
||||||
|
// #include <QtCore/QObject>
|
||||||
|
|
||||||
#include <cstddef> // std::size_t
|
#include <cstddef> // std::size_t
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -13,7 +15,7 @@
|
|||||||
#include <odb/query.hxx>
|
#include <odb/query.hxx>
|
||||||
|
|
||||||
#pragma db object
|
#pragma db object
|
||||||
class Author_S
|
class __attribute__((visibility("default"))) Author_S
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Author_S() = default;
|
Author_S() = default;
|
||||||
@@ -4,6 +4,8 @@
|
|||||||
#ifndef BOOK_S_H
|
#ifndef BOOK_S_H
|
||||||
#define BOOK_S_H
|
#define BOOK_S_H
|
||||||
|
|
||||||
|
// #include <QtCore/QObject>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -12,7 +14,7 @@
|
|||||||
#include "author_s.h"
|
#include "author_s.h"
|
||||||
|
|
||||||
#pragma db object
|
#pragma db object
|
||||||
class Book_S
|
class __attribute__((visibility("default"))) Book_S
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Book_S() = default;
|
Book_S() = default;
|
||||||
52
src/database/database.qbs
Normal file
52
src/database/database.qbs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/*!
|
||||||
|
\qmltype cpp-opds
|
||||||
|
\inherits Project
|
||||||
|
\brief Описание
|
||||||
|
*/
|
||||||
|
PSLibrary {
|
||||||
|
cpp.defines: [
|
||||||
|
// You can make your code fail to compile if it uses deprecated APIs.
|
||||||
|
// In order to do so, uncomment the following line.
|
||||||
|
//"QT_DISABLE_DEPRECATED_BEFORE=0x060000" // disables all the APIs deprecated before Qt 6.0.0
|
||||||
|
"DATABASE_SQLITE"
|
||||||
|
]
|
||||||
|
consoleApplication: true
|
||||||
|
|
||||||
|
Depends { name: "Qt"; submodules: [ "core", "sql", "network" ] }
|
||||||
|
Depends { name: "cpp" }
|
||||||
|
Depends { name: "odbModule"}
|
||||||
|
|
||||||
|
cpp.cxxLanguageVersion: "c++20"
|
||||||
|
|
||||||
|
Group {
|
||||||
|
name: "cpp"
|
||||||
|
files: [
|
||||||
|
"books.*",
|
||||||
|
"databasemanager.*",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
Group {
|
||||||
|
name: "odb"
|
||||||
|
files: [
|
||||||
|
"author_s.h",
|
||||||
|
"book_s.h",
|
||||||
|
]
|
||||||
|
fileTags: ["odb"]
|
||||||
|
}
|
||||||
|
|
||||||
|
cpp.includePaths: [
|
||||||
|
"/usr/include", // Общие заголовки
|
||||||
|
"/usr/include/odb" // Заголовки ODB
|
||||||
|
]
|
||||||
|
|
||||||
|
// Подключаем библиотеки ODB
|
||||||
|
cpp.libraryPaths: [
|
||||||
|
"/usr/lib" // Путь к библиотекам
|
||||||
|
]
|
||||||
|
|
||||||
|
cpp.dynamicLibraries: [
|
||||||
|
"odb",
|
||||||
|
"odb-sqlite"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -35,7 +35,7 @@ struct SelectBuilder
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class DatabaseManager
|
class Q_DECL_EXPORT DatabaseManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static DatabaseManager& instance(); // Singleton
|
static DatabaseManager& instance(); // Singleton
|
||||||
15
src/main.cpp
15
src/main.cpp
@@ -1,17 +1,16 @@
|
|||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
#include "restapiserver.h"
|
#include <restapi/restapiserver.h>
|
||||||
|
|
||||||
/* Опыты с odb */
|
/* Опыты с odb */
|
||||||
#include "author_s-odb.hxx" // Должен быть здесь
|
#include <database/author_s-odb.hxx> // Должен быть здесь
|
||||||
#include "author_s.h"
|
#include <database/author_s.h>
|
||||||
|
#include <database/book_s-odb.hxx> // Должен быть здесь
|
||||||
#include "book_s-odb.hxx" // Должен быть здесь
|
#include <database/book_s.h>
|
||||||
#include "book_s.h"
|
#include <database/database.hxx> // create_database
|
||||||
|
|
||||||
#include <odb/database.hxx>
|
#include <odb/database.hxx>
|
||||||
|
|
||||||
#include "database.hxx" // create_database
|
#include <iostream>
|
||||||
|
|
||||||
using unidb = std::unique_ptr<odb::database>;
|
using unidb = std::unique_ptr<odb::database>;
|
||||||
|
|
||||||
|
|||||||
31
src/restapi/restapi.qbs
Normal file
31
src/restapi/restapi.qbs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/*!
|
||||||
|
\qmltype cpp-opds
|
||||||
|
\inherits Project
|
||||||
|
\brief Описание
|
||||||
|
*/
|
||||||
|
PSLibrary {
|
||||||
|
cpp.defines: [
|
||||||
|
// You can make your code fail to compile if it uses deprecated APIs.
|
||||||
|
// In order to do so, uncomment the following line.
|
||||||
|
//"QT_DISABLE_DEPRECATED_BEFORE=0x060000" // disables all the APIs deprecated before Qt 6.0.0
|
||||||
|
"DATABASE_SQLITE"
|
||||||
|
]
|
||||||
|
consoleApplication: true
|
||||||
|
|
||||||
|
Depends { name: "Qt"; submodules: [ "core", "sql", "network" ] }
|
||||||
|
Depends { name: "cpp" }
|
||||||
|
Depends { name: "database" }
|
||||||
|
Depends { name: "odbModule"}
|
||||||
|
|
||||||
|
|
||||||
|
// Depends { name: "redkit_gen" }
|
||||||
|
|
||||||
|
cpp.cxxLanguageVersion: "c++20"
|
||||||
|
|
||||||
|
Group {
|
||||||
|
name: "cpp"
|
||||||
|
files: [
|
||||||
|
"restapiserver.*",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
} // Project
|
||||||
@@ -5,15 +5,16 @@
|
|||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonValue>
|
#include <QJsonValue>
|
||||||
|
|
||||||
#include "book_s-odb.hxx"
|
#include <database/book_s.h>
|
||||||
#include "book_s.h"
|
|
||||||
|
#include "database/book_s-odb.hxx"
|
||||||
|
|
||||||
#include <odb/core.hxx>
|
#include <odb/core.hxx>
|
||||||
#include <odb/database.hxx>
|
#include <odb/database.hxx>
|
||||||
#include <odb/query.hxx>
|
#include <odb/query.hxx>
|
||||||
|
|
||||||
RestApiServer::RestApiServer(odb::database& db, QObject* parent) :
|
RestApiServer::RestApiServer(odb::database& db, QObject* parent) :
|
||||||
m_db(db), QTcpServer(parent) {}
|
QTcpServer(parent), m_db(db) {}
|
||||||
|
|
||||||
void RestApiServer::start(quint16 port)
|
void RestApiServer::start(quint16 port)
|
||||||
{
|
{
|
||||||
@@ -3,10 +3,11 @@
|
|||||||
|
|
||||||
#include <odb/database.hxx>
|
#include <odb/database.hxx>
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
#include <QTcpServer>
|
#include <QTcpServer>
|
||||||
#include <QTcpSocket>
|
#include <QTcpSocket>
|
||||||
|
|
||||||
class RestApiServer : public QTcpServer
|
class Q_DECL_EXPORT RestApiServer : public QTcpServer
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Reference in New Issue
Block a user