feat(toolbox): get toolbox config list api - #482
Merged
renbaoshuo merged 16 commits intoMay 19, 2026
Conversation
155TuT
requested review from
a team,
jiuxia211,
mutezebra,
ozline and
renbaoshuo
as code owners
May 13, 2026 15:16
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #482 +/- ##
==========================================
- Coverage 63.81% 63.18% -0.63%
==========================================
Files 230 233 +3
Lines 6027 6104 +77
==========================================
+ Hits 3846 3857 +11
- Misses 2057 2125 +68
+ Partials 124 122 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 8 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
新增一个带鉴权与分页的“工具箱云配置列表”获取接口,贯穿 IDL/Kitex 生成代码、Common RPC 服务实现、DAL 查询与 API 网关侧路由/Handler,并补充了对应单测,方便管理端按页查看配置明细(含 config_id、student_id)。
Changes:
- 新增 DAL
ListToolboxConfigs与 CommonServiceGetToolboxConfigList(含分页归一化与鉴权)实现,并补充单测 - 扩展
ToolboxConfigThrift 模型字段(config_id、student_id),并更新 Kitex/API 侧生成代码与打包逻辑 - API 网关新增
/api/v1/toolbox/config/list路由、RPC 调用封装与 Handler/测试
Reviewed changes
Copilot reviewed 13 out of 23 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/db/toolbox/get_configs.go | 新增分页查询与总数统计 DAL 方法 |
| pkg/db/toolbox/get_configs_test.go | 新增 DAL 分页查询单测(count/find 分支) |
| kitex_gen/model/model.go | 扩展 ToolboxConfig 生成模型字段与 accessor |
| kitex_gen/common/k-common.go | 新增 GetToolboxConfigList RPC 的 args/result 生成代码 |
| kitex_gen/common/commonservice/commonservice.go | 注册并实现 GetToolboxConfigList Kitex handler/client 调用 |
| kitex_gen/common/commonservice/client.go | CommonService client 接口补充 GetToolboxConfigList |
| kitex_gen/common/common.go | 新增请求/响应结构体与 CommonService 接口方法声明 |
| internal/course/service/get_term_info_test.go | mock Common client 补齐新方法以通过编译 |
| internal/common/service/get_toolbox_config_list.go | 新增鉴权+分页归一化的 service 层列表逻辑 |
| internal/common/service/get_toolbox_config_list_test.go | 新增 service 层列表逻辑单测 |
| internal/common/pack/toolbox.go | 新增面向管理端的 config detail 打包(含 config_id/student_id) |
| internal/common/handler.go | Common RPC handler 增加 GetToolboxConfigList 实现 |
| idl/model.thrift | ToolboxConfig 增加 config_id、student_id 字段 |
| idl/common.thrift | CommonService 增加 GetToolboxConfigList RPC 定义 |
| idl/api.thrift | API Service 增加 /api/v1/toolbox/config/list 定义 |
| api/rpc/common.go | 增加 API→Common 的 GetToolboxConfigListRPC 封装 |
| api/router/api/middleware.go | 生成的 middleware stub 增加 list 路由占位 |
| api/router/api/api.go | 注册 /api/v1/toolbox/config/list 路由 |
| api/pack/common.go | API ToolboxConfig pack 增加 config_id/student_id 字段映射 |
| api/model/model/model.go | API ToolboxConfig 生成模型补充字段 |
| api/model/api/api.go | API GetToolboxConfigList* 生成请求/响应与接口声明 |
| api/handler/api/common_service.go | 新增 HTTP Handler:GetToolboxConfigList |
| api/handler/api/common_service_test.go | 新增 HTTP Handler 单测覆盖成功/参数错误/RPC 错误 |
Files not reviewed (10)
- api/handler/api/common_service.go: Language not supported
- api/model/api/api.go: Language not supported
- api/model/model/model.go: Language not supported
- api/router/api/api.go: Language not supported
- api/router/api/middleware.go: Language not supported
- kitex_gen/common/common.go: Language not supported
- kitex_gen/common/commonservice/client.go: Language not supported
- kitex_gen/common/commonservice/commonservice.go: Language not supported
- kitex_gen/common/k-common.go: Language not supported
- kitex_gen/model/model.go: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+36
to
+49
| func (c *DBToolbox) ListToolboxConfigs(ctx context.Context, pageNum, pageSize int) ([]*model.ToolboxConfig, int64, error) { | ||
| var total int64 | ||
| if err := c.client.WithContext(ctx).Table(constants.ToolboxConfigTableName).Count(&total).Error; err != nil { | ||
| return nil, 0, errno.NewErrNo(errno.InternalDatabaseErrorCode, fmt.Sprintf("dal.ListToolboxConfigs count error: %v", err)) | ||
| } | ||
|
|
||
| toolboxConfigs := make([]*model.ToolboxConfig, 0) | ||
| offset := (pageNum - 1) * pageSize | ||
| if err := c.client.WithContext(ctx). | ||
| Table(constants.ToolboxConfigTableName). | ||
| Order("id DESC"). | ||
| Limit(pageSize). | ||
| Offset(offset). | ||
| Find(&toolboxConfigs).Error; err != nil { |
Comment on lines
+195
to
+198
| resp := new(api.GetToolboxConfigListResponse) | ||
| resp.Config = pack.BuildToolboxConfigs(configs) | ||
| resp.Total = total | ||
| pack.RespList(c, resp) |
renbaoshuo
reviewed
May 16, 2026
| return r, nil | ||
| } | ||
|
|
||
| func (s *CommonServiceImpl) GetToolboxConfigList(ctx context.Context, req *common.GetToolboxConfigListRequest) (r *common.GetToolboxConfigListResponse, err error) { |
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.
自查 PR 结构
PR 标题符合这个格式: <type>(optional scope): <description>
此 PR 标题的描述以用户为导向,足够清晰,其他人可以理解。
我已经对所有 commit 提供了签名(GPG 密钥签名、SSH 密钥签名)
这个 PR 属于强制变更/破坏性更改
这个 PR 的类型是什么?
feat
这个 PR 做了什么 / 我们为什么需要这个 PR?
新增获取工具箱云配置列表接口
(可选)这个 PR 解决了哪个/些 issue?
对 Reviewer 预留的一些提醒
有加分页和鉴权