feat:인터뷰 시나리오 MD 파일 업로드 일괄 생성 기능

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
김보곤
2026-02-06 21:42:14 +09:00
parent 79f6fc29e8
commit 32cbef9ae3
4 changed files with 170 additions and 0 deletions

View File

@@ -141,6 +141,59 @@ public function deleteQuestion(int $id): void
$question->delete();
}
// ============================================================
// MD 파일 일괄 가져오기
// ============================================================
public function bulkImport(int $categoryId, array $templates): array
{
return DB::transaction(function () use ($categoryId, $templates) {
$tenantId = session('selected_tenant_id', 1);
$userId = auth()->id();
$maxTemplateSort = InterviewTemplate::where('interview_category_id', $categoryId)
->max('sort_order') ?? 0;
$createdTemplates = 0;
$createdQuestions = 0;
foreach ($templates as $tpl) {
$maxTemplateSort++;
$template = InterviewTemplate::create([
'tenant_id' => $tenantId,
'interview_category_id' => $categoryId,
'name' => $tpl['name'],
'sort_order' => $maxTemplateSort,
'is_active' => true,
'created_by' => $userId,
'updated_by' => $userId,
]);
$createdTemplates++;
$questionSort = 0;
foreach ($tpl['questions'] as $questionText) {
$questionSort++;
InterviewQuestion::create([
'tenant_id' => $tenantId,
'interview_template_id' => $template->id,
'question_text' => $questionText,
'question_type' => 'checkbox',
'is_required' => false,
'sort_order' => $questionSort,
'is_active' => true,
'created_by' => $userId,
'updated_by' => $userId,
]);
$createdQuestions++;
}
}
return [
'templates_created' => $createdTemplates,
'questions_created' => $createdQuestions,
];
});
}
// ============================================================
// 전체 트리 조회
// ============================================================