refactor(school,classes): 完成 school/grade/class 审计全量改进项
P0-1/P0-2: 删除 grade-management 死模块,年级 CRUD 统一由 school 模块负责 P0-3: classes/actions.ts 从 974 行拆分为 6 个职责文件 + barrel re-export P0-5: 13 个页面 i18n 全量接入(grades/departments/academic-year/classes/insights) P1-1: 角色硬编码改为 hasAdminScope/hasTeacherScope/hasStudentScope 基于 dataScope.type P1-3: 新增 SchoolErrorBoundary + SchoolListSkeleton/SchoolCardSkeleton,4 个页面包裹 Error Boundary P1-4: classes/types.ts 跨领域类型添加归属决策注释 P1-5: schools-view.tsx 拆分为组合模式(SchoolFormDialog + SchoolDeleteDialog + SchoolListToolbar) P1-6: 新增 getSchoolsForUser/getGradesForUser 权限感知查询函数 P2-1: 抽取 useSchoolData hook,对话框状态管理与 UI 分离 同步更新架构图文档 004/005
This commit is contained in:
@@ -1,28 +1,36 @@
|
||||
import type { Metadata } from "next"
|
||||
import type { Metadata } from "next"
|
||||
import type { JSX } from "react"
|
||||
|
||||
import { getTranslations } from "next-intl/server"
|
||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||
import { Permissions } from "@/shared/types/permissions"
|
||||
import { AcademicYearClient } from "@/modules/school/components/academic-year-view"
|
||||
import { SchoolErrorBoundary } from "@/modules/school/components/school-error-boundary"
|
||||
import { getAcademicYears } from "@/modules/school/data-access"
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "学年管理 - Next_Edu",
|
||||
description: "管理学年区间与当前激活学年",
|
||||
}
|
||||
|
||||
export const dynamic = "force-dynamic"
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
const t = await getTranslations("school")
|
||||
return {
|
||||
title: `${t("academicYear.title")} - Next_Edu`,
|
||||
description: t("academicYear.description"),
|
||||
}
|
||||
}
|
||||
|
||||
export default async function AdminAcademicYearPage(): Promise<JSX.Element> {
|
||||
await requirePermission(Permissions.SCHOOL_MANAGE)
|
||||
const t = await getTranslations("school")
|
||||
const years = await getAcademicYears()
|
||||
return (
|
||||
<div className="flex h-full flex-col space-y-8 p-8">
|
||||
<div className="space-y-1">
|
||||
<h2 className="text-2xl font-bold tracking-tight">学年管理</h2>
|
||||
<p className="text-muted-foreground">管理学年区间与当前激活学年。</p>
|
||||
<h2 className="text-2xl font-bold tracking-tight">{t("academicYear.title")}</h2>
|
||||
<p className="text-muted-foreground">{t("academicYear.description")}</p>
|
||||
</div>
|
||||
<AcademicYearClient years={years} />
|
||||
<SchoolErrorBoundary>
|
||||
<AcademicYearClient years={years} />
|
||||
</SchoolErrorBoundary>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,21 +1,26 @@
|
||||
import type { Metadata } from "next"
|
||||
import type { JSX } from "react"
|
||||
|
||||
import { getTranslations } from "next-intl/server"
|
||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||
import { Permissions } from "@/shared/types/permissions"
|
||||
import { getAdminClasses, getTeacherOptions } from "@/modules/classes/data-access"
|
||||
import { getGrades, getSchools } from "@/modules/school/data-access"
|
||||
import { AdminClassesClient } from "@/modules/classes/components/admin-classes-view"
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "班级管理 - Next_Edu",
|
||||
description: "管理班级并分配教师",
|
||||
}
|
||||
|
||||
export const dynamic = "force-dynamic"
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
const t = await getTranslations("school")
|
||||
return {
|
||||
title: `${t("classManagement.title")} - Next_Edu`,
|
||||
description: t("classManagement.description"),
|
||||
}
|
||||
}
|
||||
|
||||
export default async function AdminSchoolClassesPage(): Promise<JSX.Element> {
|
||||
await requirePermission(Permissions.SCHOOL_MANAGE)
|
||||
const t = await getTranslations("school")
|
||||
const [classes, teachers, schools, grades] = await Promise.all([
|
||||
getAdminClasses(),
|
||||
getTeacherOptions(),
|
||||
@@ -26,8 +31,8 @@ export default async function AdminSchoolClassesPage(): Promise<JSX.Element> {
|
||||
return (
|
||||
<div className="flex h-full flex-col space-y-8 p-8">
|
||||
<div className="space-y-1">
|
||||
<h2 className="text-2xl font-bold tracking-tight">班级管理</h2>
|
||||
<p className="text-muted-foreground">管理班级并分配教师。</p>
|
||||
<h2 className="text-2xl font-bold tracking-tight">{t("classManagement.title")}</h2>
|
||||
<p className="text-muted-foreground">{t("classManagement.description")}</p>
|
||||
</div>
|
||||
<AdminClassesClient classes={classes} teachers={teachers} schools={schools} grades={grades} />
|
||||
</div>
|
||||
|
||||
@@ -1,28 +1,36 @@
|
||||
import type { Metadata } from "next"
|
||||
import type { Metadata } from "next"
|
||||
import type { JSX } from "react"
|
||||
|
||||
import { getTranslations } from "next-intl/server"
|
||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||
import { Permissions } from "@/shared/types/permissions"
|
||||
import { DepartmentsClient } from "@/modules/school/components/departments-view"
|
||||
import { SchoolErrorBoundary } from "@/modules/school/components/school-error-boundary"
|
||||
import { getDepartments } from "@/modules/school/data-access"
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "部门管理 - Next_Edu",
|
||||
description: "管理学校部门",
|
||||
}
|
||||
|
||||
export const dynamic = "force-dynamic"
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
const t = await getTranslations("school")
|
||||
return {
|
||||
title: `${t("departments.title")} - Next_Edu`,
|
||||
description: t("departments.description"),
|
||||
}
|
||||
}
|
||||
|
||||
export default async function AdminDepartmentsPage(): Promise<JSX.Element> {
|
||||
await requirePermission(Permissions.SCHOOL_MANAGE)
|
||||
const t = await getTranslations("school")
|
||||
const departments = await getDepartments()
|
||||
return (
|
||||
<div className="flex h-full flex-col space-y-8 p-8">
|
||||
<div className="space-y-1">
|
||||
<h2 className="text-2xl font-bold tracking-tight">部门管理</h2>
|
||||
<p className="text-muted-foreground">管理学校部门。</p>
|
||||
<h2 className="text-2xl font-bold tracking-tight">{t("departments.title")}</h2>
|
||||
<p className="text-muted-foreground">{t("departments.description")}</p>
|
||||
</div>
|
||||
<DepartmentsClient departments={departments} />
|
||||
<SchoolErrorBoundary>
|
||||
<DepartmentsClient departments={departments} />
|
||||
</SchoolErrorBoundary>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,29 +1,37 @@
|
||||
import type { Metadata } from "next"
|
||||
import type { Metadata } from "next"
|
||||
import type { JSX } from "react"
|
||||
|
||||
import { getTranslations } from "next-intl/server"
|
||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||
import { Permissions } from "@/shared/types/permissions"
|
||||
import { GradesClient } from "@/modules/school/components/grades-view"
|
||||
import { SchoolErrorBoundary } from "@/modules/school/components/school-error-boundary"
|
||||
import { getGrades, getSchools, getStaffOptions } from "@/modules/school/data-access"
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "年级管理 - Next_Edu",
|
||||
description: "管理年级并分配年级组长",
|
||||
}
|
||||
|
||||
export const dynamic = "force-dynamic"
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
const t = await getTranslations("school")
|
||||
return {
|
||||
title: `${t("grades.title")} - Next_Edu`,
|
||||
description: t("grades.description"),
|
||||
}
|
||||
}
|
||||
|
||||
export default async function AdminGradesPage(): Promise<JSX.Element> {
|
||||
await requirePermission(Permissions.SCHOOL_MANAGE)
|
||||
const t = await getTranslations("school")
|
||||
const [grades, schools, staff] = await Promise.all([getGrades(), getSchools(), getStaffOptions()])
|
||||
|
||||
return (
|
||||
<div className="flex h-full flex-col space-y-8 p-8">
|
||||
<div className="space-y-1">
|
||||
<h2 className="text-2xl font-bold tracking-tight">年级管理</h2>
|
||||
<p className="text-muted-foreground">管理年级并分配年级组长。</p>
|
||||
<h2 className="text-2xl font-bold tracking-tight">{t("grades.title")}</h2>
|
||||
<p className="text-muted-foreground">{t("grades.description")}</p>
|
||||
</div>
|
||||
<GradesClient grades={grades} schools={schools} staff={staff} />
|
||||
<SchoolErrorBoundary>
|
||||
<GradesClient grades={grades} schools={schools} staff={staff} />
|
||||
</SchoolErrorBoundary>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { getTranslations } from "next-intl/server"
|
||||
import { requirePermission } from "@/shared/lib/auth-guard"
|
||||
import { Permissions } from "@/shared/types/permissions"
|
||||
import { SchoolsClient } from "@/modules/school/components/schools-view"
|
||||
import { SchoolErrorBoundary } from "@/modules/school/components/school-error-boundary"
|
||||
import { getSchools } from "@/modules/school/data-access"
|
||||
|
||||
export const dynamic = "force-dynamic"
|
||||
@@ -27,7 +28,9 @@ export default async function AdminSchoolsPage(): Promise<JSX.Element> {
|
||||
<h2 className="text-2xl font-bold tracking-tight">{t("schools.title")}</h2>
|
||||
<p className="text-muted-foreground">{t("schools.description")}</p>
|
||||
</div>
|
||||
<SchoolsClient schools={schools} />
|
||||
<SchoolErrorBoundary>
|
||||
<SchoolsClient schools={schools} />
|
||||
</SchoolErrorBoundary>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user