Commit Graph

71 Commits

Author SHA1 Message Date
charilezhou
1b84aff71a feat: DataTable 错误状态支持和 403 页面退出登录
- DataTable 组件添加 error 和 onRetry 属性,支持错误状态渲染
- 新增 Alert 组件(shadcn/ui 风格)
- 403 页面添加重新登录按钮,方便权限更新后刷新缓存
- auth.ts 退出登录时同时清除权限缓存
- CrudService restore 方法修复:显式指定 deletedAt 条件绕过软删除过滤

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 20:28:15 +08:00
charilezhou
c37ee29071 feat(plop): 生成的模块自动应用权限控制
后端 Controller:
- 添加 PermissionGuard 守卫
- 每个接口添加 @RequirePermission 装饰器
- 权限格式: {module}:create/read/update/delete

前端 Table:
- 使用 PermissionGuard 组件进行权限控制
- 新建按钮根据 create 权限显示/隐藏
- 编辑/删除/恢复按钮根据对应权限显示/隐藏
- 整个操作菜单根据 update/delete 权限显示/隐藏

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 19:57:28 +08:00
charilezhou
ed901250bd feat(plop): 添加菜单/权限种子脚本生成功能
- 新增种子脚本模板 module-seed.hbs
- 生成器新增「菜单/权限种子脚本」选项
- 添加菜单图标和排序的提示问题
- 生成的脚本包含 4 个 CRUD 权限和 1 个菜单项
- 支持独立运行或被主 seed.ts 导入调用
- 修复 ESM 模块导入路径(添加 .ts 扩展名)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 19:42:11 +08:00
charilezhou
331142d87a fix(plop): 修复 edit-dialog 模板 Handlebars 解析错误
使用 {{"{"}} 输出 JSX 花括号字面量,避免与三重大括号语法冲突

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 17:38:32 +08:00
charilezhou
3119460f13 feat(plop): 优化生成器支持 Prisma 关联关系
- 支持一对多/多对一关系定义并生成到 Prisma schema
- 简化流程:查询关联配置根据关系自动预填
- 修复 Handlebars 模板 HTML 转义导致的乱码问题
- 修复 controller 模板缺少 Prisma 导入的问题
- 新增页面模板 (page.hbs) 生成前端页面
- 添加 FindAllParams/PaginationQueryDto 索引签名修复类型兼容

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 17:30:18 +08:00
charilezhou
e5b3285519 fix(plop): 修复生成文件路径和 app.module.ts 正则
- 添加 --dest . 参数确保文件生成到项目根目录
- 修复 app.module.ts 导入语句和 imports 数组的正则匹配

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 16:19:54 +08:00
charilezhou
8c904c419a feat(plop): 关联配置支持从 Schema 选择模型和字段
- 新增 schema-parser.ts 解析 Prisma schema 文件
- 关联关系先选择模型,再编辑预填的配置
- 多对多关系自动推断中间表配置
- 可用字段作为注释显示,方便用户参考

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 16:14:48 +08:00
charilezhou
31598d79ae fix(plop): 修复模板文件路径
模板路径应相对于 plopfile 所在目录,移除多余的 plop/ 前缀

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 16:11:46 +08:00
charilezhou
f492e7c172 feat(plop): 模板支持关联关系和多对多生成
- service.hbs: 支持三种服务类型,生成 @CrudOptions 关联配置和 DTO 转换方法
- dto.hbs: 生成 BriefDto、DetailResponseDto、AssignDto
- controller.hbs: 支持关联查询端点和多对多分配端点
- types.hbs: 添加关联类型接口定义

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 16:03:12 +08:00
charilezhou
f126e03cf1 feat(plop): 代码生成器支持 CrudService 分层架构
- 新增 relation-parser.ts 关联关系 DSL 解析器
- 生成器支持三种服务类型选择:CrudService/RelationCrudService/ManyToManyCrudService
- 添加关联关系、多对多关系、统计关系配置问题
- 修复 helpers 导入路径扩展名问题

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 16:02:48 +08:00
charilezhou
3ae13fd512 feat: 添加教学管理模块(教师、学生、班级)
后端:
- 新增 Teacher、Student、Class 模块及 CRUD 接口
- 新增 ClassTeacher 多对多关系支持任课教师管理
- Student 支持班级关联查询
- Class 支持班主任一对一和任课教师多对多关系
- 更新 Prisma schema 和种子数据

