Batch 6a: application controllers base
This commit is contained in:
47
application/controllers/tools/Merge_report.php
Normal file
47
application/controllers/tools/Merge_report.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Merge_report extends MY_Controller {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->load->database();
|
||||
}
|
||||
|
||||
public function get($id = null) {
|
||||
header('Content-Type: application/json');
|
||||
|
||||
try {
|
||||
if ($id === null || !is_numeric($id)) {
|
||||
throw new Exception('Invalid or missing ID parameter.');
|
||||
}
|
||||
|
||||
$query = $this->db
|
||||
->select('mergeRequestPayload')
|
||||
->where('mergeRequestID', $id)
|
||||
->get('merge_request');
|
||||
|
||||
if ($query->num_rows() === 0) {
|
||||
throw new Exception('Record not found.');
|
||||
}
|
||||
|
||||
$row = $query->row();
|
||||
$payload = json_decode($row->mergeRequestPayload, true);
|
||||
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw new Exception('Invalid JSON in mergeRequestPayload.');
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
'status' => 'OK',
|
||||
'data' => $payload
|
||||
]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode([
|
||||
'status' => 'ERR',
|
||||
'message' => $e->getMessage()
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user