feat:인터뷰 시나리오 MD 파일 업로드 일괄 생성 기능
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 전체 트리 조회
|
||||
// ============================================================
|
||||
|
||||
Reference in New Issue
Block a user