init
This commit is contained in:
31
app/api/kpi/[id]/route.ts
Normal file
31
app/api/kpi/[id]/route.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { kpiService } from '@/lib/database'
|
||||
|
||||
// PUT - 更新 KPI
|
||||
export async function PUT(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
try {
|
||||
const body = await request.json()
|
||||
const kpi = await kpiService.updateKPI(params.id, body)
|
||||
return NextResponse.json(kpi)
|
||||
} catch (error) {
|
||||
console.error('更新 KPI 失敗:', error)
|
||||
return NextResponse.json({ error: '更新 KPI 失敗' }, { status: 500 })
|
||||
}
|
||||
}
|
||||
|
||||
// DELETE - 刪除 KPI
|
||||
export async function DELETE(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
try {
|
||||
await kpiService.deleteKPI(params.id)
|
||||
return NextResponse.json({ message: 'KPI 刪除成功' })
|
||||
} catch (error) {
|
||||
console.error('刪除 KPI 失敗:', error)
|
||||
return NextResponse.json({ error: '刪除 KPI 失敗' }, { status: 500 })
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user