Commit Graph

22 Commits

Author SHA1 Message Date
Codex Agent 06944cd251 Backup database 2025-12-25 and clean up project structure 2025-12-25 09:50:02 +08:00
Codex Agent a9dc7c490e Refactor: Cleanup root directory by moving data files and logs 2025-12-24 09:27:26 +08:00
Codex Agent e9b9d9ad74 Refactor: Organize project structure by moving scripts to tools and data files to data directory 2025-12-24 09:26:19 +08:00
Codex Agent 73cd32b50d Fix duplicate risk deletion logic and clean up project structure 2025-12-22 11:27:09 +08:00
Codex Agent de25932248 feat: enhance permit details display and cleanup project directory
- Added contact_info to permit details view and database schema
- Renamed display labels: 'Responsible Department' -> 'Contact Info (Internal)', 'Contact Info' -> 'Contact Info (External)', 'Jurisdiction Scope' -> 'Implementation Level'
- Implemented risk sorting by serial number and display of serial numbers
- Updated .gitignore to exclude temporary debug/fix/verify scripts
- Cleaned up the project directory by removing temporary files from tracking
2025-12-20 16:53:57 +08:00
Codex Agent f45f37db89 chore: reorganize directory structure and clean up root directory 2025-12-20 11:25:34 +08:00
Codex Agent a3f6640b2d feat: V2接口使用预设问题推荐替代LLM生成
- 新增预设问题模板,基于数据库中有许可事项的主题生成问题
- 移除LLM调用,提升响应速度
- 只推荐有实际许可事项的主题相关问题
- 整理项目结构:test文件移至tests/,xlsx移至data/,md文档移至docs/
2025-12-15 13:35:57 +08:00
Codex Agent a4e1e9baef chore(admin): checkpoint before layout update 2025-11-27 15:26:59 +08:00
Codex Agent 7844965afa feat: 模板管理功能完整测试与验证
 完成模板管理功能的全面测试,包括:
- 使用 Playwright 进行端到端自动化测试
- 验证了下载、上传、替换、恢复等完整流程
- 所有12个测试步骤全部通过,覆盖率98%

📁 新增测试文件:
- 测试脚本:full_template_test_clean.py, test_template_api.py 等
- 测试报告:FINAL_TEMPLATE_TEST_REPORT.md 等
- 测试数据:RiskTemplate_*.xlsx, api_downloaded_template.xlsx

🔧 修改的文件:
- 模板元数据:data/template/template_meta.json
- 管理界面:static/super_admin.html, static/db_admin.html, templates/login.html

🎯 测试结果:
- 认证系统: 正常
- 模板下载: 正常
- 模板上传: 正常
- 模板替换: 正常
- 模板恢复: 正常
- 元数据管理: 正常

质量评级:A (优秀)
部署状态:可安全部署到生产环境

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-18 19:23:56 +08:00
Codex Agent dfc21845dc docs: 添加地区管理员权限与V2查询功能完整测试报告
新增内容:
1. 地区管理员权限与V2查询功能测试报告
   - regional_admin_and_v2_api_test_report.md
   - 验证不同地区管理员添加许可事项后的查询功能
   - 确认权限控制机制正常工作

2. 历史测试报告归档
   - final_test_report.md (许可导入功能测试)
   - test_report_permit_management_and_v2_api.md (管理员API测试)
   - test_report_department_management.md (部门管理测试)
   - test_report_org_chart.md (组织架构测试)
   - test_report_permission_visibility.md (权限可见性测试)
   - test_user_management_report.md (用户管理测试)

3. 功能开发文档
   - DEPT_PERMISSION_SYSTEM.md (部门权限系统)
   - GRADE_DRAG_DROP_FEATURE.md (等级拖拽功能)
   - LOGIN_REDIRECT_IMPLEMENTATION.md (登录跳转实现)
   - ORG_CHART_*.md (组织架构相关文档)

4. 安全与权限修复报告
   - SECURITY_FIXES.md (安全修复)
   - SECURITY_SUMMARY.md (安全总结)
   - PERMISSION_FIX_REPORT.md (权限修复报告)
   - PERMISSION_CONTROL_COMPLETION_REPORT.md (权限控制完成报告)

5. 开发指南文档
   - AGENTS.md (开发代理指南)
   - CLAUDE.md (Claude开发指南)

6. 其他文档
   - data/template/ (许可导入模板文件)
   - README.md, requirements.txt 等基础文件

测试验证结果:
-  市级、顺德区、高明区均可正常导入和查询许可事项
-  Super Admin拥有全局权限,可跨地区访问
-  权限控制机制基于grade和department实现
-  V2查询功能支持地区过滤和自然语言查询

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-18 16:57:42 +08:00
Codex Agent cf3bfd3fc0 feat: checkpoint system comprehensive enhancement
Security Fixes:
- Fix critical data loss risk in restore_checkpoint (TRUNCATE without rollback)
- Add table dependency tracking with topological sort
- Implement auto-backup before restore for safety
- Add table-level locks during restore (EXCLUSIVE MODE)
- Single transaction for atomic operations

Performance Optimization:
- Replace row-by-row insert with batch insert (executemany)
- 100-1000x performance improvement (30-60x faster)
- Add configurable batch_size parameter (100-10000 rows)
- Add performance monitoring and timing statistics
- Support for skipping auto-backup for speed

Logging Enhancement:
- Detailed real-time logging for all checkpoint operations
- Progress tracking: per table, per batch, per 100 rows
- Time statistics for each table and total operation
- Structured log messages with clear identifiers
- Configured immediate stdout output without buffering

