Skip to content

feat(toolbox): get toolbox config list api - #482

Merged
renbaoshuo merged 16 commits into
west2-online:mainfrom
155TuT:feat/get-toolbox-config-list
May 19, 2026
Merged

feat(toolbox): get toolbox config list api#482
renbaoshuo merged 16 commits into
west2-online:mainfrom
155TuT:feat/get-toolbox-config-list

Conversation

@155TuT

@155TuT 155TuT commented May 13, 2026

Copy link
Copy Markdown
Contributor

自查 PR 结构

  • PR 标题符合这个格式: <type>(optional scope): <description>

  • 此 PR 标题的描述以用户为导向,足够清晰,其他人可以理解。

  • 我已经对所有 commit 提供了签名(GPG 密钥签名、SSH 密钥签名)

  • 这个 PR 属于强制变更/破坏性更改

如果是,请在 PR 标题中添加 BREAKING CHANGE 前缀,并在 PR 描述中详细说明。

这个 PR 的类型是什么?

feat

这个 PR 做了什么 / 我们为什么需要这个 PR?

新增获取工具箱云配置列表接口

(可选)这个 PR 解决了哪个/些 issue?

对 Reviewer 预留的一些提醒

有加分页和鉴权

@155TuT
155TuT requested review from a team, jiuxia211, mutezebra, ozline and renbaoshuo as code owners May 13, 2026 15:16
@codecov

codecov Bot commented May 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.65517% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/common/service/get_toolbox_config_list.go 80.95% 2 Missing and 2 partials ⚠️
pkg/db/toolbox/get_configs.go 88.88% 1 Missing and 1 partial ⚠️
@@            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     
Flag Coverage Δ
unittest 63.18% <89.65%> (-0.63%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
api/handler/api/common_service.go 100.00% <100.00%> (ø)
pkg/db/toolbox/get_configs.go 69.56% <88.88%> (+69.56%) ⬆️
internal/common/service/get_toolbox_config_list.go 80.95% <80.95%> (ø)

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

新增一个带鉴权与分页的“工具箱云配置列表”获取接口,贯穿 IDL/Kitex 生成代码、Common RPC 服务实现、DAL 查询与 API 网关侧路由/Handler,并补充了对应单测,方便管理端按页查看配置明细(含 config_id、student_id)。

Changes:

  • 新增 DAL ListToolboxConfigs 与 CommonService GetToolboxConfigList(含分页归一化与鉴权)实现,并补充单测
  • 扩展 ToolboxConfig Thrift 模型字段(config_idstudent_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_idstudent_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)
Comment thread internal/common/handler.go Outdated
return r, nil
}

func (s *CommonServiceImpl) GetToolboxConfigList(ctx context.Context, req *common.GetToolboxConfigListRequest) (r *common.GetToolboxConfigListResponse, err error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

太长,本地跑 make verify 了没有

@renbaoshuo renbaoshuo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM,晚点更新下 apifox 文档后合并

@renbaoshuo
renbaoshuo merged commit 265b003 into west2-online:main May 19, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants