Fix #35: 价格表页面增加分页功能 - #37
Merged
Merged
Conversation
修复问题: validateApiKeyAndGetUser 函数在查询用户信息时遗漏了 providerGroup 字段,导致 session.authState.user.providerGroup 始终为 undefined,供应商选择器中的用户分组过滤逻辑无法生效。 修改内容: - 在 SELECT 查询中添加 userProviderGroup: users.providerGroup - 在构建 User 对象时传递 providerGroup: row.userProviderGroup 影响范围: - 恢复用户分组过滤功能,使设置了 providerGroup 的用户请求能够正确过滤到对应 groupTag 的供应商 - 向后兼容,未设置 providerGroup 的用户行为不变 - 无需数据库迁移或环境变更" Co-authored-by: GuShenghua <gushenghua@sdesrd.com>
- 添加分页接口 PaginationParams 和 PaginatedResult - 新增 findAllLatestPricesPaginated 分页查询方法 - 新增 getModelPricesPaginated action 函数 - 新增 /api/prices API 端点支持分页查询 - 重构 PriceList 组件支持分页、页面大小选择、搜索 - 修改价格表页面支持分页参数和降级处理 - 支持URL参数同步分页状态 - 优化性能,避免一次性加载大量数据
Owner
|
@claude 帮我审核这个 PR |
| page, | ||
| pageSize, | ||
| }; | ||
|
|
Contributor
Author
There was a problem hiding this comment.
建议优化:后端搜索实现会导致性能问题,当数据量大时前端过滤仍然需要处理大量数据。建议在 SQL 层面实现搜索过滤以提高性能。
| * - page: 页码 (默认: 1) | ||
| * - pageSize: 每页大小 (默认: 50) | ||
| * - search: 搜索关键词 (可选) | ||
| */ |
Contributor
Author
There was a problem hiding this comment.
安全建议:建议在 API 端点添加权限检查,确保只有管理员可以访问价格数据,与 Server Action 保持一致的权限控制。
| }: PriceListProps) { | ||
| const [searchTerm, setSearchTerm] = useState(""); | ||
| const [prices, setPrices] = useState<ModelPrice[]>(initialPrices); | ||
| const [total, setTotal] = useState(initialTotal); |
Contributor
Author
There was a problem hiding this comment.
性能优化:在 useEffect 中直接调用 fetchPrices 会导致额外的 API 请求。建议只在 URL 参数与当前状态不一致时才触发数据获取。
| window.history.replaceState({}, '', url.toString()); | ||
| }; | ||
|
|
||
| // 获取价格数据 |
Contributor
Author
There was a problem hiding this comment.
用户体验改进:建议添加防抖机制,避免用户快速输入时触发过多 API 请求。可以使用 useDebounce hook 来优化搜索体验。
| model_name, | ||
| MAX(created_at) as max_created_at | ||
| FROM model_prices | ||
| GROUP BY model_name |
Contributor
Author
There was a problem hiding this comment.
代码重复:两个函数使用了相似的 CTE 查询逻辑。建议抽取公共的 SQL 模板或重构为可复用的查询构建器以减少重复代码。
Contributor
Author
📋 代码审查结果✅ 整体评价这是一个质量很高的 PR,成功实现了价格表页面的分页功能,代码结构清晰,功能完整。主要优点包括:
🔧 主要改进建议
🎯 建议优先级高优先级:
中优先级:
低优先级:
🧪 测试建议
总的来说,这是一个很棒的功能实现!👍 建议优先处理安全性和性能优化后合并。 |
github-actions Bot
pushed a commit
that referenced
this pull request
Oct 31, 2025
- 将管理员用户显示名称从 'Admin Token' 改为 'Admin (token_prefix...)' - 显示管理员令牌的前8位作为标识,便于区分不同的管理员会话 - 保持普通用户的正常显示逻辑不变
Closed
主要改进: - 添加 /api/prices 端点权限检查,确保只有管理员可访问 - 实现 SQL 层面的搜索过滤,提升大数据量场景下的性能 - 添加搜索防抖机制(500ms),优化用户体验 - 移除客户端过滤逻辑,统一使用后端搜索 - 优化 useEffect 依赖,避免不必要的 API 请求 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Close #35
🎯 功能概述
为价格表页面添加分页功能,解决一次性加载大量数据导致的性能问题。
🔧 主要改动
后端改进
前端优化
性能提升
📊 预期效果
🧪 测试建议
Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com