mirror of
https://github.com/Karaka-Management/oms-Organization.git
synced 2026-01-21 20:48:39 +00:00
Language fixes+api routes implemented
This commit is contained in:
parent
d2015ea93c
commit
d3fa3d9bcd
|
|
@ -15,7 +15,11 @@
|
|||
*/
|
||||
namespace Modules\Organization;
|
||||
|
||||
use Modules\Organization\Models\Department;
|
||||
use Modules\Organization\Models\DepartmentMapper;
|
||||
use Modules\Organization\Models\Position;
|
||||
use Modules\Organization\Models\PositionMapper;
|
||||
use Modules\Organization\Models\Unit;
|
||||
use Modules\Organization\Models\UnitMapper;
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
|
|
@ -257,4 +261,36 @@ class Controller extends ModuleAbstract implements WebInterface
|
|||
return $view;
|
||||
}
|
||||
|
||||
public function apiUnitCreate(RequestAbstract $request, ResponseAbstract $response, $data = null)
|
||||
{
|
||||
$unit = new Unit();
|
||||
$unit->setName($request->getData('name'));
|
||||
$unit->setDescription($request->getData('desc'));
|
||||
|
||||
UnitMapper::create($unit);
|
||||
|
||||
$response->set('unit', $unit->jsonSerialize());
|
||||
}
|
||||
|
||||
public function apiPositionCreate(RequestAbstract $request, ResponseAbstract $response, $data = null)
|
||||
{
|
||||
$position = new Position();
|
||||
$position->setName($request->getData('name'));
|
||||
$position->setDescription($request->getData('desc'));
|
||||
|
||||
PositionMapper::create($position);
|
||||
|
||||
$response->set('unit', $position->jsonSerialize());
|
||||
}
|
||||
|
||||
public function apiDepartmentCreate(RequestAbstract $request, ResponseAbstract $response, $data = null)
|
||||
{
|
||||
$department = new Department();
|
||||
$department->setName($request->getData('name'));
|
||||
$department->setDescription($request->getData('desc'));
|
||||
|
||||
DepartmentMapper::create($department);
|
||||
|
||||
$response->set('unit', $department->jsonSerialize());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,4 +71,40 @@ class Department
|
|||
{
|
||||
$this->description = $desc;
|
||||
}
|
||||
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'description' => $this->description,
|
||||
'unit' => $this->unit,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get string representation.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->jsonSerialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Json serialize.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return json_encode($this->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,9 @@
|
|||
*/
|
||||
namespace Modules\Organization\Models;
|
||||
|
||||
class Position
|
||||
use phpOMS\Contract\ArrayableInterface;
|
||||
|
||||
class Position implements ArrayableInterface, \JsonSerializable
|
||||
{
|
||||
private $id = 0;
|
||||
|
||||
|
|
@ -45,7 +47,8 @@ class Position
|
|||
return $this->parent;
|
||||
}
|
||||
|
||||
public function setParent(int $parent) {
|
||||
public function setParent(int $parent)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
|
|
@ -58,4 +61,39 @@ class Position
|
|||
{
|
||||
$this->description = $desc;
|
||||
}
|
||||
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'description' => $this->description,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get string representation.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->jsonSerialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Json serialize.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return json_encode($this->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,9 @@
|
|||
*/
|
||||
namespace Modules\Organization\Models;
|
||||
|
||||
class Unit
|
||||
use phpOMS\Contract\ArrayableInterface;
|
||||
|
||||
class Unit implements ArrayableInterface, \JsonSerializable
|
||||
{
|
||||
private $id = 0;
|
||||
|
||||
|
|
@ -45,7 +47,8 @@ class Unit
|
|||
return $this->parent;
|
||||
}
|
||||
|
||||
public function setParent(int $parent) {
|
||||
public function setParent(int $parent)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
|
|
@ -58,4 +61,39 @@ class Unit
|
|||
{
|
||||
$this->description = $desc;
|
||||
}
|
||||
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'description' => $this->description,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get string representation.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->jsonSerialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Json serialize.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return json_encode($this->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user