Stabilize legacy Steven API endpoints and add OpenAPI spec
This commit is contained in:
57
steven/API/getListKK.php
Normal file
57
steven/API/getListKK.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
include '../conf/class.server.php';
|
||||
include '../conf/koneksiPDO.php';
|
||||
include '../conf/function.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$server = new Server();
|
||||
|
||||
$conn = new createCon();
|
||||
$dbh = $conn->connect();
|
||||
|
||||
checkKey('GET', 'secret');
|
||||
|
||||
requireRobotSecret();
|
||||
|
||||
$sql = 'SELECT * FROM tb_kelompok_keahlian LEFT JOIN tbdosen ON tb_kelompok_keahlian.ketuaKK = tbdosen.iddosen';
|
||||
$stmt = $dbh->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
$data = [];
|
||||
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$idKK = $row['idKK'];
|
||||
$listAnggotaKK = [];
|
||||
|
||||
array_push($listAnggotaKK, [
|
||||
'status' => 'ketua',
|
||||
'id' => $row['iddosen'],
|
||||
'nama' => $row['nmLengkap'],
|
||||
]);
|
||||
|
||||
$sql = 'SELECT * FROM tbdosen WHERE kelompokKeahlian = :kk';
|
||||
$stmt1 = $dbh->prepare($sql);
|
||||
$stmt1->bindParam(':kk', $idKK);
|
||||
$stmt1->execute();
|
||||
|
||||
while ($row1 = $stmt1->fetch(PDO::FETCH_ASSOC)) {
|
||||
if ($row1['iddosen'] == $row['iddosen']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
array_push($listAnggotaKK, [
|
||||
'status' => 'anggota',
|
||||
'id' => $row1['iddosen'],
|
||||
'nama' => $row1['nmLengkap'],
|
||||
]);
|
||||
}
|
||||
|
||||
array_push($data, [
|
||||
'id' => $row['idKK'],
|
||||
'nama' => $row['namaKK'],
|
||||
'anggotaKK' => $listAnggotaKK,
|
||||
]);
|
||||
}
|
||||
|
||||
echo json_encode(utf8ize(['status' => 1, 'data' => $data]));
|
||||
Reference in New Issue
Block a user