add organization endpoint
This commit is contained in:
parent
4fea4e1385
commit
112e6ec311
@ -94,6 +94,32 @@ $routes->post('/api/containerdef', 'Specimen\ContainerDef::create');
|
||||
$routes->patch('/api/containerdef', 'Specimen\ContainerDef::update');
|
||||
$routes->delete('/api/containerdef', 'Specimen\ContainerDef::delete');
|
||||
|
||||
//organization
|
||||
// discipline
|
||||
$routes->get('/api/organization/discipline/', 'Organization\Discipline::index');
|
||||
$routes->get('/api/organization/discipline/(:num)', 'Organization\Discipline::show/$1');
|
||||
$routes->post('/api/organization/discipline', 'Organization\Discipline::create');
|
||||
$routes->patch('/api/organization/discipline', 'Organization\Discipline::update');
|
||||
$routes->delete('/api/organization/discipline', 'Organization\Discipline::delete');
|
||||
// department
|
||||
$routes->get('/api/organization/department/', 'Organization\Department::index');
|
||||
$routes->get('/api/organization/department/(:num)', 'Organization\Department::show/$1');
|
||||
$routes->post('/api/organization/department', 'Organization\Department::create');
|
||||
$routes->patch('/api/organization/department', 'Organization\Department::update');
|
||||
$routes->delete('/api/organization/department', 'Organization\Department::delete');
|
||||
// workstation
|
||||
$routes->get('/api/organization/workstation/', 'Organization\Workstation::index');
|
||||
$routes->get('/api/organization/workstation/(:num)', 'Organization\Workstation::show/$1');
|
||||
$routes->post('/api/organization/workstation', 'Organization\Workstation::create');
|
||||
$routes->patch('/api/organization/workstation', 'Organization\Workstation::update');
|
||||
$routes->delete('/api/organization/workstation', 'Organization\Workstation::delete');
|
||||
// workbench
|
||||
$routes->get('/api/organization/workbench/', 'Organization\Workbench::index');
|
||||
$routes->get('/api/organization/workbench/(:num)', 'Organization\Workbench::show/$1');
|
||||
$routes->post('/api/organization/workbench', 'Organization\Workbench::create');
|
||||
$routes->patch('/api/organization/workbench', 'Organization\Workbench::update');
|
||||
$routes->delete('/api/organization/workbench', 'Organization\Workbench::delete');
|
||||
|
||||
// Khusus
|
||||
$routes->get('/api/zones', 'Zones::index');
|
||||
$routes->get('/api/zones/synchronize', 'Zones::synchronize');
|
||||
|
||||
72
app/Controllers/Organization/Department.php
Normal file
72
app/Controllers/Organization/Department.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
namespace App\Controllers\Organization;
|
||||
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
use App\Models\Organization\DepartmentModel;
|
||||
|
||||
class Department extends BaseController {
|
||||
use ResponseTrait;
|
||||
|
||||
protected $db;
|
||||
protected $model;
|
||||
|
||||
public function __construct() {
|
||||
$this->db = \Config\Database::connect();
|
||||
$this->model = new DepartmentModel();
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$rows = $this->model->findAll();
|
||||
|
||||
if (empty($rows)) {
|
||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
||||
}
|
||||
|
||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
||||
}
|
||||
|
||||
public function show($DepartmentID = null) {
|
||||
$rows = $this->model->where('DepartmentID', $DepartmentID)->findAll();
|
||||
|
||||
if (empty($rows)) {
|
||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
||||
}
|
||||
|
||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
try {
|
||||
$input = $this->request->getJSON(true);
|
||||
$id = $input["DepartmentID"];
|
||||
if (!$id) { return $this->failValidationErrors('ID is required.'); }
|
||||
$this->model->delete($id);
|
||||
return $this->respondDeleted([ 'status' => 'success', 'message' => "{$id} deleted successfully."]);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function create() {
|
||||
$input = $this->request->getJSON(true);
|
||||
try {
|
||||
$id = $this->model->insert($input,true);
|
||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function update() {
|
||||
$input = $this->request->getJSON(true);
|
||||
try {
|
||||
$id = $input['DepartmentID'];
|
||||
$this->model->where('DepartmentID', $id)->update();
|
||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
72
app/Controllers/Organization/Discipline.php
Normal file
72
app/Controllers/Organization/Discipline.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
namespace App\Controllers\Organization;
|
||||
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
use App\Models\Organization\DisciplineModel;
|
||||
|
||||
class Discipline extends BaseController {
|
||||
use ResponseTrait;
|
||||
|
||||
protected $db;
|
||||
protected $model;
|
||||
|
||||
public function __construct() {
|
||||
$this->db = \Config\Database::connect();
|
||||
$this->model = new DisciplineModel();
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$rows = $this->model->findAll();
|
||||
|
||||
if (empty($rows)) {
|
||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
||||
}
|
||||
|
||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
||||
}
|
||||
|
||||
public function show($DisciplineID = null) {
|
||||
$rows = $this->model->where('DisciplineID', $DisciplineID)->findAll();
|
||||
|
||||
if (empty($rows)) {
|
||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
||||
}
|
||||
|
||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
try {
|
||||
$input = $this->request->getJSON(true);
|
||||
$id = $input["DisciplineID"];
|
||||
if (!$id) { return $this->failValidationErrors('ID is required.'); }
|
||||
$this->model->delete($id);
|
||||
return $this->respondDeleted([ 'status' => 'success', 'message' => "{$id} deleted successfully."]);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function create() {
|
||||
$input = $this->request->getJSON(true);
|
||||
try {
|
||||
$id = $this->model->insert($input,true);
|
||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function update() {
|
||||
$input = $this->request->getJSON(true);
|
||||
try {
|
||||
$id = $input['DisciplineID'];
|
||||
$this->model->where('DisciplineID', $id)->update();
|
||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
72
app/Controllers/Organization/Workbench.php
Normal file
72
app/Controllers/Organization/Workbench.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
namespace App\Controllers\Organization;
|
||||
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
use App\Models\Organization\WorkbenchModel;
|
||||
|
||||
class Workbench extends BaseController {
|
||||
use ResponseTrait;
|
||||
|
||||
protected $db;
|
||||
protected $model;
|
||||
|
||||
public function __construct() {
|
||||
$this->db = \Config\Database::connect();
|
||||
$this->model = new WorkbenchModel();
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$rows = $this->model->findAll();
|
||||
|
||||
if (empty($rows)) {
|
||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
||||
}
|
||||
|
||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
||||
}
|
||||
|
||||
public function show($WorkbenchID = null) {
|
||||
$rows = $this->model->where('WorkbenchID', $WorkbenchID)->findAll();
|
||||
|
||||
if (empty($rows)) {
|
||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
||||
}
|
||||
|
||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
try {
|
||||
$input = $this->request->getJSON(true);
|
||||
$id = $input["WorkbenchID"];
|
||||
if (!$id) { return $this->failValidationErrors('ID is required.'); }
|
||||
$this->model->delete($id);
|
||||
return $this->respondDeleted([ 'status' => 'success', 'message' => "{$id} deleted successfully."]);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function create() {
|
||||
$input = $this->request->getJSON(true);
|
||||
try {
|
||||
$id = $this->model->insert($input,true);
|
||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function update() {
|
||||
$input = $this->request->getJSON(true);
|
||||
try {
|
||||
$id = $input['WorkbenchID'];
|
||||
$this->model->where('WorkbenchID', $id)->update();
|
||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
72
app/Controllers/Organization/Workstation.php
Normal file
72
app/Controllers/Organization/Workstation.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
namespace App\Controllers\Organization;
|
||||
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
use App\Models\Organization\WorkstationModel;
|
||||
|
||||
class Workstation extends BaseController {
|
||||
use ResponseTrait;
|
||||
|
||||
protected $db;
|
||||
protected $model;
|
||||
|
||||
public function __construct() {
|
||||
$this->db = \Config\Database::connect();
|
||||
$this->model = new WorkstationModel();
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$rows = $this->model->findAll();
|
||||
|
||||
if (empty($rows)) {
|
||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
||||
}
|
||||
|
||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
||||
}
|
||||
|
||||
public function show($WorkstationID = null) {
|
||||
$rows = $this->model->where('WorkstationID', $WorkstationID)->findAll();
|
||||
|
||||
if (empty($rows)) {
|
||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
||||
}
|
||||
|
||||
return $this->respond([ 'status' => 'success', 'message'=> "fetch success", 'data' => $rows ], 200);
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
try {
|
||||
$input = $this->request->getJSON(true);
|
||||
$id = $input["WorkstationID"];
|
||||
if (!$id) { return $this->failValidationErrors('ID is required.'); }
|
||||
$this->model->delete($id);
|
||||
return $this->respondDeleted([ 'status' => 'success', 'message' => "{$id} deleted successfully."]);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function create() {
|
||||
$input = $this->request->getJSON(true);
|
||||
try {
|
||||
$id = $this->model->insert($input,true);
|
||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'data created successfully', 'data' => $id ], 201);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function update() {
|
||||
$input = $this->request->getJSON(true);
|
||||
try {
|
||||
$id = $input['WorkstationID'];
|
||||
$this->model->where('WorkstationID', $id)->update();
|
||||
return $this->respondCreated([ 'status' => 'success', 'message' => 'data updated successfully', 'data' => $id ], 201);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4,7 +4,7 @@ namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class CreateTestsTable extends Migration {
|
||||
class CreateRefRangesTable extends Migration {
|
||||
public function up() {
|
||||
|
||||
$this->forge->addField([
|
||||
|
||||
@ -13,7 +13,7 @@ class Organization extends Migration {
|
||||
'CreateDate' => ['type'=>'DATETIME', 'null' => true],
|
||||
'EndDate' => ['type'=>'DATETIME', 'null' => true]
|
||||
]);
|
||||
$this->forge->addKey('DiciplineID', true);
|
||||
$this->forge->addKey('DisciplineID', true);
|
||||
$this->forge->createTable('discipline');
|
||||
|
||||
$this->forge->addField([
|
||||
|
||||
65
app/Database/Migrations/2025-10-29-100201_Equipment.php
Normal file
65
app/Database/Migrations/2025-10-29-100201_Equipment.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class Equipment extends Migration {
|
||||
|
||||
public function up() {
|
||||
$this->forge->addField([
|
||||
'EquipmentID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true],
|
||||
'DepartmentID' => ['type' => 'int', 'constraint'=> 10, 'null'=> false],
|
||||
'InstrumentID' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true],
|
||||
'InstrumentName' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true],
|
||||
'Enable' => ['type' => 'bit', 'null'=> false],
|
||||
'EquipmentRole' => ['type' => 'varchar', 'constraint' => 1, 'null'=> false],
|
||||
'CreateDate' => ['type'=>'DATETIME', 'null' => true],
|
||||
'EndDate' => ['type'=>'DATETIME', 'null' => true]
|
||||
]);
|
||||
$this->forge->addKey('EquipmentID', true);
|
||||
$this->forge->createTable('equipmentlist');
|
||||
|
||||
$this->forge->addField([
|
||||
'InterfaceID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true],
|
||||
'InstrumentID' => ['type' => 'int', 'null'=> false],
|
||||
'SiteID' => ['type' => 'int', 'null'=> true],
|
||||
'InterfaceName' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true],
|
||||
'InterfaceDesc' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true],
|
||||
'Protocol' => ['type' => 'varchar', 'constraint'=> 50, 'null'=> true],
|
||||
'IPAddress' => ['type' => 'varchar', 'constraint'=> 50, 'null'=> true],
|
||||
'Port' => ['type' => 'varchar', 'constraint'=> 25, 'null'=> true],
|
||||
'COM' => ['type' => 'varchar', 'constraint'=> 5, 'null'=> true],
|
||||
'Baud' => ['type' => 'varchar', 'constraint'=> 10, 'null'=> true],
|
||||
'Data' => ['type' => 'varchar', 'constraint'=> 10, 'null'=> true],
|
||||
'Parity' => ['type' => 'varchar', 'constraint'=> 10, 'null'=> true],
|
||||
'Stop' => ['type' => 'varchar', 'constraint'=> 10, 'null'=> true],
|
||||
'CreateDate' => ['type'=>'DATETIME', 'null' => true],
|
||||
'EndDate' => ['type'=>'DATETIME', 'null' => true]
|
||||
]);
|
||||
$this->forge->addKey('InterfaceID', true);
|
||||
$this->forge->createTable('comparameters');
|
||||
|
||||
$this->forge->addField([
|
||||
'EquipmentID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true],
|
||||
'DeviceName' => ['type' => 'varchar', 'constraint' => 50,'null'=> false],
|
||||
'Description' => ['type' => 'varchar', 'constraint' => 50,'null'=> false],
|
||||
'SiteID' => ['type' => 'int', 'null'=> true],
|
||||
'LocationID' => ['type' => 'int', 'null'=> true],
|
||||
'DIDType' => ['type' => 'varchar', 'constraint'=>10, 'null'=> true],
|
||||
'DID' => ['type' => 'varchar', 'constraint'=>100, 'null'=> true],
|
||||
'MachineID' => ['type' => 'varchar', 'constraint'=>100, 'null'=> true],
|
||||
'IPAddress' => ['type' => 'varchar', 'constraint'=>25, 'null'=> true],
|
||||
'CreateDate' => ['type'=>'DATETIME', 'null' => true],
|
||||
'EndDate' => ['type'=>'DATETIME', 'null' => true]
|
||||
]);
|
||||
$this->forge->addKey('EquipmentID', true);
|
||||
$this->forge->createTable('devicelist');
|
||||
|
||||
}
|
||||
|
||||
public function down() {
|
||||
$this->forge->dropTable('equipmentlist', true);
|
||||
$this->forge->dropTable('comparameters', true);
|
||||
$this->forge->dropTable('devicelist', true);
|
||||
}
|
||||
}
|
||||
16
app/Models/Organization/DepartmentModel.php
Normal file
16
app/Models/Organization/DepartmentModel.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace App\Models\Organization;
|
||||
use App\Models\BaseModel;
|
||||
|
||||
class DepartmentModel extends BaseModel {
|
||||
protected $table = 'department';
|
||||
protected $primaryKey = 'DepartmentID';
|
||||
protected $allowedFields = ['DisciplineID', 'SiteID', 'DepartmentCode', 'DepartmentName', 'CreateDate', 'EndDate'];
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'CreateDate';
|
||||
protected $updatedField = '';
|
||||
protected $useSoftDeletes = true;
|
||||
protected $deletedField = 'EndDate';
|
||||
|
||||
}
|
||||
16
app/Models/Organization/DisciplineModel.php
Normal file
16
app/Models/Organization/DisciplineModel.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace App\Models\Organization;
|
||||
use App\Models\BaseModel;
|
||||
|
||||
class DisciplineModel extends BaseModel {
|
||||
protected $table = 'discipline';
|
||||
protected $primaryKey = 'DisciplineID';
|
||||
protected $allowedFields = ['DisciplineCode', 'DisciplineName', 'CreateDate', 'EndDate'];
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'CreateDate';
|
||||
protected $updatedField = '';
|
||||
protected $useSoftDeletes = true;
|
||||
protected $deletedField = 'EndDate';
|
||||
|
||||
}
|
||||
16
app/Models/Organization/WorkbenchModel.php
Normal file
16
app/Models/Organization/WorkbenchModel.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace App\Models\Organization;
|
||||
use App\Models\BaseModel;
|
||||
|
||||
class WorkbenchModel extends BaseModel {
|
||||
protected $table = 'workbench';
|
||||
protected $primaryKey = 'WorkbenchID';
|
||||
protected $allowedFields = ['DepartmentID', 'WorkbenchCode', 'WorkbenchName', 'EndDate'];
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'CreateDate';
|
||||
protected $updatedField = '';
|
||||
protected $useSoftDeletes = true;
|
||||
protected $deletedField = 'EndDate';
|
||||
|
||||
}
|
||||
17
app/Models/Organization/WorkstationModel.php
Normal file
17
app/Models/Organization/WorkstationModel.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
namespace App\Models\Organization;
|
||||
use App\Models\BaseModel;
|
||||
|
||||
class WorkstationModel extends BaseModel {
|
||||
protected $table = 'workstation';
|
||||
protected $primaryKey = 'WorkstationID';
|
||||
protected $allowedFields = ['DepartmentID', 'WorkstationCode', 'WorkstationName', 'Type', 'LinkTo', 'Enable',
|
||||
'EquipmentID', 'CreateDate', 'EndDate'];
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'CreateDate';
|
||||
protected $updatedField = '';
|
||||
protected $useSoftDeletes = true;
|
||||
protected $deletedField = 'EndDate';
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user