實作管理者用戶管理、邀請註冊功能
This commit is contained in:
34
app/api/admin/users/[id]/stats/route.ts
Normal file
34
app/api/admin/users/[id]/stats/route.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { UserService } from '@/lib/services/database-service'
|
||||
|
||||
const userService = new UserService()
|
||||
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
try {
|
||||
const { id: userId } = await params
|
||||
|
||||
if (!userId) {
|
||||
return NextResponse.json(
|
||||
{ success: false, error: '用戶 ID 是必需的' },
|
||||
{ status: 400 }
|
||||
)
|
||||
}
|
||||
|
||||
const stats = await userService.getUserDetailedStats(userId)
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
data: stats
|
||||
})
|
||||
|
||||
} catch (error) {
|
||||
console.error('獲取用戶統計數據錯誤:', error)
|
||||
return NextResponse.json(
|
||||
{ success: false, error: '獲取用戶統計數據時發生錯誤' },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user