add base sql server

This commit is contained in:
Andrei Yankovich 2019-02-16 17:08:00 +03:00
parent 0e4ab11e2f
commit fdc990e5ba
25 changed files with 1388 additions and 5 deletions

View File

@ -69,7 +69,6 @@ HEADERS += \
back-end/backgrounditem.h
DISTFILES += \
doc/calassdiagramm.qmodel \
android/AndroidManifest.xml \
android/gradle/wrapper/gradle-wrapper.jar \
android/gradlew \

View File

@ -11,3 +11,8 @@ QuasarAppLib.file = QuasarAppLib/QuasarApp.pro
Snake.file = Snake/snake.pro
include($$PWD/installer/installer.pri)
DISTFILES += \
doc/librarymodel.qmodel \
doc/calassdiagramm.qmodel

View File

@ -5,7 +5,6 @@
#include "clientprotocol.h"
#include <QObject>
class QTcpSocket;
class Player;
class BaseItem;

View File

@ -33,3 +33,4 @@ HEADERS += \
include($$PWD/../../QuasarAppLib/QuasarLib.pri)
include($$PWD/../ServerProtocol/ServerProtocol.pri)
include($$PWD/../Server/Server.pri)

View File

@ -0,0 +1,23 @@
#
# Copyright (C) 2018 - 2019 QuasarApp.
# Distributed under the lgplv3 software license, see the accompanying
# Everyone is permitted to copy and distribute verbatim copies
# of this license document, but changing it is not allowed.
#
!isEmpty(SERVER_LIB):error("Server.pri already included")
SERVER_LIB = 1
#DEPENDS
CONFIG(release, debug|release): {
SERVER_LIB_OUTPUT_DIR="$$PWD/build/release"
} else {
SERVER_LIB_OUTPUT_DIR="$$PWD/build/debug"
}
LIBS += -L$$SERVER_LIB_OUTPUT_DIR -lServer
INCLUDEPATH += "$$PWD/"

View File

@ -0,0 +1,47 @@
#-------------------------------------------------
#
# Project created by QtCreator 2019-02-16T12:24:27
#
#-------------------------------------------------
QT -= gui
QT += network
TARGET = Server
TEMPLATE = lib
DEFINES += SERVER_LIBRARY
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
server.cpp \
sqldatabase.cpp
TARGET = Server
CONFIG(release, debug|release): {
DESTDIR = $$PWD/build/release
} else {
DESTDIR = $$PWD/build/debug
}
HEADERS += \
server.h \
server_global.h \
sqldatabase.h
include($$PWD/../../QuasarAppLib/QuasarLib.pri)
include($$PWD/../ServerProtocol/ServerProtocol.pri)
RESOURCES += sqlres.qrc

View File

@ -0,0 +1,11 @@
#include "server.h"
#include <spserver.h>
Server::Server(QObject *ptr):
QObject (ptr) {
_serverDaemon = new ServerProtocol::Server(this);
_serverDaemon->run(DEFAULT_SERVER);
}
Server::~Server() {
}

View File

@ -0,0 +1,21 @@
#ifndef SERVER_H
#define SERVER_H
#include <serverprotocol.h>
#include "server_global.h"
namespace ServerProtocol {
class Server;
}
class SERVERSHARED_EXPORT Server: public QObject
{
Q_OBJECT
private:
ServerProtocol::Server *_serverDaemon = nullptr;
public:
Server(QObject *ptr = nullptr);
virtual ~Server();
};
#endif // SERVER_H

View File

@ -0,0 +1,12 @@
#ifndef SERVER_GLOBAL_H
#define SERVER_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined(SERVER_LIBRARY)
# define SERVERSHARED_EXPORT Q_DECL_EXPORT
#else
# define SERVERSHARED_EXPORT Q_DECL_IMPORT
#endif
#endif // SERVER_GLOBAL_H

View File

@ -0,0 +1,33 @@
CREATE TABLE IF NOT EXISTS items(
id int NOT NULL AUTO_INCREMENT,
type int NOT NULL,
data BLOB NOT NULL,
PRIMARY KEY(id)
);
CREATE TABLE IF NOT EXISTS players(
id int NOT NULL AUTO_INCREMENT,
name VARCHAR(100) NOT NULL,
gmail VARCHAR(64) NOT NLLL,
money int NOT NULL DEFAULT 0,
avgrecord int NOT NULL DEFAULT 0,
record int NOT NULL DEFAULT 0,
lastOnline date not null DEFAULT 0,
onlinetime int not null DEFAULT 0,
currentsnake int not null DEFAULT 0,
PRIMARY KEY(id),
FOREIGN KEY(currentsnake) REFERENCES items(id)
ON UPDATE CASCADE
ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS ovners(
player int NOT NULL,
item int NOT NULL
);
CREATE UNIQUE INDEX IF NOT EXISTS iovners ON ovners(player,item);

View File

@ -0,0 +1,6 @@
#include "sqldatabase.h"
SQLDataBase::SQLDataBase(QObject *ptr):
QObject (ptr) {
}

View File

@ -0,0 +1,12 @@
#ifndef SQLDATABASE_H
#define SQLDATABASE_H
#include <QObject>
class SQLDataBase : public QObject
{
Q_OBJECT
public:
SQLDataBase(QObject * ptr = nullptr);
};
#endif // SQLDATABASE_H

View File

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/sql">
<file alias="DB">sql/SnakeDB.sql</file>
</qresource>
</RCC>

View File

@ -47,5 +47,6 @@ HEADERS += \
serverutils.h \
server.h \
client.h \
sp.h
sp.h \
spserver.h

View File

@ -0,0 +1,6 @@
#ifndef SPSERVER_H
#define SPSERVER_H
#include "server.h"
#endif // SPSERVER_H

View File

@ -5,6 +5,7 @@ CONFIG += ordered
SUBDIRS += \
ServerProtocol \
ClientProtocol \
Client \
Terminal \
Server \
Daemon \
serverProtocolTests
serverProtocolTests \

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -13,7 +13,11 @@ class testSankeServer : public QObject
private:
void testPingServerProtockol();
void testPingClientProtockol();
void testLoginClientProtockol();
void testUserDataClientProtockol();
void testGetItemClientProtockol();
public:
testSankeServer();
@ -131,7 +135,17 @@ void testSankeServer::testPingClientProtockol() {
delete serv;
delete client;
}
void testSankeServer::testLoginClientProtockol() {
}
void testSankeServer::testUserDataClientProtockol() {
}
void testSankeServer::testGetItemClientProtockol() {
}
@ -141,6 +155,10 @@ void testSankeServer::testServerProtockol() {
void testSankeServer::testClientProtockol() {
testPingClientProtockol();
testLoginClientProtockol();
testGetItemClientProtockol();
testUserDataClientProtockol();
}
QTEST_APPLESS_MAIN(testSankeServer)

View File

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

1183
doc/librarymodel.qmodel Normal file

File diff suppressed because it is too large Load Diff