Stabilize legacy Steven API endpoints and add OpenAPI spec
This commit is contained in:
78
steven/API/willy_updateDataRekapHasil.php
Normal file
78
steven/API/willy_updateDataRekapHasil.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', '0');
|
||||
|
||||
include '../conf/class.server.php';
|
||||
include '../conf/koneksiPDO.php';
|
||||
include '../conf/function.php';
|
||||
|
||||
header("Content-Type: application/json");
|
||||
|
||||
$conn = new createCon();
|
||||
$dbh = $conn->connect();
|
||||
$jsonData = getRequestJson();
|
||||
|
||||
requireRobotSecret();
|
||||
|
||||
$act = isset($jsonData['act']) ? $jsonData['act'] : '';
|
||||
|
||||
// if($jsonData['nim'] != "D03111037"){
|
||||
// echo json_encode([
|
||||
// 'status' => false,
|
||||
// 'msg' => "NIM yang diinjikan hanya D03111037",
|
||||
// ]);
|
||||
// exit;
|
||||
// }
|
||||
|
||||
switch($act){
|
||||
case 'update' :
|
||||
if(!(empty($jsonData['id']) || empty($jsonData['judul']))){
|
||||
$id = $jsonData['id'];
|
||||
$judul = $jsonData['judul'];
|
||||
|
||||
$sql = "UPDATE tbrekaphasil SET judul_final = :judul WHERE id = :id";
|
||||
$stmt = $dbh->prepare($sql);
|
||||
$stmt->bindParam(':id', $id);
|
||||
$stmt->bindParam(':judul', $judul);
|
||||
$stmt->execute();
|
||||
|
||||
$error = $stmt->errorInfo();
|
||||
|
||||
$isError = true;
|
||||
|
||||
if ($error[0] == '00000') {
|
||||
$isError = false;
|
||||
}
|
||||
|
||||
if ($isError) {
|
||||
echo json_encode(
|
||||
[
|
||||
'status' => false,
|
||||
'msg' => 'Terjadi kesalahan teknis!!!',
|
||||
]
|
||||
);
|
||||
} else {
|
||||
echo json_encode(
|
||||
[
|
||||
'status' => true,
|
||||
'msg' => 'Berhasil mengubah data!!!',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
}else{
|
||||
echo json_encode([
|
||||
'status' => false,
|
||||
'msg' => "Parameter tidak lengkap",
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
break;
|
||||
default :
|
||||
echo json_encode([
|
||||
'status' => false,
|
||||
'msg' => "Parameter tidak lengkap",
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
Reference in New Issue
Block a user