68 lines
1.9 KiB
PHP
68 lines
1.9 KiB
PHP
<?php
|
|
// 출력 버퍼링 시작 및 에러 리포팅 비활성화
|
|
error_reporting(0);
|
|
ob_start();
|
|
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
|
|
|
// 출력 버퍼 비우기
|
|
ob_clean();
|
|
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
|
|
// 1. 권한 및 세션 체크
|
|
if (!isset($user_id) || $level > 5) {
|
|
echo json_encode(['success' => false, 'message' => '접근 권한이 없습니다.']);
|
|
exit;
|
|
}
|
|
|
|
$manager_id = $user_id;
|
|
$step_id = isset($_GET['step_id']) ? intval($_GET['step_id']) : 2;
|
|
$limit = isset($_GET['limit']) ? intval($_GET['limit']) : 20;
|
|
|
|
try {
|
|
$pdo = db_connect();
|
|
if (!$pdo) {
|
|
throw new Exception('데이터베이스 연결 실패');
|
|
}
|
|
|
|
// 저장된 녹음 파일 목록 조회
|
|
$sql = "SELECT id, manager_id, step_id, audio_file_path, transcript_text,
|
|
file_expiry_date, created_at
|
|
FROM manager_consultations
|
|
WHERE manager_id = ? AND step_id = ?
|
|
ORDER BY created_at DESC
|
|
LIMIT ?";
|
|
$stmt = $pdo->prepare($sql);
|
|
|
|
if (!$stmt) {
|
|
throw new Exception('SQL 준비 실패');
|
|
}
|
|
|
|
$stmt->execute([$manager_id, $step_id, $limit]);
|
|
$consultations = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
// 날짜 포맷팅
|
|
foreach ($consultations as &$consultation) {
|
|
$consultation['created_at_formatted'] = date('Y-m-d H:i', strtotime($consultation['created_at']));
|
|
$consultation['is_gcs'] = strpos($consultation['audio_file_path'], 'gs://') === 0;
|
|
}
|
|
|
|
echo json_encode([
|
|
'success' => true,
|
|
'data' => $consultations,
|
|
'count' => count($consultations)
|
|
]);
|
|
|
|
} catch (Exception $e) {
|
|
error_log('조회 오류: ' . $e->getMessage());
|
|
echo json_encode([
|
|
'success' => false,
|
|
'message' => '조회 실패: ' . $e->getMessage(),
|
|
'data' => []
|
|
]);
|
|
}
|
|
?>
|
|
|