- Add Nuxt 3 + Prisma + SQLite full-stack setup - Add student CRUD API with batch import/export - Add stats dashboard with gender/class distribution - Add target community settings feature - Add Docker deployment support (Dockerfile + docker-compose) - Add README with development and deployment instructions
29 lines
737 B
TypeScript
29 lines
737 B
TypeScript
import { prisma } from '~/server/utils/prisma'
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const body = await readBody(event)
|
|
|
|
if (!Array.isArray(body.students)) {
|
|
throw createError({
|
|
statusCode: 400,
|
|
message: 'Invalid data format'
|
|
})
|
|
}
|
|
|
|
const result = await prisma.student.createMany({
|
|
data: body.students.map((s: any) => ({
|
|
className: s.className,
|
|
name: s.name,
|
|
gender: s.gender || '',
|
|
birthday: s.birthday || null,
|
|
address: s.address || null,
|
|
fatherName: s.fatherName || null,
|
|
fatherPhone: s.fatherPhone || null,
|
|
motherName: s.motherName || null,
|
|
motherPhone: s.motherPhone || null
|
|
}))
|
|
})
|
|
|
|
return { count: result.count }
|
|
})
|