Commit Graph

88 Commits

Author SHA1 Message Date
Codex Agent 26a7b531f3 Update auth flows and admin tools 2026-03-19 15:14:42 +08:00
Codex Agent d97c7ca086 fix: 优化组织架构显示顺序,解决市级部门层级显示问题
修改内容:
- 后端:修改 service_department_tree 排序逻辑,实现叶子节点优先显示
- 前端:添加组织架构渲染调试日志,便于排查层级问题
- 文档:添加前端调试指南、快速参考和实施总结文档

排序规则:
1. 无下属单位的部门(叶子节点)排在前面
2. 有下属单位的部门(父节点)排在后面
3. 同类节点按名称排序

预期效果:
- "佛山交通运输局"等市级部门不再被误认为区级部门的子节点
- 视觉层次更清晰,减少用户误解
- 层级关系保持不变(都是 Level 1)

相关文件:
- lawrisk/services/licensing_repo.py
- static/super_admin.html
- FRONTEND_DEBUG_GUIDE.md
- HIERARCHY_DEBUG_QUICK_REF.md
- IMPLEMENTATION_SUMMARY.md
- SORTING_FIX_SUMMARY.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-10 19:51:25 +08:00
Codex Agent 616cac2c2e feat: 实施严格部门权限控制并修复导入功能
主要修改:
- 添加严格的部门层级权限控制(只看自己及下级部门,不看父级)
- 在 filter_permits_advanced() 添加 expand_department_family 参数
- 修复许可导入时的部门自动绑定功能
- 在 API 端点添加用户认证和部门权限过滤

技术细节:
- lawrisk/api/v2.py: 添加 @login_required 和部门权限过滤逻辑
- lawrisk/services/licensing_repo.py: 添加 expand_department_family 参数控制部门扩展行为
- static/db_admin.html: 修复导入功能,自动绑定到用户部门
- lawrisk/api/auth.py: 添加 is_superuser 权限检查

影响范围:
- 用户现在只能看到自己部门及下级部门上传的许可事项
- 新导入的许可事项会自动绑定到当前用户的部门
- 超级管理员不受影响

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-10 19:06:06 +08:00
Codex Agent b0590fda30 feat: enhance theme and permit listing with filtering and risk counts
- Filter out "不涉及" (not applicable) theme from list_all_themes()
- Add risk_count column to list_unbound_permits() with aggregated risk counts
- Improve unbound permits API to display risk count per permit-region combination

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-04 13:52:57 +08:00
Codex Agent fe911592e0 fix: resolve server deployment image 404 errors and enhance admin UI
- Add dedicated image serving API endpoint (/admin/images/<filename>) with security whitelist
- Update image paths from /static/ to /fs-ai-asistant/api/workflow/lawrisk/admin/images/
- Add permit import sample file download endpoint
- Enhance import wizard UI with template/sample preview section
- Add risk count column to unbound permits table
- Filter out "不涉及" (not applicable) theme from theme list
- Improve permit import UX with better visual organization

