1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Before model refactoring

This commit is contained in:
Laurent Cozic 2017-01-01 14:05:21 +01:00
parent b5dc92e3a7
commit 959e5be871
7 changed files with 45 additions and 40 deletions

View File

@ -17,7 +17,8 @@ SOURCES += \
synchronizer.cpp \ synchronizer.cpp \
settings.cpp \ settings.cpp \
uuid.cpp \ uuid.cpp \
dispatcher.cpp dispatcher.cpp \
models/change.cpp
RESOURCES += qml.qrc \ RESOURCES += qml.qrc \
database.qrc database.qrc
@ -47,7 +48,8 @@ HEADERS += \
settings.h \ settings.h \
simpletypes.h \ simpletypes.h \
uuid.h \ uuid.h \
dispatcher.h dispatcher.h \
models/change.h
DISTFILES += DISTFILES +=

View File

@ -108,6 +108,10 @@ bool Database::errorCheck(const QSqlQuery& query) {
return true; return true;
} }
//Change Database::newChange() const {
// return Change(*this);
//}
int Database::version() const { int Database::version() const {
if (version_ >= 0) return version_; if (version_ >= 0) return version_;

View File

@ -19,6 +19,8 @@ public:
QSqlQuery buildSqlQuery(Database::QueryType type, const QString& tableName, const QStringList& fields, const VariantVector& values, const QString& whereCondition = ""); QSqlQuery buildSqlQuery(Database::QueryType type, const QString& tableName, const QStringList& fields, const VariantVector& values, const QString& whereCondition = "");
bool errorCheck(const QSqlQuery& query); bool errorCheck(const QSqlQuery& query);
//Change newChange() const;
private: private:
QSqlDatabase db_; QSqlDatabase db_;

View File

@ -0,0 +1,7 @@
#include "change.h"
using namespace jop;
Change::Change(Database &database) {
}

View File

@ -0,0 +1,24 @@
#ifndef CHANGE_H
#define CHANGE_H
#include <stable.h>
#include "database.h"
namespace jop {
class Change {
public:
Change(Database& database);
private:
Database& database_;
};
}
#endif // CHANGE_H

View File

@ -14,6 +14,10 @@ class FoldersController extends ApiController {
* @Route("/folders") * @Route("/folders")
*/ */
public function allAction(Request $request) { public function allAction(Request $request) {
if ($request->isMethod('GET')) {
return static::successResponse(Folder::all());
}
if ($request->isMethod('POST')) { if ($request->isMethod('POST')) {
$folder = new Folder(); $folder = new Folder();
$folder->fromPublicArray($request->request->all()); $folder->fromPublicArray($request->request->all());

View File

@ -1,38 +0,0 @@
<?php
function config($name) {
$config = array(
'baseUrl' => '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();