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

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

@@ -5,26 +5,38 @@ const userService = new UserService()
export async function GET(request: NextRequest) {
try {
// 獲取所有啟用狀態的用戶
// 獲取所有用戶(包括不同狀態)
const sql = `
SELECT id, name, email, department, role
SELECT id, name, email, department, role, status, created_at, last_login
FROM users
WHERE status = 'active'
ORDER BY name ASC
`;
const users = await userService.query(sql);
return NextResponse.json({
success: true,
data: {
users: users.map(user => ({
// 為每個用戶獲取統計數據
const usersWithStats = await Promise.all(
users.map(async (user) => {
const stats = await userService.getUserAppAndReviewStats(user.id);
return {
id: user.id,
name: user.name,
email: user.email,
department: user.department,
role: user.role
}))
role: user.role,
status: user.status,
createdAt: user.created_at,
lastLogin: user.last_login,
appCount: stats.appCount,
reviewCount: stats.reviewCount
};
})
);
return NextResponse.json({
success: true,
data: {
users: usersWithStats
}
})