Skip to content
This repository has been archived by the owner on Mar 10, 2024. It is now read-only.

Commit

Permalink
feat(class): add class to group
Browse files Browse the repository at this point in the history
  • Loading branch information
ZTL-UwU committed Dec 14, 2023
1 parent 27a3ed5 commit dce3a05
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/controllers/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ export class GroupController {
leader: string
members: string[]
papers?: string[]
classId: string
archived?: boolean
}) {
const { leader, members, papers, archived } = newGroup;
const { leader, members, papers, classId, archived } = newGroup;
const group = {
leader,
classId,
archived: archived ?? false,
};

Expand Down
2 changes: 2 additions & 0 deletions src/db/schema/group.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core';
import { nanoid } from 'nanoid';
import { users } from './user';
import { classes } from './class';

export const groups = sqliteTable('groups', {
id: text('id', { mode: 'text' }).primaryKey().$defaultFn(() => nanoid(12)),
leader: text('leader', { mode: 'text' }).notNull().references(() => users.id),
archived: integer('archived', { mode: 'boolean' }).notNull().default(false),
classId: text('class_id', { mode: 'text' }).notNull().references(() => classes.id),
createdAt: integer('created_at', { mode: 'timestamp' }).notNull().$defaultFn(() => new Date()),
});
1 change: 1 addition & 0 deletions src/routers/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const groupRouter = router({
)
.min(1, '请填写组员ID')
.max(64, '组员最多64人'),
classId: z.string().min(1, '班级ID不存在'),
papers: z
.array(z.string())
.max(8, '小组最多8篇论文')
Expand Down
1 change: 1 addition & 0 deletions src/serializer/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export function groupSerializer(basicGroup: TRawGroup, members: string[], papers
leader: basicGroup.leader,
members,
papers,
classId: basicGroup.classId,
createdAt: basicGroup.createdAt,
};
}

0 comments on commit dce3a05

Please sign in to comment.