實作管理者用戶管理、邀請註冊功能

This commit is contained in:
2025-09-09 15:15:26 +08:00
parent 32b19e9a0f
commit 46bd9db2e3
11 changed files with 1297 additions and 214 deletions

View 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 }
)
}
}