exec("SET NAMES 'utf8mb4'"); // JSON 입력 받기 $raw = file_get_contents('php://input'); $req = json_decode($raw, true); $contentId = trim((string)($req['content_id'] ?? '')); $tab = trim((string)($req['tab'] ?? '')); if ($contentId === '') { response_json([ 'success' => false, 'message' => 'content_id가 없습니다.' ]); } // 탭별 삭제 처리 if ($tab === 'watching') { // 시청중 목록 제거: 학습이력 삭제 대신 // "마이페이지에서 숨김" 정책이 아직 없으면 임시로 위시리스트 제거만 처리하거나 // 별도 정책 확정 필요 $stmt = $pdo->prepare(" DELETE FROM edu_learning_histories WHERE member_id = :member_id AND sys_comp_code = :sys_comp_code AND content_id = :content_id "); $stmt->execute([ ':member_id' => $memberId, ':sys_comp_code' => $sysCompCode, ':content_id' => $contentId, ]); } elseif ($tab === 'completed') { // 시청완료 목록 제거 $stmt = $pdo->prepare(" DELETE FROM edu_learning_histories WHERE member_id = :member_id AND sys_comp_code = :sys_comp_code AND content_id = :content_id "); $stmt->execute([ ':member_id' => $memberId, ':sys_comp_code' => $sysCompCode, ':content_id' => $contentId, ]); } elseif ($tab === 'saved') { // 저장한 콘텐츠 제거 $stmt = $pdo->prepare(" DELETE FROM edu_content_wishlist WHERE member_id = :member_id AND sys_comp_code = :sys_comp_code AND content_id = :content_id "); $stmt->execute([ ':member_id' => $memberId, ':sys_comp_code' => $sysCompCode, ':content_id' => $contentId, ]); } else { response_json([ 'success' => false, 'message' => '유효하지 않은 탭입니다.' ]); } response_json([ 'success' => true, 'content_id' => $contentId, 'tab' => $tab ]); } catch (Throwable $e) { response_json([ 'success' => false, 'message' => '삭제 처리 중 오류가 발생했습니다.', 'error' => $e->getMessage() ]); }