mirror of
https://github.com/Karaka-Management/oms-Organization.git
synced 2026-02-17 16:58:41 +00:00
org -> unit change, some new functionality
This commit is contained in:
parent
67424ec6cf
commit
8b153555af
|
|
@ -1,54 +1,4 @@
|
||||||
{
|
{
|
||||||
"organization_unit": {
|
|
||||||
"name": "organization_unit",
|
|
||||||
"fields": {
|
|
||||||
"organization_unit_id": {
|
|
||||||
"name": "organization_unit_id",
|
|
||||||
"type": "INT",
|
|
||||||
"null": false,
|
|
||||||
"primary": true,
|
|
||||||
"autoincrement": true
|
|
||||||
},
|
|
||||||
"organization_unit_name": {
|
|
||||||
"name": "organization_unit_name",
|
|
||||||
"type": "VARCHAR(50)",
|
|
||||||
"default": null,
|
|
||||||
"null": true
|
|
||||||
},
|
|
||||||
"organization_unit_image": {
|
|
||||||
"name": "organization_unit_image",
|
|
||||||
"type": "INT",
|
|
||||||
"default": null,
|
|
||||||
"null": true
|
|
||||||
},
|
|
||||||
"organization_unit_description": {
|
|
||||||
"name": "organization_unit_description",
|
|
||||||
"type": "TEXT",
|
|
||||||
"default": null,
|
|
||||||
"null": true
|
|
||||||
},
|
|
||||||
"organization_unit_descriptionraw": {
|
|
||||||
"name": "organization_unit_descriptionraw",
|
|
||||||
"type": "TEXT",
|
|
||||||
"default": null,
|
|
||||||
"null": true
|
|
||||||
},
|
|
||||||
"organization_unit_parent": {
|
|
||||||
"name": "organization_unit_parent",
|
|
||||||
"type": "INT",
|
|
||||||
"default": null,
|
|
||||||
"null": true,
|
|
||||||
"foreignTable": "organization_unit",
|
|
||||||
"foreignKey": "organization_unit_id"
|
|
||||||
},
|
|
||||||
"organization_unit_status": {
|
|
||||||
"name": "organization_unit_status",
|
|
||||||
"type": "TINYINT",
|
|
||||||
"default": null,
|
|
||||||
"null": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"organization_department": {
|
"organization_department": {
|
||||||
"name": "organization_department",
|
"name": "organization_department",
|
||||||
"fields": {
|
"fields": {
|
||||||
|
|
@ -95,8 +45,8 @@
|
||||||
"name": "organization_department_unit",
|
"name": "organization_department_unit",
|
||||||
"type": "INT",
|
"type": "INT",
|
||||||
"null": false,
|
"null": false,
|
||||||
"foreignTable": "organization_unit",
|
"foreignTable": "unit",
|
||||||
"foreignKey": "organization_unit_id"
|
"foreignKey": "unit_id"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,9 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Modules\Organization\Controller;
|
namespace Modules\Organization\Controller;
|
||||||
|
|
||||||
|
use Model\Setting;
|
||||||
|
use Model\SettingMapper;
|
||||||
|
use Modules\Admin\Models\SettingsEnum as ModelsSettingsEnum;
|
||||||
use Modules\Media\Models\PathSettings;
|
use Modules\Media\Models\PathSettings;
|
||||||
use Modules\Organization\Models\Department;
|
use Modules\Organization\Models\Department;
|
||||||
use Modules\Organization\Models\DepartmentMapper;
|
use Modules\Organization\Models\DepartmentMapper;
|
||||||
|
|
@ -28,6 +31,7 @@ use Modules\Organization\Models\Unit;
|
||||||
use Modules\Organization\Models\UnitMapper;
|
use Modules\Organization\Models\UnitMapper;
|
||||||
use phpOMS\Account\GroupStatus;
|
use phpOMS\Account\GroupStatus;
|
||||||
use phpOMS\Message\Http\HttpRequest;
|
use phpOMS\Message\Http\HttpRequest;
|
||||||
|
use phpOMS\Message\Http\HttpResponse;
|
||||||
use phpOMS\Message\Http\RequestStatusCode;
|
use phpOMS\Message\Http\RequestStatusCode;
|
||||||
use phpOMS\Message\NotificationLevel;
|
use phpOMS\Message\NotificationLevel;
|
||||||
use phpOMS\Message\RequestAbstract;
|
use phpOMS\Message\RequestAbstract;
|
||||||
|
|
@ -187,11 +191,24 @@ final class ApiController extends Controller
|
||||||
/** @var \Model\Setting $setting */
|
/** @var \Model\Setting $setting */
|
||||||
$setting = $this->app->appSettings->get(null, SettingsEnum::GROUP_GENERATE_AUTOMATICALLY_UNIT);
|
$setting = $this->app->appSettings->get(null, SettingsEnum::GROUP_GENERATE_AUTOMATICALLY_UNIT);
|
||||||
if ($setting->content === '1') {
|
if ($setting->content === '1') {
|
||||||
|
$internalResponse = new HttpResponse();
|
||||||
$newRequest = new HttpRequest();
|
$newRequest = new HttpRequest();
|
||||||
$newRequest->header->account = $request->header->account;
|
$newRequest->header->account = $request->header->account;
|
||||||
$newRequest->setData('name', 'org:unit:' . \strtolower($unit->name));
|
$newRequest->setData('name', 'unit:' . \strtolower($unit->name));
|
||||||
$newRequest->setData('status', GroupStatus::ACTIVE);
|
$newRequest->setData('status', GroupStatus::ACTIVE);
|
||||||
$this->app->moduleManager->get('Admin')->apiGroupCreate($newRequest, $response, $data);
|
|
||||||
|
$this->app->moduleManager->get('Admin')->apiGroupCreate($newRequest, $internalResponse, $data);
|
||||||
|
$group = $internalResponse->get($newRequest->uri->__toString())['response'];
|
||||||
|
|
||||||
|
$setting = new Setting(
|
||||||
|
0,
|
||||||
|
ModelsSettingsEnum::UNIT_DEFAULT_GROUPS,
|
||||||
|
\json_encode([$group->getId()]),
|
||||||
|
unit: $unit->getId(),
|
||||||
|
module: 'Admin'
|
||||||
|
);
|
||||||
|
$this->createModel($request->header->account, $setting, SettingMapper::class, 'setting', $request->getOrigin());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Unit', 'Unit successfully created.', $unit);
|
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Unit', 'Unit successfully created.', $unit);
|
||||||
|
|
|
||||||
|
|
@ -34,13 +34,13 @@ final class UnitMapper extends DataMapperFactory
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public const COLUMNS = [
|
public const COLUMNS = [
|
||||||
'organization_unit_id' => ['name' => 'organization_unit_id', 'type' => 'int', 'internal' => 'id'],
|
'unit_id' => ['name' => 'unit_id', 'type' => 'int', 'internal' => 'id'],
|
||||||
'organization_unit_name' => ['name' => 'organization_unit_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
|
'unit_name' => ['name' => 'unit_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
|
||||||
'organization_unit_image' => ['name' => 'organization_unit_image', 'type' => 'int', 'internal' => 'image'],
|
'unit_image' => ['name' => 'unit_image', 'type' => 'int', 'internal' => 'image'],
|
||||||
'organization_unit_description' => ['name' => 'organization_unit_description', 'type' => 'string', 'internal' => 'description'],
|
'unit_description' => ['name' => 'unit_description', 'type' => 'string', 'internal' => 'description'],
|
||||||
'organization_unit_descriptionraw' => ['name' => 'organization_unit_descriptionraw', 'type' => 'string', 'internal' => 'descriptionRaw'],
|
'unit_descriptionraw' => ['name' => 'unit_descriptionraw', 'type' => 'string', 'internal' => 'descriptionRaw'],
|
||||||
'organization_unit_parent' => ['name' => 'organization_unit_parent', 'type' => 'int', 'internal' => 'parent'],
|
'unit_parent' => ['name' => 'unit_parent', 'type' => 'int', 'internal' => 'parent'],
|
||||||
'organization_unit_status' => ['name' => 'organization_unit_status', 'type' => 'int', 'internal' => 'status'],
|
'unit_status' => ['name' => 'unit_status', 'type' => 'int', 'internal' => 'status'],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -52,7 +52,7 @@ final class UnitMapper extends DataMapperFactory
|
||||||
public const OWNS_ONE = [
|
public const OWNS_ONE = [
|
||||||
'image' => [
|
'image' => [
|
||||||
'mapper' => MediaMapper::class,
|
'mapper' => MediaMapper::class,
|
||||||
'external' => 'organization_unit_image',
|
'external' => 'unit_image',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -65,7 +65,7 @@ final class UnitMapper extends DataMapperFactory
|
||||||
public const BELONGS_TO = [
|
public const BELONGS_TO = [
|
||||||
'parent' => [
|
'parent' => [
|
||||||
'mapper' => self::class,
|
'mapper' => self::class,
|
||||||
'external' => 'organization_unit_parent',
|
'external' => 'unit_parent',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -83,7 +83,7 @@ final class UnitMapper extends DataMapperFactory
|
||||||
* @var string
|
* @var string
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public const TABLE = 'organization_unit';
|
public const TABLE = 'unit';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Primary field name.
|
* Primary field name.
|
||||||
|
|
@ -91,5 +91,5 @@ final class UnitMapper extends DataMapperFactory
|
||||||
* @var string
|
* @var string
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public const PRIMARYFIELD ='organization_unit_id';
|
public const PRIMARYFIELD ='unit_id';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
|
||||||
};
|
};
|
||||||
|
|
||||||
$this->app->dbPool = $GLOBALS['dbpool'];
|
$this->app->dbPool = $GLOBALS['dbpool'];
|
||||||
$this->app->orgId = 1;
|
$this->app->unitId = 1;
|
||||||
$this->app->accountManager = new AccountManager($GLOBALS['session']);
|
$this->app->accountManager = new AccountManager($GLOBALS['session']);
|
||||||
$this->app->appSettings = new CoreSettings();
|
$this->app->appSettings = new CoreSettings();
|
||||||
$this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../Modules/');
|
$this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../Modules/');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user