實作管理者用戶管理、邀請註冊功能
This commit is contained in:
46
app/api/admin/users/[id]/activities/route.ts
Normal file
46
app/api/admin/users/[id]/activities/route.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
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
|
||||
const { searchParams } = new URL(request.url)
|
||||
const page = parseInt(searchParams.get('page') || '1')
|
||||
const limit = parseInt(searchParams.get('limit') || '10')
|
||||
const search = searchParams.get('search') || ''
|
||||
const startDate = searchParams.get('startDate') || ''
|
||||
const endDate = searchParams.get('endDate') || ''
|
||||
const activityType = searchParams.get('activityType') || 'all'
|
||||
|
||||
if (!userId) {
|
||||
return NextResponse.json(
|
||||
{ success: false, error: '用戶 ID 是必需的' },
|
||||
{ status: 400 }
|
||||
)
|
||||
}
|
||||
|
||||
const result = await userService.getUserActivities(userId, page, limit, {
|
||||
search,
|
||||
startDate,
|
||||
endDate,
|
||||
activityType
|
||||
})
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
data: result
|
||||
})
|
||||
|
||||
} catch (error) {
|
||||
console.error('獲取用戶活動記錄錯誤:', error)
|
||||
return NextResponse.json(
|
||||
{ success: false, error: '獲取用戶活動記錄時發生錯誤' },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user