Commit Graph

34 Commits

Author SHA1 Message Date
Codex Agent 347af34bfc Refine import wizard: simplify permit details, add image zoom, and enhance risk metadata display (legal basis, document no, summary) 2026-01-27 15:33:33 +08:00
Codex Agent e7da819fea feat(ui,api): resolve department filter errors and enhance import wizard 2026-01-27 14:23:03 +08:00
Codex Agent fbc696b61c feat: add visibility filter to unbound permits API 2025-12-29 16:59:26 +08:00
Codex Agent c55170208b feat: add visibility filter for permit management and fix V2 visibility logic
- Added 'Enabled Status' dropdown filter to db_admin.html for filtering permits by visibility (visible/hidden/all)
- Updated admin_permits_advanced_filter API to accept and process visibility parameter
- Modified filter_permits_advanced in licensing_repo.py to filter by is_v2_visible column
- Fixed role-based access control to allow department_admin to toggle permit visibility
- Improved parameter parsing in API endpoints for more robust handling
2025-12-29 15:54:53 +08:00
Codex Agent b532c46dc1 feat: 优化事项过滤逻辑与后台管理界面交互 2025-12-26 09:26:10 +08:00
黄仁欢 1595027679 fix: resolve missing preview data in permit import session and fix logging bug 2025-12-25 19:56:56 +08:00
Codex Agent 762d0c0115 Cleanup: Organize project structure and resolve merge conflicts 2025-12-25 19:18:37 +08:00
Codex Agent 06944cd251 Backup database 2025-12-25 and clean up project structure 2025-12-25 09:50:02 +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 60b94d8a20 feat: 修复V2 API许可证名称匹配和审批部门显示
- 添加permit_approval_departments表自动创建和管理
- 实现许可证名称的精确匹配和前缀模糊匹配
- 修复find_permit_contexts_by_name支持前缀匹配(如'药品经营许可'匹配'药品经营许可证')
- 修复load_permits_and_risks中的审批部门JOIN逻辑,使用CONCAT进行前缀匹配
- 新增管理API端点 /admin/approval-departments/setup 用于初始化审批部门映射
- 更新.gitignore忽略临时脚本和Excel文件
2025-12-23 16:23:10 +08:00
Codex Agent 199a97cceb Fix: Allow searching for unbound permits by name 2025-12-22 16:27:48 +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 6dd5621fad docs: create root README and update guides with checkpoint system info; fix: JSON serialization bug in checkpoint creation for binary data 2025-12-21 17:26:04 +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 b53fb872ed Refine login status bar UI in super_admin.html and db_admin.html 2025-12-18 11:51:43 +08:00
Codex Agent a4e1e9baef chore(admin): checkpoint before layout update 2025-11-27 15:26:59 +08:00
Codex Agent 9aa6fabfb1 feat: 增强许可详情页面显示完整信息
在许可详情弹窗中添加了完整的许可信息展示区域,包括以下7个字段:
1. 许可情况 - 显示许可状态
2. 许可(备案)事项子项 - 显示子项详情
3. 行政区域 - 显示所属区域
4. 负责部门 - 显示负责部门和联系方式
5. 权限划分 - 显示权限范围
6. 经营范围 - 显示业务范围(跨列显示)

所有字段均使用清晰标签、两列网格布局,经营范围字段跨列显示适合长文本。
信息层次清晰:基本信息 → 许可信息 → 风险信息。

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 09:47:20 +08:00
Codex Agent ec44bec90a feat: 实现许可事项管理多选筛选器及区域部门关联过滤
 核心功能实现:

1. 多选筛选器界面
   - 行政区域多选支持
   - 主题多选支持
   - 关联部门多选支持
   - 全选/取消全选功能
   - 实时显示选中数量

2. 区域与部门智能关联过滤
   - 选择区域后自动更新关联部门列表
   - 通过permit_sources表建立region与department关联关系
   - 避免无效筛选条件组合
   - 提升用户体验和数据准确性

📝 修改文件:

- lawrisk/services/licensing_repo.py
  * 新增 list_service_departments(region_id) 函数
  * 支持按region_id筛选部门列表

- lawrisk/api/v2.py
  * 修改 admin_permits_filter_options() 路由
  * 支持 region_id 查询参数

- static/db_admin.html
  * 实现多选下拉菜单组件
  * 新增区域选择变化处理函数
  * 新增动态加载关联部门功能

🧪 测试验证:

- API测试通过:带region_id参数返回关联部门
- Flask应用正常启动
- 多选筛选功能完全可用

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-19 15:51:49 +08:00
Codex Agent a6fe2f4370 feat: 登录权限跳转安全优化与权限控制系统完善
## 主要修改

### 🔒 安全优化 (auth.py)
- 统一所有用户登录跳转路径,防止权限暴露
- 所有用户默认跳转到 /fs-ai-asistant/api/workflow/lawrisk/db_admin
- 移除基于权限等级的多路径跳转逻辑
- 移除调试字段 TEST_MARKER

