@@ -112,4 +112,13 @@ export class TeamController {
return reply.code(500).send({ message: '获取统计数据失败', error })
}
+
+ async getTeams(request: FastifyRequest, reply: FastifyReply) {
+ try {
+ const teams = await this.teamService.getTeams()
+ return reply.send(teams)
+ } catch (error) {
+ return reply.code(500).send({ message: '获取团队失败', error })
+ }
@@ -62,4 +62,11 @@ export default async function teamRoutes(fastify: FastifyInstance) {
{ onRequest: [authenticate, hasRole(UserRole.ADMIN)] },
teamController.getStatistics.bind(teamController)
)
+ // 获取团队
+ fastify.get(
+ '/all',
+ { onRequest: [authenticate, hasRole(UserRole.ADMIN)] },
+ teamController.getTeams.bind(teamController)
+ )
@@ -133,4 +133,10 @@ export class TeamService {
return statistics
+ async getTeams(): Promise<Array<{ id: number; name: string; userId: number }>> {
+ return await this.teamRepository.find({
+ select: ['id', 'name', 'userId']
+ })