實作個人收藏、個人活動紀錄

This commit is contained in:
2025-09-11 17:40:07 +08:00
parent bc2104d374
commit 9c5dceb001
29 changed files with 3781 additions and 601 deletions

View File

@@ -0,0 +1,41 @@
import { NextRequest, NextResponse } from 'next/server'
import { AppService } from '@/lib/services/database-service'
const appService = new AppService()
export async function GET(request: NextRequest) {
try {
const { searchParams } = new URL(request.url)
const userId = searchParams.get('userId')
if (!userId) {
return NextResponse.json(
{ success: false, error: '缺少用戶ID' },
{ status: 400 }
)
}
// 直接查詢收藏的應用ID不依賴 apps 表的 is_active 狀態)
const favoriteAppIds = await appService.getUserFavoriteAppIds(userId)
console.log('用戶收藏的應用ID列表:', favoriteAppIds)
// 獲取用戶的按讚列表
const likedAppIds = await appService.getUserLikedApps(userId)
console.log('用戶按讚的應用ID列表:', likedAppIds)
return NextResponse.json({
success: true,
data: {
favorites: favoriteAppIds,
likes: likedAppIds
}
})
} catch (error) {
console.error('獲取用戶互動狀態錯誤:', error)
return NextResponse.json(
{ success: false, error: '獲取用戶互動狀態時發生錯誤' },
{ status: 500 }
)
}
}