[web] GET for team data
This commit is contained in:
parent
d43ffb680a
commit
c901e3ac42
@ -8,10 +8,10 @@ datasource db {
|
||||
}
|
||||
|
||||
model User {
|
||||
id Int @id @default(autoincrement())
|
||||
username String @unique
|
||||
password String
|
||||
Submission Session[]
|
||||
id Int @id @default(autoincrement())
|
||||
username String @unique
|
||||
password String
|
||||
sessions Session[]
|
||||
}
|
||||
|
||||
model Session {
|
||||
@ -47,7 +47,7 @@ model Problem {
|
||||
sampleOutput String
|
||||
realInput String
|
||||
realOutput String
|
||||
Submission Submission[]
|
||||
submissions Submission[]
|
||||
contests Contest[] @relation("ProblemContestRelation")
|
||||
}
|
||||
|
||||
@ -66,11 +66,14 @@ model ActiveTeam {
|
||||
team Team @relation(fields: [teamId], references: [id])
|
||||
sessionToken String? @unique
|
||||
sessionCreatedAt DateTime?
|
||||
contestId Int
|
||||
contest Contest @relation(fields: [contestId], references: [id])
|
||||
}
|
||||
|
||||
model Contest {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
teams Team[] @relation("TeamContestRelation")
|
||||
problems Problem[] @relation("ProblemContestRelation")
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
teams Team[] @relation("TeamContestRelation")
|
||||
problems Problem[] @relation("ProblemContestRelation")
|
||||
activeTeams ActiveTeam[]
|
||||
}
|
||||
|
20
web/src/routes/api/team/[session]/+server.ts
Normal file
20
web/src/routes/api/team/[session]/+server.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import type { RequestHandler } from './$types';
|
||||
import { error, json } from '@sveltejs/kit';
|
||||
import { db } from '$lib/server/prisma';
|
||||
|
||||
export const GET = (async ({ params }) => {
|
||||
const session = params.session;
|
||||
const activeTeam = await db.activeTeam.findUnique({
|
||||
where: { sessionToken: session }
|
||||
});
|
||||
if (!activeTeam) {
|
||||
return json({ success: false });
|
||||
}
|
||||
return json({
|
||||
success: true,
|
||||
data: {
|
||||
teamId: activeTeam.teamId,
|
||||
contestId: activeTeam.contestId
|
||||
}
|
||||
});
|
||||
}) satisfies RequestHandler;
|
Loading…
Reference in New Issue
Block a user