feat: 完成 P1 全部功能 + 修复 proxy 导出 + 切换 MySQL 端口至 14013
## P1 功能(20 项) - 站内消息系统、家长仪表盘、学生考勤管理 - Excel 导入导出、用户批量导入、成绩导出 - 排课规则+自动排课+课表调整 - 成绩趋势+对比分析、密码安全策略、速率限制 - 数据变更日志、文件预览+存储策略、全文检索 - 依赖审计集成 CI、数据库定时备份、E2E 测试完善 - 通知偏好管理 ## 基础设施修复 - src/proxy.ts: 将 middleware 导出重命名为 proxy(Next.js 16 要求) - .env: MySQL 端口从 13002 切换至 14013 - scripts/create-db.ts: 新增数据库初始化脚本 ## 架构文档同步 - 004_architecture_impact_map.md 和 005_architecture_data.json 完整记录所有新增表、模块、路由、权限、依赖关系
This commit is contained in:
101
src/app/(dashboard)/teacher/grades/page.tsx
Normal file
101
src/app/(dashboard)/teacher/grades/page.tsx
Normal file
@@ -0,0 +1,101 @@
|
||||
import Link from "next/link"
|
||||
import { PlusCircle, BarChart3, ClipboardList } from "lucide-react"
|
||||
import { Button } from "@/shared/components/ui/button"
|
||||
import { EmptyState } from "@/shared/components/ui/empty-state"
|
||||
import { db } from "@/shared/db"
|
||||
import { subjects } from "@/shared/db/schema"
|
||||
import { asc } from "drizzle-orm"
|
||||
import { getAuthContext } from "@/shared/lib/auth-guard"
|
||||
import { getTeacherClasses } from "@/modules/classes/data-access"
|
||||
import { getGradeRecords } from "@/modules/grades/data-access"
|
||||
import { GradeQueryFilters } from "@/modules/grades/components/grade-query-filters"
|
||||
import { GradeRecordList } from "@/modules/grades/components/grade-record-list"
|
||||
import { ExportButton } from "@/modules/grades/components/export-button"
|
||||
|
||||
export const dynamic = "force-dynamic"
|
||||
|
||||
type SearchParams = { [key: string]: string | string[] | undefined }
|
||||
|
||||
const getParam = (params: SearchParams, key: string) => {
|
||||
const v = params[key]
|
||||
return Array.isArray(v) ? v[0] : v
|
||||
}
|
||||
|
||||
export default async function TeacherGradesPage({ searchParams }: { searchParams: Promise<SearchParams> }) {
|
||||
const sp = await searchParams
|
||||
const ctx = await getAuthContext()
|
||||
|
||||
const classId = getParam(sp, "classId")
|
||||
const subjectId = getParam(sp, "subjectId")
|
||||
const type = getParam(sp, "type")
|
||||
const semester = getParam(sp, "semester")
|
||||
|
||||
const [classes, allSubjects] = await Promise.all([
|
||||
getTeacherClasses(),
|
||||
db.query.subjects.findMany({ orderBy: [asc(subjects.order), asc(subjects.name)] }),
|
||||
])
|
||||
|
||||
const records = await getGradeRecords({
|
||||
scope: ctx.dataScope,
|
||||
currentUserId: ctx.userId,
|
||||
classId: classId && classId !== "all" ? classId : undefined,
|
||||
subjectId: subjectId && subjectId !== "all" ? subjectId : undefined,
|
||||
type: type && type !== "all" ? (type as "exam" | "quiz" | "homework" | "other") : undefined,
|
||||
semester: semester && semester !== "all" ? (semester as "1" | "2") : undefined,
|
||||
})
|
||||
|
||||
const classOptions = classes.map((c) => ({ id: c.id, name: c.name }))
|
||||
const subjectOptions = allSubjects.map((s) => ({ id: s.id, name: s.name }))
|
||||
|
||||
return (
|
||||
<div className="h-full flex-1 flex-col space-y-8 p-8 md:flex">
|
||||
<div className="flex items-center justify-between space-y-2">
|
||||
<div>
|
||||
<h2 className="text-2xl font-bold tracking-tight">Grades</h2>
|
||||
<p className="text-muted-foreground">Manage student grade records.</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button asChild variant="outline">
|
||||
<Link href="/teacher/grades/stats">
|
||||
<BarChart3 className="mr-2 h-4 w-4" />
|
||||
Statistics
|
||||
</Link>
|
||||
</Button>
|
||||
<Button asChild variant="outline">
|
||||
<Link href="/teacher/grades/entry">
|
||||
<ClipboardList className="mr-2 h-4 w-4" />
|
||||
Batch Entry
|
||||
</Link>
|
||||
</Button>
|
||||
<ExportButton
|
||||
classId={classId && classId !== "all" ? classId : ""}
|
||||
subjectId={subjectId && subjectId !== "all" ? subjectId : undefined}
|
||||
variant="outline"
|
||||
/>
|
||||
<Button asChild>
|
||||
<Link href="/teacher/grades/entry">
|
||||
<PlusCircle className="mr-2 h-4 w-4" />
|
||||
Record Grades
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<GradeQueryFilters classes={classOptions} subjects={subjectOptions} />
|
||||
|
||||
{records.length === 0 && !classId && !subjectId ? (
|
||||
<EmptyState
|
||||
title="No grade records"
|
||||
description="Start by recording grades for your classes."
|
||||
icon={ClipboardList}
|
||||
action={{
|
||||
label: "Record Grades",
|
||||
href: "/teacher/grades/entry",
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<GradeRecordList records={records} />
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user