Conversation
Walkthrough向 CampusService 添加体测成绩相关三条 gRPC RPC(Store/Update/Delete)及对应消息类型,并在 Swagger 中新增两组 HTTP 路由(/fitness/score 与 /staff/v1/fitness/score)及相应 schema。文件中存在 FitnessScore 相关重复声明片段。 Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 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)
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: 3
🤖 Fix all issues with AI agents
In `@campusapis/staff/v1/campus.proto`:
- Around line 1017-1035: The new messages use snake_case and an inconsistent
semester type; update FitnessScoreRequest to use camelCase field names (staffId,
schoolYear, semester, gender, grade, height, weight, bmi, run50m,
standingLongJump, sitAndReach, run800m, run1000m, sitUps, pullUps, lungCapacity,
totalScore) and change the semester field type from int32 to string to match
existing requests (e.g., GetStudentExamRequest), and apply the exact same naming
and semester-type changes to DeleteFitnessScoreRequest and FitnessScore so all
three messages are consistent with the existing API style.
In `@docs/swagger/campusapis/staff/v1/campus.swagger.json`:
- Around line 67-87: 将删除接口的关键查询参数 staffId、schoolYear 和 semester 从 required:
false 改为 required: true,并在相应的接口输入校验层(如 proto 定义或 API
网关验证规则)添加必填检查以拒绝缺失任一参数的请求;定位到 swagger 参数定义中对应的 "staffId"、"schoolYear"、"semester"
三个条目并更新其 required 属性,同时在后端处理函数(校验入口的 handler)确保参数存在并返回明确的验证错误。
- Around line 49-230: The POST/PATCH endpoints under /fitness/score were
generated with query parameters because the proto RPCs StoreFitnessScore and
UpdateFitnessScore have additional_bindings without a body mapping; update the
proto definitions for StoreFitnessScore and UpdateFitnessScore to include body:
"*" inside each additional_bindings block (i.e., add body: "*" alongside post:
"/fitness/score" and patch: "/fitness/score" respectively) so gRPC-Gateway emits
request-body schemas for those routes, then regenerate the OpenAPI/Swagger
artifacts.
🧹 Nitpick comments (2)
campusapis/staff/v1/campus.proto (2)
260-280:StoreFitnessScore和UpdateFitnessScore语义重叠
StoreFitnessScore注释为"新增或更新",而UpdateFitnessScore注释为"更新"。这两个 RPC 功能重叠,可能导致 API 使用者困惑。建议:
- 如果
StoreFitnessScore是 upsert 操作,可以移除UpdateFitnessScore- 或者明确区分:
StoreFitnessScore仅用于新增,UpdateFitnessScore仅用于更新
1045-1049: 删除请求缺少必要字段说明
DeleteFitnessScoreRequest中的staff_id、school_year、semester是删除操作的关键标识字段,建议添加注释说明这些字段的作用和格式要求,与文件中其他消息的风格保持一致。
Summary by CodeRabbit
新功能
文档
✏️ Tip: You can customize this high-level summary in your review settings.