### 🛡️ 权限控制系统 (licensing_repo.py)
- 实现基于用户等级的权限过滤
- 超级管理员(grade=100)和市级管理员(grade>=90): 查看所有区域数据
- 区级管理员(grade<90): 只能查看自己区域数据
- 添加详细的权限拒绝日志记录

### 👥 用户管理增强 (auth_service.py, v2.py)
- 添加 delete_user_account 函数
- 实现用户删除API端点
- 防止删除最后一个管理员账号的安全检查

### 🎨 UI优化 (super_admin.html)
- 更新界面文案: "新的服务部门" → "绑定服务部门"

## 测试验证
-  所有用户统一跳转验证通过
-  权限控制逻辑验证通过
-  用户删除功能验证通过
-  自定义next参数支持正常

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-18 15:45:30 +08:00
Codex Agent 9ca9a3642f feat: 组织架构权限等级自动管理系统
## 主要功能
- 实现基于组织架构层级的权限等级自动计算
- 权限等级映射:根级(90)、二级(80)、三级(70)、四级+(60)
- 自动根据从属关系计算权限,无需手动填写

## 安全修复
- 修复密码在URL中泄露的严重安全问题
- 清理所有重定向URL的查询参数
- 前端敏感参数检测与警告

## 用户体验优化
- 移除组织架构树的权限等级显示
- 简化新增/编辑部门的表单界面
- 实现智能登录跳转(基于角色自动跳转)
- Tooltip跟随鼠标,修复滚动偏移bug

## 技术实现
- 前端:自动权限计算函数、拖拽功能、模态框交互
- 后端:_calculate_grade_by_parent()、_get_department_level()
- 数据库:保留grade字段,自动同步层级关系

## 修复的问题
- 组织架构管理按钮无响应
- 登录跳转404错误
- 权限等级手动设置繁琐
- Tooltip位置偏移

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-18 09:39:18 +08:00
Codex Agent 1c010f4fdf feat: add authentication system and service department tree structure
## Major Changes

### Authentication System
- Added passlib dependency for password hashing and security
- Integrated auth_service module with automatic admin seeding
- Added authentication blueprint and middleware
- Updated app initialization to ensure auth schema and default accounts

### Service Department Management
- Added build_service_department_tree() function for hierarchical data structure
- Supports nested parent-child relationships for department hierarchy
- Recursive sorting for consistent tree visualization
- Enables advanced admin interface features

### Dependencies
- Added passlib>=1.7.4 for secure password hashing
- Added openpyxl>=3.1.2 for Excel file processing

### UI Improvements
- Enhanced db_admin.html with tabbed interface styling
- Improved spacing and visual layout
- Better organization for multiple admin functions

## Technical Details
- Refactored app.py to use auth_service instead of deprecated ensure_database
- Maintains backward compatibility with existing v2 API
- Clean separation of authentication and business logic

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 15:07:14 +08:00
Codex Agent 168cdf6470 feat: add super admin console 2025-11-14 15:46:18 +08:00
Codex Agent 90fa969046 fix: honor permit overrides and bindings 2025-11-14 11:43:43 +08:00
Codex Agent 0076d2db2f feat: add permit file management UI and APIs 2025-11-14 10:32:23 +08:00
Codex Agent fd82b757fe feat: show permit themes in db admin 2025-11-13 17:01:37 +08:00
Codex Agent 772354bd01 feat: support permit file uploads 2025-11-13 15:28:08 +08:00
Codex Agent 5b86bd8799 feat: 优化许可导入区划合并与来源展示 2025-11-04 13:38:21 +08:00
Codex Agent ec8adf98f1 feat: add permit risk snapshot workflow 2025-11-03 09:43:58 +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 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 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 9530eabac8 feat: add database checkpoint management system
Features:
- Create manual database checkpoints with descriptions
- List all available checkpoints with statistics
- Restore database from checkpoints (with dangerous operation warning)
- Delete unwanted checkpoints
- Frontend UI integrated into database admin panel
- JSON-based checkpoint storage in data/checkpoints/

Backend Changes:
- Added checkpoint management functions to licensing_repo.py:
  * create_checkpoint() - backup all tables to JSON
  * list_checkpoints() - enumerate checkpoint files
  * restore_checkpoint() - restore from checkpoint
  * delete_checkpoint() - remove checkpoint file
- Added 4 new API endpoints to v2.py:
  * GET /admin/checkpoints - list checkpoints
  * POST /admin/checkpoints - create checkpoint
  * POST /admin/checkpoints/{id}/restore - restore checkpoint
  * DELETE /admin/checkpoints/{id} - delete checkpoint

Frontend Changes (db_admin.html):
- Added step 5 "检查点管理" to navigation
- Created checkpoint management UI with forms and lists
- Added dangerous operation confirmation modal
- Integrated into existing breadcrumb navigation system

Safety Features:
- All dangerous operations require explicit confirmation
- Restore operations show warning about data loss
- Checkpoints include row counts and table statistics
- Timestamped checkpoint IDs for easy identification

Note: Checkpoint files are stored in data/checkpoints/ directory

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-30 10:33:35 +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