wz-golang-server/docs/tasks/task_detail_2026_03_22.md

43 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 任务执行摘要
## 会话 ID: 20260322-tenant
- [2026-03-22 14:45:56]
- **执行原因**: 增加租户ID多租户查询支持支持从Header读取并按配置过滤。
- **执行过程**:
1. 新增租户配置与中间件,从请求头读取 X-tenantId 并绑定上下文。
2. 引入 GORM 多租户插件与工具函数,支持按表名单自动加 tenant_id 条件、手动覆盖/跳过。
3. 调整现有查询代码与部分 Raw SQL使用带上下文的 DB 并按需拼接租户条件。
- **执行结果**: 已实现可配置的租户过滤与临时覆盖能力,配置已写入配置文件。
# 任务执行摘要
## 会话 ID: 20260322-delflag
- [2026-03-22 15:00:37]
- **执行原因**: 解决查询中使用 delFlag 导致列不存在的错误。
- **执行过程**:
1. 排查 user/platform_user mapper 中软删除条件与更新字段。
2. 将查询与更新字段统一改为数据库字段名 del_flag。
- **执行结果**: 查询条件与软删除更新已改为 del_flag避免列不存在错误。
# 任务执行摘要
## 会话 ID: 20260322-tenant-login
- [2026-03-22 15:11:07]
- **执行原因**: 登录接口要求从 Header 获取 tenantId 并校验。
- **执行过程**:
1. 在登录接口中读取配置的 HeaderKey默认 X-tenantId
2. tenantId 为空时直接返回 400。
3. Swagger 注解增加 Header 参数。
- **执行结果**: 登录接口已强制要求 tenantId。
# 任务执行摘要
## 会话 ID: 20260322-tenant-helper
- [2026-03-22 15:13:58]
- **执行原因**: 抽取通用方法获取租户Header与tenantId。
- **执行过程**:
1. 新增 TenantHeaderKey 与 TenantIDFromHeader 工具方法。
2. 中间件与登录接口改为调用通用方法。
- **执行结果**: tenantId 获取逻辑已统一复用。