Skip to content

feat: fitnessGradeStorage#36

Merged
Jiahe114514 merged 1 commit intomainfrom
feat/fitnessGradeStorage
Feb 23, 2026
Merged

feat: fitnessGradeStorage#36
Jiahe114514 merged 1 commit intomainfrom
feat/fitnessGradeStorage

Conversation

@Jiahe114514
Copy link
Contributor

@Jiahe114514 Jiahe114514 commented Feb 23, 2026

Summary by CodeRabbit

新功能

  • 新增体测成绩查询 API。可通过 HTTP GET 请求调用两个新的 API 端点(/staff/v1/fitness/score 和 /fitness/score)来查询和检索已保存的体测成绩列表。新接口返回结构化响应,包含查询执行状态码、消息描述以及完整的体测成绩数据列表。两个端点功能一致,提供多种访问路径选择。

@coderabbitai
Copy link

coderabbitai bot commented Feb 23, 2026

Walkthrough

该PR在campusapis/staff/v1/campus.proto中新增了ListFitnessScores RPC方法及ListFitnessScoresResponse消息类型,用于查询已保存的体测成绩列表。同步更新了Swagger文档,定义了两个新的GET端点及响应模式。

Changes

Cohort / File(s) Summary
Proto服务定义
campusapis/staff/v1/campus.proto
新增ListFitnessScores RPC方法,支持通过HTTP GET /staff/v1/fitness/score和/fitness/score路由访问。新增ListFitnessScoresResponse消息,包含error、msg和data字段,用于返回FitnessScore列表。
Swagger API文档
docs/swagger/campusapis/staff/v1/campus.swagger.json
添加两个新的GET端点(/fitness/score和/staff/v1/fitness/score),分别对应operationId CampusService_ListFitnessScores2和CampusService_ListFitnessScores。新增v1ListFitnessScoresResponse定义,包含错误状态、消息和体测成绩数组数据。

估计代码审查工作量

🎯 2 (Simple) | ⏱️ ~10 minutes

可能相关的PR

  • chore: fitness data storage #32 — 该PR的ListFitnessScores RPC和ListFitnessScoresResponse消息与相关PR的体测成绩查询RPC和FitnessScore消息定义相辅相成,两者均修改CampusService和/fitness/score API接口。

Poem

🐰 体测成绩放心查,新端点为你开花,
列表响应数据齐,GET请求轻轻拿,
Proto与Swagger相映,API路径在闪耀!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR标题「fitnessGradeStorage」与实际变更内容相符,增加了体测成绩列表查询的RPC方法和响应消息。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/fitnessGradeStorage

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines +285 to +293
//查询已保存体测成绩列表
rpc ListFitnessScores(google.protobuf.Empty) returns (ListFitnessScoresResponse) {
option (google.api.http) = {
get: "/staff/v1/fitness/score"
additional_bindings {
get: "/fitness/score"
}
};
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

缺少过滤参数,建议引入专用请求消息

当前 RPC 使用 google.protobuf.Empty 作为请求类型,调用方无法按 schoolYearsemesterstaffId 在 API 层面进行过滤。与该文件中其他成绩类接口(如 GetStudentGradeGetStudentExamGetStudentRewards)统一使用带 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.

@Jiahe114514 Jiahe114514 merged commit 2f7cb17 into main Feb 23, 2026
2 checks passed
Jiahe114514 pushed a commit that referenced this pull request Feb 23, 2026
This reverts commit 2f7cb17, reversing
changes made to 14e2f21.
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.

1 participant