Commit Graph

39 Commits

Author SHA1 Message Date
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 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 4ab4090560 feat: 移除许可导入说明和编辑人输入项 2025-12-20 12:02:55 +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 64585261c4 feat(admin): 账号区域标识回填 2025-11-27 17:13:49 +08:00
Codex Agent 34bce0f5df feat(admin): 账号创建支持单位电话 2025-11-27 16:19:43 +08:00
Codex Agent 334aa77622 feat(admin): 优化用户管理布局与交互 2025-11-27 16:03:50 +08:00
Codex Agent a4e1e9baef chore(admin): checkpoint before layout update 2025-11-27 15:26:59 +08:00
Codex Agent 9a392f62b0 feat: add super admin v2 debug console 2025-11-24 15:18:49 +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 f115a31cdd feat: remove user management feature and set permits as default tab
- Remove "用户与系统管理" tab and its content from db_admin page
- Delete admin-only CSS styles and role-based logic
- Set "许可事项管理" as the default active tab
- Simplify setupTabsByRole function to remove role checks
- Update DOMContentLoaded handler to use simplified logic

Now users accessing /db_admin will directly see the permits management interface by default.
2025-11-18 19:57:55 +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 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 cc0f9053dd fix: hide redundant region_name tag for district-level departments
## 问题
顺德区服务部门显示额外的"顺德区"标签,而其他区没有,造成显示不一致。

## 根因
数据库中顺德区服务部门的region_id字段被设置,其他区为NULL,导致region_name显示不一致。

## 解决
修改前端渲染逻辑,对于二级节点(Level 1),如果节点名称已包含"区"字,则智能隐藏region_name标签,避免冗余显示。

## 修改
- static/super_admin.html: 在渲染元数据时添加智能隐藏逻辑
- 添加详细的修复说明文档和测试脚本

## 效果
所有区级服务部门(如禅城区、南海区、顺德区等)现在都统一不显示冗余的区域标签,保持显示一致性。

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 14:55:04 +08:00
Codex Agent 942884fe4b feat: improve org chart visual design with soft color scheme
## 改进内容

### 视觉优化
- 实现三级颜色体系区分组织层级(根/二级/三级节点)
- 调整配色为柔和淡雅的浅色系,不再刺眼
- 增强缩进指示(0px → 20px → 40px)
- 添加左侧彩色边框和垂直连接线

### 交互体验
- 优化toggle按钮(32x32px,易于点击)
- 改进hover效果(柔和阴影 + 轻微浮动)
- 添加平滑过渡动画(0.2s)

### 配色方案
- 根节点:淡蓝紫渐变 + 深蓝紫文字
- 二级节点:淡紫渐变 + 深紫文字
- 三级节点:很浅淡紫 + 深紫文字
- 所有节点均采用浅色背景配深色文字,舒适不刺眼

### 文件变更
- static/super_admin.html: 更新CSS样式和JavaScript逻辑
- 添加配色方案更新文档和视觉改进说明
- 创建柔和配色预览页面

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 14:49:23 +08:00
Codex Agent 3a9bf9aeca fix: add tabbed layout to super admin console 2025-11-17 14:19:36 +08:00
Codex Agent 168cdf6470 feat: add super admin console 2025-11-14 15:46:18 +08:00
Codex Agent 0076d2db2f feat: add permit file management UI and APIs 2025-11-14 10:32:23 +08:00
Codex Agent 66cc871e47 feat: redesign db admin import flow 2025-11-13 19:21:59 +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 a5bc3c41b7 feat: 优化风险快照批次展示 2025-11-03 16:41:35 +08:00
Codex Agent 406fca7363 feat: unify snapshot and checkpoint timeline 2025-11-03 11:30:38 +08:00
Codex Agent d2faf03082 fix: correct translation in db_admin.html
Changed "管辖范围" to "权限划分" in the permit details section.
This more accurately reflects the actual meaning of the jurisdiction_scope field.

Modified:
- static/db_admin.html: Line 1208

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 10:08:11 +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 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 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 7ddec0fb4f refactor: move checkpoint management to separate modal window
Changes:
- Removed checkpoint from main workflow (step 5)
- Added standalone "检查点管理" button in top toolbar
- Created dedicated modal window for checkpoint management
- Updated UI to be more user-friendly and separate concerns

Benefits:
- Checkpoint management is now a standalone feature
- Doesn't interfere with the main database maintenance flow
- Modal window provides better focused interface
- Users can access checkpoints anytime without losing their place in the workflow

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-30 11:48:15 +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 506ea5ce98 feat: optimize database admin UI with improved navigation
 Major Improvements:
- Layout optimization: Reduced navigation panel to 350px, maximized content area
- Navigation centralization: All operations in left panel with unified workflow
- History stack management: Implemented step-by-step back navigation
- Loading animations: Added loading spinners for all async operations
- Scrollable lists: Added custom scrollbar for long theme lists (max-height: 600px)
- Breadcrumb navigation: Visual path tracking with quick jump functionality

🎨 User Experience:
- Navigation paths show current position (e.g., Home › 市级 › 开办电影院)
- Clickable breadcrumbs for fast navigation to any step
- "Back" button for sequential navigation
- "Home" button to reset all selections
- Custom scrollbar styling matching UI design
- Responsive design with proper overflow handling

🔧 Technical Implementation:
- Step state machine (1→2→3→4 workflow)
- History stack for multi-step navigation
- Dynamic breadcrumb generation
- Smart state cleanup on quick jumps
- Loading states for all API operations

📁 Files Modified:
- static/db_admin.html: Complete UI/UX overhaul (734 lines)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-30 09:54:36 +08:00
Codex Agent cbefb81a35 feat: 实现数据库维护功能
## 新增功能

### 1. 后端API路由 (lawrisk/api/v2.py)
- 添加了5个新的管理API端点:
  * GET /admin/regions - 获取地区列表
  * GET /admin/themes - 获取主题列表(按地区筛选)
  * GET /admin/permits - 获取许可列表(按地区和主题筛选)
  * GET /admin/permit-details - 获取许可详细信息
  * GET /admin/test - 测试路由

### 2. 前端管理界面 (static/db_admin.html)
- 实现了完整的数据库维护管理页面
- 4步操作流程:地区选择 → 主题列表 → 许可列表 → 详细信息展示
- 现代化UI设计,包括:
  * 渐变背景和响应式布局
  * 平滑动画过渡效果
  * 实时数据加载提示
  * 完整的许可信息展示(许可状态、经营范围、法律风险等)

## 技术实现
- RESTful API设计,返回标准JSON格式
- 直接从PostgreSQL数据库读取数据
- 所有API已通过curl和Flask测试客户端验证

## 测试结果
在端口8888上测试通过:
- admin/regions: 1个地区
- admin/themes: 57个主题
- admin/permits: 6个许可
- admin/permit-details: 完整许可信息和3个风险记录
- 静态页面: 成功加载

## 使用方法
```bash
# 启动服务
PORT=8888 python app.py &

# 访问管理界面
http://localhost:8888/static/db_admin.html

# API调用示例
curl http://localhost:8888/fs-ai-asistant/api/workflow/lawrisk/admin/regions
```

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-30 08:52:48 +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
Codex Agent be25619fa8 feat: add v2 tester page and LLM logging 2025-10-24 11:30:36 +08:00