Add cityentity object for ownCloud 9.1

master
Loic Blot 2016-04-24 22:16:29 +02:00
parent e09f160faf
commit a910b81be2
3 changed files with 34 additions and 9 deletions

View File

@ -17,7 +17,9 @@ use \OCP\AppFramework\Controller;
use \OCP\AppFramework\Http\JSONResponse; use \OCP\AppFramework\Http\JSONResponse;
use \OCP\AppFramework\Http; use \OCP\AppFramework\Http;
use \OCA\Weather\Db\CityEntity;
use \OCA\Weather\Db\CityMapper; use \OCA\Weather\Db\CityMapper;
use \OCA\Weather\Db\SettingsMapper;
use \OCA\Weather\Controller\IntermediateController; use \OCA\Weather\Controller\IntermediateController;
class CityController extends IntermediateController { class CityController extends IntermediateController {
@ -101,7 +103,11 @@ class CityController extends IntermediateController {
return new JSONResponse(array(), 403); return new JSONResponse(array(), 403);
} }
$this->mapper->delete($id); $entity = new CityEntity();
$entity->setId($id);
$entity->setUser_id($this->userId);
$this->mapper->delete($entity);
return new JSONResponse(array("deleted" => true)); return new JSONResponse(array("deleted" => true));
} }

27
db/cityentity.php 100644
View File

@ -0,0 +1,27 @@
<?php
/**
* ownCloud - weather
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Loic Blot <loic.blot@unix-experience.fr>
* @copyright Loic Blot 2015
*/
namespace OCA\Weather\Db;
use \OCP\AppFramework\Db\Entity;
class CityEntity extends Entity {
public $id;
public $name;
public $user_id;
public function __construct() {
$this->addType('id', 'integer');
$this->addType('user_id', 'integer');
}
}
?>

View File

@ -66,13 +66,5 @@ class CityMapper extends Mapper {
} }
return null; return null;
} }
public function delete ($id) {
\OCP\DB::beginTransaction();
$query = \OCP\DB::prepare('DELETE FROM *PREFIX*weather_city ' .
'WHERE id = ?');
$query->execute(array($id));
\OCP\DB::commit();
}
}; };
?> ?>