Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,28 @@ 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 {
id String @id @default(uuid())
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?
Expand All @@ -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
Expand All @@ -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])
}

Expand Down
3 changes: 2 additions & 1 deletion src/routes/project/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -156,6 +156,7 @@ projectRouter.openapi(updateProject, async (ctx) => {
demoUrl,
reportUrl,
imageId,
mimeType,
},
});
return ctx.json(updatedProject, 200);
Expand Down
1 change: 1 addition & 0 deletions src/routes/project/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" }),
}),
},
},
Expand Down
7 changes: 4 additions & 3 deletions src/routes/teams/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/routes/teams/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" }),
}),
},
},
Expand Down
3 changes: 2 additions & 1 deletion src/routes/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -100,6 +100,7 @@ userRouter.openapi(updateUser, async (ctx) => {
college,
github,
imageId,
mimeType,
},
});
} catch (e) {
Expand Down
1 change: 1 addition & 0 deletions src/routes/user/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export const updateUser = createRoute({
.string()
.optional()
.openapi({ example: "123e4567-e89b-12d3-a456-426614174000" }),
mimeType: z.string().optional().openapi({ example: "png" }),
}),
},
},
Expand Down
1 change: 1 addition & 0 deletions src/schemas/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions src/schemas/team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
});
1 change: 1 addition & 0 deletions src/schemas/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down