import { NextRequest, NextResponse } from 'next/server' import { prisma } from '@/lib/prisma' import { auth } from '@/lib/auth' export const dynamic = 'force-dynamic' // DELETE /api/wx-users/level-progress - Batch delete level progress export async function DELETE( request: NextRequest, ) { try { const session = await auth.api.getSession({ headers: request.headers, }) if (!session) { return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }) } const { ids } = await request.json() if (!Array.isArray(ids) || ids.length === 0 || !ids.every((id) => typeof id === 'string')) { return NextResponse.json( { error: 'ids must be a non-empty array of strings' }, { status: 400 } ) } const result = await prisma.wxUserLevelProgress.deleteMany({ where: { id: { in: ids, }, }, }) return NextResponse.json({ deleted: result.count }) } catch (error) { console.error('Error deleting level progress:', error) return NextResponse.json( { error: 'Failed to delete level progress' }, { status: 500 } ) } }