From d5c8cac5ec0ef742649176f74be18b11137084c7 Mon Sep 17 00:00:00 2001 From: mahdahar <89adham@gmail.com> Date: Fri, 24 Oct 2025 16:41:31 +0700 Subject: [PATCH] prework --- app/Controllers/Test/ValueSetDef.php | 69 +++++++++++++++++++ ...nt copy.php => 2025-10-11-100001_Test.php} | 0 app/Models/RefRange/RefNumModel.php | 20 ++++++ app/Models/RefRange/RefTHoldModel.php | 20 ++++++ app/Models/RefRange/RefVSetModel.php | 19 +++++ app/Models/Test/TestDefCalModel.php | 19 +++++ app/Models/Test/TestDefModel.php | 19 +++++ app/Models/Test/TestDefSiteModel.php | 19 +++++ app/Models/Test/TestDefTechModel.php | 20 ++++++ app/Models/Test/TestGrpModel.php | 18 +++++ 10 files changed, 223 insertions(+) create mode 100644 app/Controllers/Test/ValueSetDef.php rename app/Database/Migrations/{2025-10-11-100001_Test_Management copy.php => 2025-10-11-100001_Test.php} (100%) create mode 100644 app/Models/RefRange/RefNumModel.php create mode 100644 app/Models/RefRange/RefTHoldModel.php create mode 100644 app/Models/RefRange/RefVSetModel.php create mode 100644 app/Models/Test/TestDefCalModel.php create mode 100644 app/Models/Test/TestDefModel.php create mode 100644 app/Models/Test/TestDefSiteModel.php create mode 100644 app/Models/Test/TestDefTechModel.php create mode 100644 app/Models/Test/TestGrpModel.php diff --git a/app/Controllers/Test/ValueSetDef.php b/app/Controllers/Test/ValueSetDef.php new file mode 100644 index 0000000..bea445c --- /dev/null +++ b/app/Controllers/Test/ValueSetDef.php @@ -0,0 +1,69 @@ +db = \Config\Database::connect(); + $this->model = new TestDefModel; + } + + public function index() { + $param = $this->request->getVar('param'); + $rows = $this->model->getValueSetDefs($param); + if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200); } + return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200); + } + + public function show($VSetID = null) { + $rows = $this->model->find($VSetID); + if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200); } + return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200); + } + + public function create() { + $input = $this->request->getJSON(true); + if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); } + try { + $VSetID = $this->model->insert($input); + return $this->respondCreated([ 'status' => 'success', 'message' => "data $VSetID created successfully" ]); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + + public function update() { + $input = $this->request->getJSON(true); + $VSetID = $input["VID"]; + if (!$VSetID) { return $this->failValidationErrors('VSetID is required.'); } + if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors( $this->validator->getErrors() ); } + try { + $this->model->update($VSetID,$input); + return $this->respondCreated([ 'status' => 'success', 'message' => "data $VSetID updated successfully" ]); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + + public function delete() { + $input = $this->request->getJSON(true); + $VSetID = $input['VSetID']; + if (!$VSetID) { return $this->failValidationErrors('VSetID is required.'); } + try { + $this->model->delete($VSetID); + return $this->respondDeleted(['status' => 'success', 'message' => "Data $VSetID deleted successfully."]); + } catch (\Throwable $e) { + return $this->failServerError('Something went wrong: ' . $e->getMessage()); + } + } + +} \ No newline at end of file diff --git a/app/Database/Migrations/2025-10-11-100001_Test_Management copy.php b/app/Database/Migrations/2025-10-11-100001_Test.php similarity index 100% rename from app/Database/Migrations/2025-10-11-100001_Test_Management copy.php rename to app/Database/Migrations/2025-10-11-100001_Test.php diff --git a/app/Models/RefRange/RefNumModel.php b/app/Models/RefRange/RefNumModel.php new file mode 100644 index 0000000..6bc1e82 --- /dev/null +++ b/app/Models/RefRange/RefNumModel.php @@ -0,0 +1,20 @@ +