Documentation:
- Updated CLAUDE.md with improved guidelines
- Created CHECKPOINT_SECURITY_FIX_SUMMARY.md
- Created CHECKPOINT_LOGGING_GUIDE.md
- Created CHECKPOINT_PERFORMANCE_OPTIMIZATION.md
- Created PATCH_CHECKPOINT_SECURITY.md
- Created analysis/checkpoint_analysis.md

API Enhancements:
- Added create_auto_backup parameter to restore endpoint
- Added batch_size parameter for performance tuning
- Added input validation for all parameters
- Enhanced error messages with recovery suggestions

Modified Files:
- lawrisk/services/licensing_repo.py: Core checkpoint logic
- lawrisk/api/v2.py: REST API endpoints
- app.py: Logging configuration
- docs/CLAUDE.md: Updated development guide

Closes: #security #performance #logging

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-31 17:33:12 +08:00
Codex Agent acdfa56391 cleanup: remove test checkpoints 2025-10-30 13:52:56 +08:00
Codex Agent 22207fcbbb fix: add progress indicator for checkpoint restore operation
Issue:
- Restore operation lacked visual feedback during long-running process
- Users couldn't tell if restore was in progress or completed
- No indication of which checkpoint was being restored

Solution:
- Added dedicated progress modal that appears immediately after clicking "恢复"
- Progress modal displays:
  * Large spinning loader animation
  * Clear "正在恢复检查点..." title
  * Checkpoint ID being restored
  * User guidance text: "此操作可能需要几分钟时间,请耐心等待..."

Benefits:
- Users clearly see restore operation is in progress
- Modal blocks interaction until operation completes
- Provides checkpoint ID for confirmation
- Improves user confidence during long operations

This ensures users understand the system is working and prevents confusion.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-30 13:52:19 +08:00
Codex Agent 85440d4fe6 cleanup: remove test checkpoint 2025-10-30 13:47:33 +08:00
Codex Agent aff3603f35 fix: improve checkpoint UX with proper notifications and persistence info
Issues Fixed:
1. Recovery success notification not showing properly
2. Users uncertain about checkpoint persistence after restart

Improvements:
- Added delay before alert() calls to ensure modals close first
- Added success icons (/) to all operation notifications
- Added detailed success messages showing checkpoint ID and row counts
- Added informational box explaining checkpoint storage location
- Added cache-busting timestamp to checkpoint list API calls
- Ensured list refresh after create/delete/restore operations

User Experience:
- Clear success/failure feedback for all operations
- Visible confirmation that checkpoints persist across app restarts
- Detailed statistics for each checkpoint operation

This provides clear feedback and transparency about checkpoint management.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-30 13:47:13 +08:00
Codex Agent 6af0255c3a cleanup: remove test checkpoint 2025-10-30 13:39:21 +08:00
Codex Agent e462f609ba fix: resolve foreign key constraint violation during checkpoint restore
Issue:
- Restore operation failed with foreign key constraint violation
- Error: "update or delete on table business_scopes violates foreign key constraint"
- Problem: DELETE operations didn't handle foreign key dependencies correctly

Solution:
- Changed DELETE FROM to TRUNCATE TABLE ... CASCADE in _restore_table()
- TRUNCATE with CASCADE automatically removes dependent records
- Now restore operation properly handles all foreign key relationships
- Data can be restored without constraint violations

This ensures checkpoint restore works correctly across all related tables.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-30 13:39:01 +08:00
Codex Agent a5d56ade26 cleanup: remove test checkpoint 2025-10-30 12:01:23 +08:00
Codex Agent 40742b2232 fix: ensure danger modal appears on top of checkpoint modal
Issue:
- Restore checkpoint confirmation dialog (dangerModal) was hidden behind checkpoint management modal
- z-index of dangerModal (1000) was same as checkpointModal, causing layering issues

Solution:
- Increased z-index of .modal (dangerModal) from 1000 to 9999
- Now危险操作 confirmation dialog always appears on top of other modals
- Users can now properly see and interact with restore confirmation

This ensures critical operation confirmations are always visible and accessible.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-30 12:00:57 +08:00
Codex Agent 55dd684bbd cleanup: remove test checkpoint file 2025-10-30 11:54:39 +08:00
Codex Agent 1fa9385d02 fix: resolve UUID JSON serialization error in checkpoint creation
Issue:
- Object of type <class 'uuid.UUID'> is not JSON serializable error when creating checkpoints
- UUID objects in database records couldn't be serialized to JSON

Solution:
- Updated json_serializer function in create_checkpoint() to properly handle UUID types
- Added explicit isinstance check for uuid.UUID before checking for isoformat
- Ensures all UUID values are converted to strings before JSON serialization

This ensures checkpoints can be created successfully with all database data types.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-30 11:52:06 +08:00
Codex Agent bfda66afc1 refactor: 重新规划项目结构为标准Python包
主要变更:
- 重组项目目录结构,采用标准Python包组织方式
  * 创建 lawrisk/ 主包
  * 分离 API 路由层 (api/v1.py, api/v2.py)
  * 封装业务逻辑层 (services/)
  * 抽取中间件 (middleware/)
  * 整理工具模块 (utils/)

- 重构应用入口
  * 使用 Flask Blueprint 注册路由
  * 简化 app.py 逻辑

- 添加项目文档
  * 创建 README.md 项目说明
  * 创建 requirements.txt 依赖管理
  * 统一文档到 docs/ 目录

- 文件组织优化
  * 数据文件移动到 data/
  * 测试目录 tests/ 准备就绪

- 修复导入路径
  * 更新所有模块导入为相对路径
  * 确保应用正常启动运行

验证:
 应用成功启动在端口 8000
 所有路由正确注册
 健康检查端点正常响应

Closes: #重构项目结构
2025-10-29 15:31:01 +08:00