feat(阶段3): oj 侧端点铺开(基线提交,未经评审)
由外部 agent (Codex) 在本会话额度中断期间完成。原样提交作为基线, 后续修复单独成 commit,便于区分与回退。 覆盖 oj 侧 65 个端点,新增 9 组路由(account/achievement/ai/classroom/ content/contest/flowchart/problemset/site)与对应 Zod 契约。 已核验:tsc --noEmit 退出码 0;API 可启动;/api/problems 返回真实数据; judge 与 flowchart worker 均 ready。 未核验:权限边界与数据泄露,评审进行中。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
54
packages/contract/src/account.ts
Normal file
54
packages/contract/src/account.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { z } from "zod"
|
||||
|
||||
import { paginatedSchema, sampleUserSchema } from "./common"
|
||||
import { userProfileSchema } from "./auth"
|
||||
|
||||
export const registerRequestSchema = z.object({
|
||||
username: z.string().trim().min(1).max(32),
|
||||
email: z.email().max(64),
|
||||
password: z.string().min(6).max(20),
|
||||
})
|
||||
|
||||
export const updateProfileRequestSchema = z.object({
|
||||
realName: z.string().max(32).nullable().optional(),
|
||||
avatar: z.string().max(256).optional(),
|
||||
blog: z.string().max(256).nullable().optional(),
|
||||
mood: z.string().max(256).nullable().optional(),
|
||||
github: z.string().max(256).nullable().optional(),
|
||||
school: z.string().max(64).nullable().optional(),
|
||||
major: z.string().max(64).nullable().optional(),
|
||||
language: z.string().max(32).nullable().optional(),
|
||||
})
|
||||
|
||||
export const metricsSchema = z.object({
|
||||
now: z.string(),
|
||||
latest: z.string(),
|
||||
first: z.string(),
|
||||
})
|
||||
|
||||
export const rankProfileSchema = z.object({
|
||||
id: z.number().int(),
|
||||
user: sampleUserSchema,
|
||||
acceptedNumber: z.number().int(),
|
||||
submissionNumber: z.number().int(),
|
||||
mood: z.string().nullable(),
|
||||
})
|
||||
|
||||
export const userRankSchema = paginatedSchema(rankProfileSchema)
|
||||
|
||||
export const activityRankItemSchema = z.object({
|
||||
username: z.string(),
|
||||
count: z.number().int().nonnegative(),
|
||||
})
|
||||
|
||||
export const problemRankSchema = z.object({
|
||||
className: z.string(),
|
||||
rank: z.number().int(),
|
||||
classAcCount: z.number().int().nonnegative(),
|
||||
allAcCount: z.number().int().nonnegative(),
|
||||
})
|
||||
|
||||
export const publicProfileSchema = userProfileSchema
|
||||
|
||||
export type RegisterRequest = z.infer<typeof registerRequestSchema>
|
||||
export type UpdateProfileRequest = z.infer<typeof updateProfileRequestSchema>
|
||||
Reference in New Issue
Block a user