Add cityentity object for ownCloud 9.1
parent
e09f160faf
commit
a910b81be2
|
@ -17,7 +17,9 @@ use \OCP\AppFramework\Controller;
|
|||
use \OCP\AppFramework\Http\JSONResponse;
|
||||
use \OCP\AppFramework\Http;
|
||||
|
||||
use \OCA\Weather\Db\CityEntity;
|
||||
use \OCA\Weather\Db\CityMapper;
|
||||
use \OCA\Weather\Db\SettingsMapper;
|
||||
use \OCA\Weather\Controller\IntermediateController;
|
||||
|
||||
class CityController extends IntermediateController {
|
||||
|
@ -101,7 +103,11 @@ class CityController extends IntermediateController {
|
|||
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));
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -66,13 +66,5 @@ class CityMapper extends Mapper {
|
|||
}
|
||||
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();
|
||||
}
|
||||
};
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue