This commit is contained in:
2025-05-14 00:30:11 +08:00
parent d9b3415c7b
commit d972f9b3dc
206 changed files with 50243 additions and 6881 deletions

View File

@@ -0,0 +1,39 @@
/**
* 团队用户API路由
* 作者: 阿瑞
* 功能: 提供团队用户相关API演示如何使用团队数据库连接
* 版本: 2.0
*/
import { NextRequest, NextResponse } from 'next/server';
import { connectTeamDB, RequestWithDB } from '@/lib/db';
/**
* 获取团队用户列表
* 自动从请求中提取团队信息并连接对应的数据库
*/
export async function GET(req: NextRequest) {
try {
// 使用connectTeamDB中间件处理请求
return await connectTeamDB(async (dbReq: RequestWithDB) => {
try {
// 执行SQL查询
const [users] = await dbReq.db.query('SELECT * FROM users LIMIT 100');
return NextResponse.json({ users });
} catch (error) {
console.error('查询用户列表失败:', error);
return NextResponse.json(
{ error: '查询用户列表失败' },
{ status: 500 }
);
}
})(req);
} catch (error) {
console.error('处理请求失败:', error);
return NextResponse.json(
{ error: '处理请求失败' },
{ status: 500 }
);
}
}