前端:
- 新增教师、学生、班级管理页面
- 新增对应的 hooks 和 services
- 更新路由常量和 hooks 导出

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 15:39:10 +08:00
charilezhou
0156e17131 refactor(api): CrudService 分层架构重构
- 新增 BaseCrudService 抽象基类,提取通用辅助方法
- 新增 RelationCrudService 支持关联查询和一对一关系管理
- 新增 ManyToManyCrudService 支持多对多关系管理
- 重构 CrudService 继承 BaseCrudService
- 迁移 UserService 到 ManyToManyCrudService(用户-角色多对多)
- 迁移 RoleService 到 ManyToManyCrudService(角色-权限、角色-菜单双多对多)
- 更新 CrudService 使用文档

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 15:37:27 +08:00
charilezhou
c759b50efd chore(api): 更新种子数据菜单结构
- 添加文件管理权限 (file:read, file:delete)
- 调整菜单层级:用户管理、文件管理等移至系统管理下
- 优化种子数据初始化逻辑

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 13:48:50 +08:00
charilezhou
c5656813ae feat(web): 添加文件管理页面
- 新增 /files 文件管理页面
- 添加 FilesTable 组件支持分页、筛选、删除
- 添加 FileStats 组件展示统计信息
- 扩展 file.service.ts 添加列表和统计接口
- 新增 useFiles、useFileStats、useDeleteFile hooks

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 13:48:18 +08:00
charilezhou
0acea22262 feat(api): 文件管理模块添加列表和统计接口
- 添加 GET /files 分页查询接口
- 添加 GET /files/stats 统计信息接口
- FileService 使用 @CrudOptions 配置过滤字段
- 新增 FileQueryDto、PaginatedFileResponseDto、FileStatsResponseDto

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 13:47:56 +08:00
charilezhou
76f835a2ad feat(api): StorageService 支持 MINIO_PUBLIC_URL 配置
- 添加 publicUrl 配置支持外部访问地址
- getPresignedUrl 方法自动替换内部地址为公开地址
- 移除已迁移到 file 模块的路径前缀常量

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 13:47:36 +08:00
charilezhou
2914d1e090 feat(api): CrudService 添加配置式过滤和 count 方法
- 新增 FilterOperator、FilterFieldConfig、FilterableField 类型
- 添加 filterableFields 配置项支持声明式过滤字段
- 实现 buildFilterWhere 方法自动构建 where 条件
- 添加 count 方法支持条件计数
- findAll/count 方法支持泛型参数兼容 DTO 类型

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 13:47:09 +08:00
charilezhou
5fab73e514 refactor(api): 优化文件上传验证分层
Controller 层(Multer 配置):
- 添加全局文件大小限制(10MB)和类型过滤
- 在文件写入内存前进行基本验证,防止恶意大文件

Service 层(业务规则):
- 新增 FILE_PURPOSE_CONFIG 配置映射
- 按场景(头像/附件)进行细化验证
- 提取 validateFile 方法,职责清晰

常量重组织:
- storage.constants.ts 只保留全局限制和存储路径
- file.constants.ts 添加场景特定限制配置

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 13:07:20 +08:00
charilezhou
c935d0b6aa docs: 更新 CLAUDE.md 项目文档
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 12:37:18 +08:00
charilezhou
9c65d39dd2 feat(web): 更新 UI 组件和个人资料页
- 更新个人资料页支持头像上传
- 优化 Header、Sidebar、UserNav 组件
- 更新表单验证规则
- 调整常量配置

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 12:37:08 +08:00
charilezhou
4e1be2b494 feat(api): 更新用户模块支持头像功能
- 更新 AuthDto 调整验证规则
- 更新 UserDto 添加头像相关字段
- 更新 UserController 支持更新用户头像

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 12:36:39 +08:00
charilezhou
d9673e2ba3 chore: 更新配置和依赖
- 添加 MinIO 和邮件服务相关环境变量
- 添加 @nestjs-modules/mailer, minio, multer 等依赖
- 更新 app.module.ts 注册新模块
- docker-compose 添加 MinIO 服务配置

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 12:36:20 +08:00
charilezhou
1627d98be5 feat: 更新数据模型和共享类型
- 更新 Prisma schema 添加 File 模型和相关字段
- 更新共享类型定义,添加文件和密码重置相关类型
- 添加 CaptchaScene.RESET_PASSWORD 场景

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 12:36:04 +08:00
charilezhou
e008179c03 feat: 添加忘记密码功能
后端:
- 新增 MailService 集成 Nodemailer 发送邮件
- 新增 EmailCodeService 管理邮箱验证码
- 新增 sendResetPasswordEmail 和 resetPassword 接口
- 支持验证码过期和次数限制

