Conversation
Walkthrough该PR在campusapis/staff/v1/campus.proto中新增了ListFitnessScores RPC方法及ListFitnessScoresResponse消息类型,用于查询已保存的体测成绩列表。同步更新了Swagger文档,定义了两个新的GET端点及响应模式。 Changes
估计代码审查工作量🎯 2 (Simple) | ⏱️ ~10 minutes 可能相关的PR
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
campusapis/staff/v1/campus.proto (1)
1092-1097:ListFitnessScoresResponse缺少分页字段返回体中无
total/page_token等分页字段。当前场景下单个学生的体测记录数量有限,暂时影响不大,但若未来扩展为管理员批量查询场景,响应将无法分页。建议在响应消息中预留分页字段(如int32 total),以便后续扩展。🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@campusapis/staff/v1/campus.proto` around lines 1092 - 1097, The ListFitnessScoresResponse message currently lacks pagination fields; update the ListFitnessScoresResponse protobuf to include pagination placeholders (for example add an int32 total and a string next_page_token or page_token) alongside the existing error, msg, and repeated FitnessScore data so responses can support paging in future admin/bulk queries; after adding the fields to the ListFitnessScoresResponse message, run the proto codegen to regenerate stubs and adjust any server/client handlers that construct or parse ListFitnessScoresResponse.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@campusapis/staff/v1/campus.proto`:
- Around line 285-293: The ListFitnessScores RPC currently takes
google.protobuf.Empty so callers cannot filter results; add a dedicated request
message (e.g., ListFitnessScoresRequest) with optional fields school_year,
semester, and staff_id, update the rpc signature from
ListFitnessScores(google.protobuf.Empty) to
ListFitnessScores(ListFitnessScoresRequest), and update the google.api.http get
binding(s) to reference the new request (preserving existing
additional_bindings) so callers can filter server-side while keeping fields
optional for forward compatibility.
---
Nitpick comments:
In `@campusapis/staff/v1/campus.proto`:
- Around line 1092-1097: The ListFitnessScoresResponse message currently lacks
pagination fields; update the ListFitnessScoresResponse protobuf to include
pagination placeholders (for example add an int32 total and a string
next_page_token or page_token) alongside the existing error, msg, and repeated
FitnessScore data so responses can support paging in future admin/bulk queries;
after adding the fields to the ListFitnessScoresResponse message, run the proto
codegen to regenerate stubs and adjust any server/client handlers that construct
or parse ListFitnessScoresResponse.
| //查询已保存体测成绩列表 | ||
| rpc ListFitnessScores(google.protobuf.Empty) returns (ListFitnessScoresResponse) { | ||
| option (google.api.http) = { | ||
| get: "/staff/v1/fitness/score" | ||
| additional_bindings { | ||
| get: "/fitness/score" | ||
| } | ||
| }; | ||
| } |
There was a problem hiding this comment.
缺少过滤参数,建议引入专用请求消息
当前 RPC 使用 google.protobuf.Empty 作为请求类型,调用方无法按 schoolYear、semester 或 staffId 在 API 层面进行过滤。与该文件中其他成绩类接口(如 GetStudentGrade、GetStudentExam、GetStudentRewards)统一使用带 schoolYear/semester 参数的请求消息不同,此接口只能一次性返回认证用户所有学期的全部体测成绩,调用方需在客户端自行过滤,带来不必要的网络开销。
建议新增专用请求消息并将字段设为可选,以保持向前兼容:
♻️ 建议重构:引入可选过滤参数
- //查询已保存体测成绩列表
- rpc ListFitnessScores(google.protobuf.Empty) returns (ListFitnessScoresResponse) {
+ //查询已保存体测成绩列表
+ rpc ListFitnessScores(ListFitnessScoresRequest) returns (ListFitnessScoresResponse) {
option (google.api.http) = {
get: "/staff/v1/fitness/score"
additional_bindings {
get: "/fitness/score"
}
};
}在消息定义区补充:
+// ListFitnessScoresRequest 查询体测成绩列表请求
+message ListFitnessScoresRequest {
+ // 学年,可选,例:2021
+ string schoolYear = 1;
+ // 学期,可选,枚举:第一学期 | 第二学期
+ string semester = 2;
+}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@campusapis/staff/v1/campus.proto` around lines 285 - 293, The
ListFitnessScores RPC currently takes google.protobuf.Empty so callers cannot
filter results; add a dedicated request message (e.g., ListFitnessScoresRequest)
with optional fields school_year, semester, and staff_id, update the rpc
signature from ListFitnessScores(google.protobuf.Empty) to
ListFitnessScores(ListFitnessScoresRequest), and update the google.api.http get
binding(s) to reference the new request (preserving existing
additional_bindings) so callers can filter server-side while keeping fields
optional for forward compatibility.
Summary by CodeRabbit
新功能