feat(special-curation): complete implementation with all components
- Database: SpecialSong model with startTime - Backend: API endpoints for curation - Admin: Waveform editor and curation page - Game: startTime support in AudioPlayer - UI: Curate button in admin dashboard
This commit is contained in:
86
app/api/specials/[id]/songs/route.ts
Normal file
86
app/api/specials/[id]/songs/route.ts
Normal file
@@ -0,0 +1,86 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
export async function POST(
|
||||
request: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
try {
|
||||
const specialId = parseInt(params.id);
|
||||
const { songId, startTime = 0, order } = await request.json();
|
||||
|
||||
const specialSong = await prisma.specialSong.create({
|
||||
data: {
|
||||
specialId,
|
||||
songId,
|
||||
startTime,
|
||||
order
|
||||
},
|
||||
include: {
|
||||
song: true
|
||||
}
|
||||
});
|
||||
|
||||
return NextResponse.json(specialSong);
|
||||
} catch (error) {
|
||||
console.error('Error adding song to special:', error);
|
||||
return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
export async function PUT(
|
||||
request: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
try {
|
||||
const specialId = parseInt(params.id);
|
||||
const { songId, startTime, order } = await request.json();
|
||||
|
||||
const specialSong = await prisma.specialSong.update({
|
||||
where: {
|
||||
specialId_songId: {
|
||||
specialId,
|
||||
songId
|
||||
}
|
||||
},
|
||||
data: {
|
||||
startTime,
|
||||
order
|
||||
},
|
||||
include: {
|
||||
song: true
|
||||
}
|
||||
});
|
||||
|
||||
return NextResponse.json(specialSong);
|
||||
} catch (error) {
|
||||
console.error('Error updating special song:', error);
|
||||
return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
export async function DELETE(
|
||||
request: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
try {
|
||||
const specialId = parseInt(params.id);
|
||||
const { songId } = await request.json();
|
||||
|
||||
await prisma.specialSong.delete({
|
||||
where: {
|
||||
specialId_songId: {
|
||||
specialId,
|
||||
songId
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return NextResponse.json({ success: true });
|
||||
} catch (error) {
|
||||
console.error('Error removing song from special:', error);
|
||||
return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user