This ensures images load correctly in server deployments (nginx, gunicorn) by using
the same API prefix as other admin resources, avoiding static file routing issues.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-04 13:51:20 +08:00
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
Codex Agent ea55825080 Merge branch 'master' of C:\Users\WIN10\Desktop\work\21th-week\law-risk-central
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
2025-12-25 19:59:34 +08:00
Codex Agent 2141db2db7 fix: add null checks to UI functions in db_admin.html to prevent innerHTML errors 2025-12-25 19:58:33 +08:00
黄仁欢 1595027679 fix: resolve missing preview data in permit import session and fix logging bug 2025-12-25 19:56:56 +08:00
黄仁欢 70e46a730e fix: update db_admin.html logic for permit visibility and UI enhancements 2025-12-25 19:23:55 +08:00
Codex Agent 762d0c0115 Cleanup: Organize project structure and resolve merge conflicts 2025-12-25 19:18:37 +08:00
黄仁欢 2440a02a2d Fix: Admin department binding and region visibility
1. Bind 'City-level' permits to 'SYSADMIN' department to ensure they are managed by admin.
2. Ensure Foshan 5 regions exist and Service Departments (FSSJSS etc.) are correctly bound to their regions.
3. Update specific permit binding logic to prevent leakage of 'City-level' data to district admins.
4. UI: Restrict region filter in Admin Console for non-admin users to their own region only.
2025-12-25 19:12:07 +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 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 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 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 a3f6640b2d feat: V2接口使用预设问题推荐替代LLM生成
- 新增预设问题模板,基于数据库中有许可事项的主题生成问题
- 移除LLM调用,提升响应速度
- 只推荐有实际许可事项的主题相关问题
- 整理项目结构:test文件移至tests/,xlsx移至data/,md文档移至docs/
2025-12-15 13:35:57 +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 2045a5b524 chore: ignore .claude, AGENTS.md, and CLAUDE.md
- Add .claude/ to .gitignore (Claude-specific configuration)
- Add AGENTS.md to .gitignore (development guidelines)
- Add CLAUDE.md to .gitignore (Claude Code guidance)
- These files should not be tracked in version control
- Remove existing tracked instances from repository
2025-11-18 17:31:31 +08:00
Codex Agent e03bfec12c feat: restore AGENTS.md and CLAUDE.md to root directory
- AGENTS.md: Development guidelines and coding standards
- CLAUDE.md: Detailed Claude Code development guide
- Both files are important project documentation that should be in root
- Files also exist in docs/guides/ for documentation organization
2025-11-18 17:24:51 +08:00
Codex Agent b236021993 chore: remove duplicate AGENTS.md from root
- AGENTS.md has been moved to docs/guides/ for consistent structure
- This cleans up the root directory
- All documentation is now properly organized under docs/
2025-11-18 17:11:58 +08:00
Codex Agent 74c377d7ce docs: track AGENTS.md in docs/guides/
- Move AGENTS.md from root to docs/guides/
- Keep development guidelines with other documentation
- Ensures consistent documentation structure
2025-11-18 17:10:03 +08:00
Codex Agent 54d50c1521 chore: update .gitignore to track AGENTS.md and CLAUDE.md
- Remove AGENTS.md and CLAUDE.md from .gitignore
- These are important project documentation files that should be tracked
- Updated to reflect the clean directory structure with docs/ organization
2025-11-18 17:09:32 +08:00
Codex Agent 4078a75b37 docs: 更新.gitignore文件
- 忽略编译的Python文件 (.pyc, .pyo)
- 忽略Python缓存目录 (__pycache__)
- 保留文档结构的整洁性
2025-11-18 17:07:24 +08:00
Codex Agent 692ff6ef0f docs: 归档所有markdown文档到docs目录
目录结构优化:
1. 创建了规范的文档目录结构
   - docs/guides/ - 开发指南文档
   - docs/features/ - 功能开发文档
     - admin/ - 管理员功能
     - login_redirect/ - 登录跳转功能
     - org_chart/ - 组织架构功能
   - docs/security/ - 安全与权限文档
   - docs/reports/ - 测试报告
     - test-reports/ - 功能测试报告
     - checkpoint-reports/ - Checkpoint系统报告
   - docs/development/ - 开发总结报告
   - docs/README.md - 文档索引

2. 移动了38个markdown文件到对应目录
   - 开发指南: README.md, AGENTS.md, CLAUDE.md
   - 功能开发: 12个功能实现文档
   - 安全权限: 5个安全和权限文档
   - 测试报告: 10个测试报告
   - 开发总结: 2个完成报告
   - Checkpoint: 5个系统报告

3. 创建了文档索引文件
   - docs/README.md
   - 详细说明目录结构和文档分类
   - 提供快速导航链接
   - 方便查阅和维护

效果:
 根目录不再有混乱的markdown文件
 文档按功能模块清晰分类
 便于开发者快速定位相关文档
 建立了完整的项目文档体系

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-18 17:06:45 +08:00
Codex Agent 2302ab099e docs: 添加SQL建表脚本和认证测试文件
新增内容:
1. 数据库建表脚本
   - docs/sql/003_create_permit_sources_table.sql
   - docs/sql/004_create_region_permit_theme_overrides.sql

2. 认证系统测试
   - tests/test_auth.py

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-18 16:58:21 +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 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