From 01e68b255b45a2aba0709b856f2f049b84600777 Mon Sep 17 00:00:00 2001 From: chenyuan Date: Thu, 30 Jul 2026 11:39:13 +0800 Subject: [PATCH] docs: specify organization menu switches --- ...07-30-school-organization-menu-switches.md | 64 +++++++++++++++++++ ...chool-organization-menu-switches-design.md | 34 ++++++++++ 2 files changed, 98 insertions(+) create mode 100644 docs/superpowers/plans/2026-07-30-school-organization-menu-switches.md create mode 100644 docs/superpowers/specs/2026-07-30-school-organization-menu-switches-design.md diff --git a/docs/superpowers/plans/2026-07-30-school-organization-menu-switches.md b/docs/superpowers/plans/2026-07-30-school-organization-menu-switches.md new file mode 100644 index 0000000..0c226b8 --- /dev/null +++ b/docs/superpowers/plans/2026-07-30-school-organization-menu-switches.md @@ -0,0 +1,64 @@ +# 学校组织管理菜单开关 Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Add per-school faculty, major, and administrative-class management switches with enforced dependencies. + +**Architecture:** Persist three booleans in the school product configuration and normalize them in the service layer. Return them to the frontend, filter teacher navigation from the booleans, and make the platform editor update both presets and individual switches. + +**Tech Stack:** Spring Boot, MyBatis, MySQL, Vue 3, Element Plus, Node static checks, JUnit 5/Mockito. + +## Global Constraints + +- Existing organization data is retained when a switch is disabled. +- Faculty off forces major and administrative-class off; major off forces administrative-class off. +- Administrative-class writes remain blocked when its switch is off. + +--- + +### Task 1: Persist and normalize organization switches + +**Files:** +- Create: `docs/sql/2026-07-30-school-organization-menu-switches.sql` +- Modify: `src/main/java/com/sztzjy/linkCommerce/entity/SchoolProductConfig.java` +- Modify: `src/main/java/com/sztzjy/linkCommerce/service/SchoolProductConfigService.java` +- Modify: `src/main/java/com/sztzjy/linkCommerce/service/impl/SchoolProductConfigServiceImpl.java` +- Test: `src/test/java/com/sztzjy/linkCommerce/service/impl/SchoolProductConfigServiceImplTest.java` + +- [ ] Write JUnit tests for default switches and cascade normalization. +- [ ] Run `mvn -q -DforkCount=0 -Dtest=SchoolProductConfigServiceImplTest test` and confirm the new assertions fail. +- [ ] Add SQL columns, Java accessors, default values, normalization, and per-capability guards. +- [ ] Re-run the focused test and confirm success. + +### Task 2: Enforce backend capability guards + +**Files:** +- Modify: `src/main/java/com/sztzjy/linkCommerce/controller/stu/UserController.java` +- Test: `src/test/java/com/sztzjy/linkCommerce/controller/stu/UserControllerTeacherAdminTest.java` + +- [ ] Add failing tests that disable faculty/major/admin-class management and assert that the corresponding write API does not write. +- [ ] Run the focused controller test and confirm failure. +- [ ] Replace the single organization-mode permission check with capability-specific checks while preserving platform-admin access. +- [ ] Re-run the focused test and confirm success. + +### Task 3: Configure and render switches in the frontend + +**Files:** +- Modify: `src/views/platformAdmin/school/index.vue` +- Modify: `src/layout/components/Sidebar/index.vue` +- Modify: `src/views/teacherEnd/class/index.vue` +- Modify: `tests/school-product-config.static.test.cjs` + +- [ ] Add failing static assertions for three Element Plus switches and capability-based route filtering. +- [ ] Run `node tests/school-product-config.static.test.cjs` and confirm failure. +- [ ] Bind switches with dependency-aware handlers, filter menus by their capabilities, and derive the administrative-class UI from its switch. +- [ ] Re-run all `tests/*.test.cjs` and `npm run build:prod`. + +### Task 4: Apply and verify the migration + +**Files:** +- Run: `docs/sql/2026-07-30-school-organization-menu-switches.sql` + +- [ ] Apply the migration to the configured development database. +- [ ] Query Guangdong Science and Technology Vocational College’s product configuration and verify all three switches are disabled. +- [ ] Restart backend and frontend, confirm the local health endpoints return HTTP 200. diff --git a/docs/superpowers/specs/2026-07-30-school-organization-menu-switches-design.md b/docs/superpowers/specs/2026-07-30-school-organization-menu-switches-design.md new file mode 100644 index 0000000..4d3c536 --- /dev/null +++ b/docs/superpowers/specs/2026-07-30-school-organization-menu-switches-design.md @@ -0,0 +1,34 @@ +# 学校组织管理菜单开关设计 + +## 目标 + +让平台超管能为每所学校独立启用院系管理、专业管理和行政班管理,并让教师端菜单、班级页面与后端写接口一致地遵守配置。 + +## 配置模型 + +`school_product_config` 增加三个布尔字段:`faculty_management_enabled`、`major_management_enabled`、`admin_class_management_enabled`。 + +组织模式仍是快捷预设:标准学校将三个开关置为开启并由学校维护学生名单;教师教学班维护名单将三个开关置为关闭并由教师维护名单。手工调整任一开关后,组织模式记录为 `CUSTOM`;非行政班模式仍由教师维护名单。 + +## 依赖规则 + +- 关闭院系管理时,系统自动关闭专业管理和行政班管理。 +- 关闭专业管理时,系统自动关闭行政班管理。 +- 行政班管理只能在院系管理和专业管理均开启时启用。 +- 已有院系、专业、行政班及其成员数据不会被删除;关闭开关只会隐藏菜单并拒绝新的相关写操作。 + +## 界面行为 + +平台学校编辑窗保留组织模式下拉框作为预设,并新增三个开关。专业和行政班开关在依赖未满足时禁用并显示原因。切换预设会同步更新开关;手动切换有效开关后显示“自定义配置”。 + +教师端侧栏按三个开关分别过滤院系、专业菜单;班级管理菜单始终保留,但行政班标签、筛选和创建入口仅在行政班开关开启时显示。教师教学班名单模式继续隐藏教师管理菜单。 + +## 后端约束 + +API 返回完整配置。院系、专业和行政班写操作分别检查对应开关;直接调用接口不能绕过前端。平台超管可修改配置。配置更新会规范化依赖关系并保留既有数据。 + +## 验收 + +- 教师名单学校三个开关均关闭,教师端不显示院系/专业菜单,班级页无行政班。 +- 打开院系和专业、关闭行政班后,院系与专业菜单可见,班级页仅显示教学班。 +- 关闭院系会自动关闭其余两个开关;现存组织数据可在重新打开后继续访问。