From 959e5be871d764e0e095df81d5bdc9de5244a3cc Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Sun, 1 Jan 2017 14:05:21 +0100 Subject: [PATCH] Before model refactoring --- QtClient/JoplinQtClient/JoplinQtClient.pro | 6 ++- QtClient/JoplinQtClient/database.cpp | 4 ++ QtClient/JoplinQtClient/database.h | 2 + QtClient/JoplinQtClient/models/change.cpp | 7 ++++ QtClient/JoplinQtClient/models/change.h | 24 ++++++++++++ .../Controller/FoldersController.php | 4 ++ web/client.php | 38 ------------------- 7 files changed, 45 insertions(+), 40 deletions(-) create mode 100755 QtClient/JoplinQtClient/models/change.cpp create mode 100755 QtClient/JoplinQtClient/models/change.h delete mode 100755 web/client.php diff --git a/QtClient/JoplinQtClient/JoplinQtClient.pro b/QtClient/JoplinQtClient/JoplinQtClient.pro index 8cc7f1dd9..d87c365de 100755 --- a/QtClient/JoplinQtClient/JoplinQtClient.pro +++ b/QtClient/JoplinQtClient/JoplinQtClient.pro @@ -17,7 +17,8 @@ SOURCES += \ synchronizer.cpp \ settings.cpp \ uuid.cpp \ - dispatcher.cpp + dispatcher.cpp \ + models/change.cpp RESOURCES += qml.qrc \ database.qrc @@ -47,7 +48,8 @@ HEADERS += \ settings.h \ simpletypes.h \ uuid.h \ - dispatcher.h + dispatcher.h \ + models/change.h DISTFILES += diff --git a/QtClient/JoplinQtClient/database.cpp b/QtClient/JoplinQtClient/database.cpp index ea2295f1d..5ba442d4a 100755 --- a/QtClient/JoplinQtClient/database.cpp +++ b/QtClient/JoplinQtClient/database.cpp @@ -108,6 +108,10 @@ bool Database::errorCheck(const QSqlQuery& query) { return true; } +//Change Database::newChange() const { +// return Change(*this); +//} + int Database::version() const { if (version_ >= 0) return version_; diff --git a/QtClient/JoplinQtClient/database.h b/QtClient/JoplinQtClient/database.h index 05b369186..17e865aa6 100755 --- a/QtClient/JoplinQtClient/database.h +++ b/QtClient/JoplinQtClient/database.h @@ -19,6 +19,8 @@ public: QSqlQuery buildSqlQuery(Database::QueryType type, const QString& tableName, const QStringList& fields, const VariantVector& values, const QString& whereCondition = ""); bool errorCheck(const QSqlQuery& query); + //Change newChange() const; + private: QSqlDatabase db_; diff --git a/QtClient/JoplinQtClient/models/change.cpp b/QtClient/JoplinQtClient/models/change.cpp new file mode 100755 index 000000000..b9a581023 --- /dev/null +++ b/QtClient/JoplinQtClient/models/change.cpp @@ -0,0 +1,7 @@ +#include "change.h" + +using namespace jop; + +Change::Change(Database &database) { + +} diff --git a/QtClient/JoplinQtClient/models/change.h b/QtClient/JoplinQtClient/models/change.h new file mode 100755 index 000000000..dd00f59ef --- /dev/null +++ b/QtClient/JoplinQtClient/models/change.h @@ -0,0 +1,24 @@ +#ifndef CHANGE_H +#define CHANGE_H + +#include + +#include "database.h" + +namespace jop { + +class Change { + +public: + + Change(Database& database); + +private: + + Database& database_; + +}; + +} + +#endif // CHANGE_H diff --git a/src/AppBundle/Controller/FoldersController.php b/src/AppBundle/Controller/FoldersController.php index 669baf141..9e904f345 100755 --- a/src/AppBundle/Controller/FoldersController.php +++ b/src/AppBundle/Controller/FoldersController.php @@ -14,6 +14,10 @@ class FoldersController extends ApiController { * @Route("/folders") */ public function allAction(Request $request) { + if ($request->isMethod('GET')) { + return static::successResponse(Folder::all()); + } + if ($request->isMethod('POST')) { $folder = new Folder(); $folder->fromPublicArray($request->request->all()); diff --git a/web/client.php b/web/client.php deleted file mode 100755 index 8c7dde000..000000000 --- a/web/client.php +++ /dev/null @@ -1,38 +0,0 @@ - 'http://joplin.local', - ); - if (isset($config[$name])) { - return $config[$name]; - } - throw new Exception('Unknown config: ' . $name); -} - -function execRequest($method, $path, $query = null, $data = null) { - $url = config('baseUrl') . '/' . $path; - if ($query) $url .= '?' . http_build_query($query); - - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $url); - if ($data) curl_setopt($ch, CURLOPT_POSTFIELDS, $data); - $response = curl_exec($ch); - curl_close($ch); - - $output = json_decode($response, true); - if ($output === null) { - return array('error' => 'Cannot decode JSON', 'body' => $response); - } - - return $output; -} - -$session = execRequest('POST', 'session', null, array( - 'email' => 'laurent@cozic.net', - 'password' => '12345678', -)); - -var_dump($session); - -die(); \ No newline at end of file