diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 2ae7be4..482cf52 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -28,18 +28,18 @@ model User { name String role Role - regNum String @unique - phone String @unique - college String - github String? @unique - imageId String? @unique + regNum String @unique + phone String @unique + college String + github String? @unique + imageId String? @unique + mimeType String? isLeader Boolean @default(false) - team Team? @relation(fields: [teamId], references: [id]) - teamId String? + team Team? @relation(fields: [teamId], references: [id]) + teamId String? evaluations Evaluation[] - } model Team { @@ -47,8 +47,9 @@ model Team { createdAt DateTime @default(now()) updatedAt DateTime @updatedAt - name String @unique - imageId String? @unique + name String @unique + imageId String? @unique + mimeType String? members User[] project Project? @@ -65,6 +66,7 @@ model Project { demoUrl String? @unique reportUrl String? @unique imageId String? @unique + mimeType String? team Team @relation(fields: [teamId], references: [id]) teamId String @unique @@ -77,13 +79,13 @@ model Evaluation { id String @id @default(uuid()) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt - user User @relation(fields: [userId], references: [id]) - userId String - project Project @relation(fields: [projectId], references: [id]) + user User @relation(fields: [userId], references: [id]) + userId String + project Project @relation(fields: [projectId], references: [id]) projectId String score Int @default(0) - + @@unique([userId, projectId]) } diff --git a/src/routes/project/index.ts b/src/routes/project/index.ts index f12708b..3563b89 100644 --- a/src/routes/project/index.ts +++ b/src/routes/project/index.ts @@ -123,7 +123,7 @@ projectRouter.openapi(getProject, async (ctx) => { projectRouter.openapi(updateProject, async (ctx) => { const projectId = ctx.req.param("id"); - const { name, description, repoUrl, demoUrl, reportUrl, imageId } = + const { name, description, repoUrl, demoUrl, reportUrl, imageId, mimeType } = ctx.req.valid("json"); if (!checkRole([Role.SUPER_ADMIN, Role.ADMIN, Role.USER], ctx)) { @@ -156,6 +156,7 @@ projectRouter.openapi(updateProject, async (ctx) => { demoUrl, reportUrl, imageId, + mimeType, }, }); return ctx.json(updatedProject, 200); diff --git a/src/routes/project/routes.ts b/src/routes/project/routes.ts index 16fc6ad..0de3334 100644 --- a/src/routes/project/routes.ts +++ b/src/routes/project/routes.ts @@ -191,6 +191,7 @@ export const updateProject = createRoute({ imageId: z.string().uuid().optional().openapi({ example: "123e4567-e89b-12d3-a456-426614174000", }), + mimeType: z.string().optional().openapi({ example: "png" }), }), }, }, diff --git a/src/routes/teams/index.ts b/src/routes/teams/index.ts index 3602c67..c0e942f 100644 --- a/src/routes/teams/index.ts +++ b/src/routes/teams/index.ts @@ -40,7 +40,7 @@ teamRouter.openapi(getCurrentTeam, async (ctx) => { }); teamRouter.openapi(createTeam, async (ctx) => { - const { name, imageId } = ctx.req.valid("json"); + const { name, imageId, mimeType } = ctx.req.valid("json"); if (!checkRole(["SUPER_ADMIN", "ADMIN", "USER"], ctx)) { return ctx.text("Forbidden", 403); } @@ -55,8 +55,9 @@ teamRouter.openapi(createTeam, async (ctx) => { } const team = await prisma.team.create({ data: { - name: name, - imageId: imageId, + name, + imageId, + mimeType, }, include: { members: true, diff --git a/src/routes/teams/routes.ts b/src/routes/teams/routes.ts index cb1fab8..6a3c142 100644 --- a/src/routes/teams/routes.ts +++ b/src/routes/teams/routes.ts @@ -217,6 +217,7 @@ export const createTeam = createRoute({ imageId: z.string().uuid().openapi({ example: "123e4567-e89b-12d3-a456-426614174000", }), + mimeType: z.string().optional().openapi({ example: "png" }), }), }, }, diff --git a/src/routes/user/index.ts b/src/routes/user/index.ts index a6119d4..ffa30c3 100644 --- a/src/routes/user/index.ts +++ b/src/routes/user/index.ts @@ -86,7 +86,7 @@ userRouter.openapi(updateUser, async (ctx) => { if (!checkRole([Role.ADMIN, Role.SUPER_ADMIN], ctx) && id !== uid) { return ctx.text("Forbidden", 403); } - const { name, regNum, phone, college, github, imageId } = + const { name, regNum, phone, college, github, imageId, mimeType } = ctx.req.valid("json"); try { await prisma.user.update({ @@ -100,6 +100,7 @@ userRouter.openapi(updateUser, async (ctx) => { college, github, imageId, + mimeType, }, }); } catch (e) { diff --git a/src/routes/user/routes.ts b/src/routes/user/routes.ts index 4664e71..7ae1b4e 100644 --- a/src/routes/user/routes.ts +++ b/src/routes/user/routes.ts @@ -222,6 +222,7 @@ export const updateUser = createRoute({ .string() .optional() .openapi({ example: "123e4567-e89b-12d3-a456-426614174000" }), + mimeType: z.string().optional().openapi({ example: "png" }), }), }, }, diff --git a/src/schemas/project.ts b/src/schemas/project.ts index f3614b9..48aaba2 100644 --- a/src/schemas/project.ts +++ b/src/schemas/project.ts @@ -14,6 +14,7 @@ export const ProjectSchema = z.object({ .string() .optional() .openapi({ example: "123e4567-e89b-12d3-a456-426614174000" }), + mimeType: z.string().optional().openapi({ example: "png" }), teamId: z .string() .uuid() diff --git a/src/schemas/team.ts b/src/schemas/team.ts index 4804f1a..a25339b 100644 --- a/src/schemas/team.ts +++ b/src/schemas/team.ts @@ -14,6 +14,7 @@ export const TeamSchema = z.object({ .string() .optional() .openapi({ example: "123e4567-e89b-12d3-a456-426614174000" }), + mimeType: z.string().optional().openapi({ example: "png" }), members: z.array(UserSchema), project: ProjectSchema.optional(), }); diff --git a/src/schemas/user.ts b/src/schemas/user.ts index bc9795f..70042a7 100644 --- a/src/schemas/user.ts +++ b/src/schemas/user.ts @@ -26,6 +26,7 @@ export const UserSchema = z.object({ .string() .optional() .openapi({ example: "123e4567-e89b-12d3-a456-426614174000" }), + mimeType: z.string().optional().openapi({ example: "png" }), isLeader: z.boolean().openapi({ example: true }), teamId: z .string()