前端:
- 新增忘记密码页面 (forgot-password)
- 新增 ForgotPasswordForm 组件,支持邮箱验证和密码重置
- 更新 auth.service.ts 添加相关 API 调用

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 12:35:24 +08:00
charilezhou
58529f0321 feat: 添加文件上传功能
后端:
- 新增 StorageService 集成 MinIO 对象存储
- 新增 FileService 和 FileController 处理文件上传
- 支持头像上传场景,含文件类型和大小验证
- 支持生成临时访问 URL

前端:
- 新增 AvatarUpload 组件,支持拖拽和点击上传
- 新增 useUploadAvatar 和 useFileUrl hooks
- 新增 file.service.ts 封装文件 API

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 12:34:58 +08:00
charilezhou
b305e49e9b fix(web): 修复 lint 错误
- 调整 permissions/page.tsx 的 import 顺序
- 重命名未使用的 collectAllMenuIds 为 _collectAllMenuIds

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 12:34:32 +08:00
charilezhou
d747f98d08 refactor(api): 优化 PrismaService 类型设计,修复依赖注入问题
- 重构 PrismaService 使其类型包含所有模型访问器
- 使用 PrismaServiceImpl 内部类 + 类型断言导出 PrismaService
- 所有 Service 现在可以直接使用 PrismaService 类型注入
- 修复 NestJS 依赖注入无法识别类型别名的问题
- 统一各 Service 的 PrismaService 导入方式

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 12:34:11 +08:00
charilezhou
57456be013 refactor(api): 移除手动 softDelete 配置,改为基于 schema 自动检测
- 从 CrudServiceOptions 中移除 softDelete 属性
- CrudService 基于 Prisma schema 自动检测模型是否支持软删除
- 新增 supportsSoftDelete getter 用于判断软删除支持
- 更新 findDeleted/restore 方法使用自动检测
- PrismaService 底层已自动处理软删除逻辑

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 12:33:46 +08:00
charilezhou
73db0eb809 chore(deploy): 删除 Knative 部署配置
移除不再使用的 Knative 部署相关文件

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 12:33:20 +08:00
charilezhou
e9bcdaacce feat(deploy): 添加 Knative 部署配置
- 修改 Next.js 配置启用 standalone 输出模式
- 添加前后端多阶段 Dockerfile
- 添加 Knative Service 配置(支持缩容到 0)
- 添加 Secrets 和 ConfigMap 模板
- 添加构建和部署脚本

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 22:30:36 +08:00
charilezhou
9e5a6355cd fix(web): 修复登录页面 hydration 不匹配问题
- 移除 LoginForm 外层的 Suspense 包裹
- auth layout 中将 AuthRedirect 移到 children 之后渲染

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 21:57:32 +08:00
charilezhou
25c724f406 fix(web): 登录失败时自动刷新验证码
- Captcha 组件使用 forwardRef 暴露 refresh 方法
- LoginForm 在登录失败的 catch 块中调用 captchaRef.refresh()
- 新增 CaptchaRef 接口类型导出

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 21:47:50 +08:00
charilezhou
55dbe844af feat(web): 添加和更新其他页面
- 新增 not-found.tsx 404 页面
- 更新 profile 页面
- LoginForm 代码优化

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 21:43:39 +08:00
charilezhou
6ade9b68c9 feat(web): 更新菜单、角色和侧边栏组件
- MenuEditDialog 移除 component 和 permission 字段
- MenusTable 优化显示逻辑
- RoleEditDialog 增强角色编辑功能
- Sidebar 优化菜单渲染逻辑

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 21:42:18 +08:00
charilezhou
d7c4cbc98d refactor(web): 优化认证布局和权限检查
- auth layout 添加智能重定向(检查权限后重定向到可访问页面)
- dashboard layout 优化权限加载和过期检查逻辑
- 支持权限缓存过期后自动刷新

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 21:40:57 +08:00
charilezhou
77bf31146d feat(web): 优化权限缓存和路由检查
- permissionStore 添加缓存过期检查(30分钟 TTL)
- permissionStore 添加 canAccessRoute 方法
- authStore 移除 cookie 同步逻辑
- 移除公开路由配置,改为动态权限检查
- 添加 CACHE_CONFIG 配置

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 21:40:17 +08:00
charilezhou
b58d7b2afa feat(web): 添加用户角色分配功能
- 新增 UserRolesDialog 组件用于分配角色
- UsersTable 添加分配角色操作按钮
- user.service 添加 getUserWithRoles 和 assignRoles 方法
- useUsers hooks 添加 useUserWithRoles 和 useAssignRoles

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 21:39:45 +08:00
charilezhou
4d52346d28 feat(web): 添加权限管理模块
- 新增权限管理页面 /permissions
- 新增权限表格组件 PermissionsTable
- 新增权限编辑对话框 PermissionEditDialog
- 新增 usePermissions hooks
- 更新 permission.service 添加 CRUD 方法
- API 端点改名 MENUS -> PRIVILEGE

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 21:39:05 +08:00
charilezhou
6369e5c6e7 refactor(api): 调整 seed 数据结构
- 新增权限管理相关权限(permission:create/update/delete)
- 新增权限管理菜单
- 菜单移除 permission 字段
- 清空角色默认权限和菜单(由管理员手动分配)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 21:38:15 +08:00
charilezhou
c081f5a01f feat(api): 优化认证模块
- 注册时自动分配默认用户角色(user)
- GET /auth/menus 改名为 GET /auth/privilege
- 添加日志记录默认角色不存在的警告

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 21:37:40 +08:00
charilezhou
fe4ea4121c feat(api): 添加用户角色管理接口
- GET /users/:id/roles 获取用户详情(包含角色)
- PATCH /users/:id/roles 分配角色给用户
- 新增 AssignRolesDto、UserRoleResponseDto、UserWithRolesResponseDto

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 21:37:01 +08:00
charilezhou
f4c42cee27 refactor(api): 移除菜单的 component 和 permission 字段
- Schema 移除 Menu.component 和 Menu.permission 字段
- isStatic 默认值改为 false
- MenuTreeNode 增加 isExternal、isStatic、isEnabled、sort 字段
- DTO 同步更新

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 21:36:27 +08:00
charilezhou
f9563f886c feat(web): 验证码组件支持主题自动跟随
- 自动跟随系统主题(dark/light)
- 支持 theme prop 手动指定主题
- 代码格式化优化

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 21:35:55 +08:00
charilezhou
ce5a96c622 feat(api): 验证码接口支持主题参数
- 新增 theme 查询参数(light/dark)
- dark 主题使用 inverse=true(深色背景浅色文字)
- 默认使用 dark 主题

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 21:34:47 +08:00
charilezhou
b1496befd7 feat(shared): 添加验证码主题类型和调整菜单类型定义
- 新增 CaptchaTheme 枚举(light/dark)
- MenuResponse 移除 component 和 permission 字段
- MenuTreeNode 增加 isExternal、isStatic、isEnabled、sort 字段
- CreateMenuDto/UpdateMenuDto 移除 component 和 permission 字段

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 21:34:21 +08:00
charilezhou
d4af3f07b8 fix(web): 修复登录失败时页面刷新而不显示错误提示的问题
登录接口设置了 skipAuth: true,但 401 错误处理没有检查此标志,
导致登录失败时触发 performLogoutWithRedirect 刷新页面。
现在 skipAuth 请求的 401 错误会传递给调用者处理,正常显示 toast。

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 21:31:04 +08:00
charilezhou
fad4842c07 fix(web): 添加登录状态拦截和修复类型错误
- dashboard layout: 未登录时重定向到登录页,携带 redirect 参数
- sidebar: 移除静态菜单 fallback,仅使用动态权限菜单
- MenuEditDialog: 修复 type 字段类型为 MenuType
- RoleEditDialog: 修复 isSystem 属性访问使用 roleDetail

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 16:22:22 +08:00
charilezhou
df69eedcd9 refactor(api): 移除 barrel imports 改用直接导入
- 将所有模块的 barrel imports 改为直接导入具体文件
- 删除不再需要的 index.ts 文件(共 10 个)
- 更新 CLAUDE.md 添加禁止后端使用 barrel imports 的规范
- 避免循环依赖问题,提高代码可追溯性

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 14:39:33 +08:00
charilezhou
2ea7ae36a4 fix: 调整菜单 hooks 匹配新的服务接口
- 重命名 useMenus 为 useMenuTree 和 useFullMenuTree
- 更新 query keys 和失效逻辑

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 14:11:05 +08:00
charilezhou
279ee53251 fix: 修复菜单模块导入和服务接口调整
- 修复 menu.controller.ts 装饰器导入路径
- 调整 menu.service.ts 接口方法名和参数

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 14:10:14 +08:00