-
Notifications
You must be signed in to change notification settings - Fork 5
Feat/pe calc #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/pe calc #30
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,133 @@ | ||||||||||||||||||||||||||||||||||||
| syntax = "proto3"; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| package campusapis.fitness.v1; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| import "google/api/annotations.proto"; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| option go_package = "./campusapis/fitness/v1"; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // 体测成绩服务 | ||||||||||||||||||||||||||||||||||||
| service FitnessService { | ||||||||||||||||||||||||||||||||||||
| // 新增或更新体测成绩 | ||||||||||||||||||||||||||||||||||||
| rpc StoreFitnessScore(StoreFitnessScoreRequest) returns (StoreFitnessScoreResponse) { | ||||||||||||||||||||||||||||||||||||
| option (google.api.http) = { | ||||||||||||||||||||||||||||||||||||
| post: "/fitness/v1/score" | ||||||||||||||||||||||||||||||||||||
| body: "*" | ||||||||||||||||||||||||||||||||||||
| additional_bindings { | ||||||||||||||||||||||||||||||||||||
| post: "/fitness/score" | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: find . -name "fitness.proto" -type fRepository: hduhelp/api_open_sdk Length of output: 101 🏁 Script executed: cat -n ./campusapis/fitness/v1/fitness.protoRepository: hduhelp/api_open_sdk Length of output: 3889 additional_bindings 缺少 body 导致请求体映射错误 StoreFitnessScore 和 UpdateFitnessScore 的 additional_bindings 均未声明 建议修复 rpc StoreFitnessScore(StoreFitnessScoreRequest) returns (StoreFitnessScoreResponse) {
option (google.api.http) = {
post: "/fitness/v1/score"
body: "*"
additional_bindings {
post: "/fitness/score"
+ body: "*"
}
};
}
rpc UpdateFitnessScore(UpdateFitnessScoreRequest) returns (UpdateFitnessScoreResponse) {
option (google.api.http) = {
patch: "/fitness/v1/score"
body: "*"
additional_bindings {
patch: "/fitness/score"
+ body: "*"
}
};
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // 更新体测成绩 | ||||||||||||||||||||||||||||||||||||
| rpc UpdateFitnessScore(UpdateFitnessScoreRequest) returns (UpdateFitnessScoreResponse) { | ||||||||||||||||||||||||||||||||||||
| option (google.api.http) = { | ||||||||||||||||||||||||||||||||||||
| patch: "/fitness/v1/score" | ||||||||||||||||||||||||||||||||||||
| body: "*" | ||||||||||||||||||||||||||||||||||||
| additional_bindings { | ||||||||||||||||||||||||||||||||||||
| patch: "/fitness/score" | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PATCH 请求缺少字段 presence,无法安全做部分更新
Also applies to: 72-91 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // 删除体测成绩 | ||||||||||||||||||||||||||||||||||||
| rpc DeleteFitnessScore(DeleteFitnessScoreRequest) returns (DeleteFitnessScoreResponse) { | ||||||||||||||||||||||||||||||||||||
| option (google.api.http) = { | ||||||||||||||||||||||||||||||||||||
| delete: "/fitness/v1/score" | ||||||||||||||||||||||||||||||||||||
| additional_bindings { | ||||||||||||||||||||||||||||||||||||
| delete: "/fitness/score" | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // StoreFitnessScoreRequest 新增或更新体测成绩请求 | ||||||||||||||||||||||||||||||||||||
| message StoreFitnessScoreRequest { | ||||||||||||||||||||||||||||||||||||
| string staff_id = 1; | ||||||||||||||||||||||||||||||||||||
| string school_year = 2; | ||||||||||||||||||||||||||||||||||||
| int32 semester = 3; | ||||||||||||||||||||||||||||||||||||
| string gender = 4; | ||||||||||||||||||||||||||||||||||||
| int32 grade = 5; | ||||||||||||||||||||||||||||||||||||
| float height = 6; | ||||||||||||||||||||||||||||||||||||
| float weight = 7; | ||||||||||||||||||||||||||||||||||||
| float bmi = 8; | ||||||||||||||||||||||||||||||||||||
| float run_50m = 9; | ||||||||||||||||||||||||||||||||||||
| float standing_long_jump = 10; | ||||||||||||||||||||||||||||||||||||
| float sit_and_reach = 11; | ||||||||||||||||||||||||||||||||||||
| float run_800m = 12; | ||||||||||||||||||||||||||||||||||||
| float run_1000m = 13; | ||||||||||||||||||||||||||||||||||||
| int32 sit_ups = 14; | ||||||||||||||||||||||||||||||||||||
| int32 pull_ups = 15; | ||||||||||||||||||||||||||||||||||||
| int32 lung_capacity = 16; | ||||||||||||||||||||||||||||||||||||
| float total_score = 17; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // StoreFitnessScoreResponse 新增或更新体测成绩响应 | ||||||||||||||||||||||||||||||||||||
| message StoreFitnessScoreResponse { | ||||||||||||||||||||||||||||||||||||
| int32 error = 1; | ||||||||||||||||||||||||||||||||||||
| string msg = 2; | ||||||||||||||||||||||||||||||||||||
| FitnessScore data = 3; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // UpdateFitnessScoreRequest 更新体测成绩请求 | ||||||||||||||||||||||||||||||||||||
| message UpdateFitnessScoreRequest { | ||||||||||||||||||||||||||||||||||||
| string staff_id = 1; | ||||||||||||||||||||||||||||||||||||
| string school_year = 2; | ||||||||||||||||||||||||||||||||||||
| int32 semester = 3; | ||||||||||||||||||||||||||||||||||||
| string gender = 4; | ||||||||||||||||||||||||||||||||||||
| int32 grade = 5; | ||||||||||||||||||||||||||||||||||||
| float height = 6; | ||||||||||||||||||||||||||||||||||||
| float weight = 7; | ||||||||||||||||||||||||||||||||||||
| float bmi = 8; | ||||||||||||||||||||||||||||||||||||
| float run_50m = 9; | ||||||||||||||||||||||||||||||||||||
| float standing_long_jump = 10; | ||||||||||||||||||||||||||||||||||||
| float sit_and_reach = 11; | ||||||||||||||||||||||||||||||||||||
| float run_800m = 12; | ||||||||||||||||||||||||||||||||||||
| float run_1000m = 13; | ||||||||||||||||||||||||||||||||||||
| int32 sit_ups = 14; | ||||||||||||||||||||||||||||||||||||
| int32 pull_ups = 15; | ||||||||||||||||||||||||||||||||||||
| int32 lung_capacity = 16; | ||||||||||||||||||||||||||||||||||||
| float total_score = 17; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // UpdateFitnessScoreResponse 更新体测成绩响应 | ||||||||||||||||||||||||||||||||||||
| message UpdateFitnessScoreResponse { | ||||||||||||||||||||||||||||||||||||
| int32 error = 1; | ||||||||||||||||||||||||||||||||||||
| string msg = 2; | ||||||||||||||||||||||||||||||||||||
| FitnessScore data = 3; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // DeleteFitnessScoreRequest 删除体测成绩请求 | ||||||||||||||||||||||||||||||||||||
| message DeleteFitnessScoreRequest { | ||||||||||||||||||||||||||||||||||||
| string staff_id = 1; | ||||||||||||||||||||||||||||||||||||
| string school_year = 2; | ||||||||||||||||||||||||||||||||||||
| int32 semester = 3; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // DeleteFitnessScoreResponse 删除体测成绩响应 | ||||||||||||||||||||||||||||||||||||
| message DeleteFitnessScoreResponse { | ||||||||||||||||||||||||||||||||||||
| int32 error = 1; | ||||||||||||||||||||||||||||||||||||
| string msg = 2; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // FitnessScore 体测成绩信息 | ||||||||||||||||||||||||||||||||||||
| message FitnessScore { | ||||||||||||||||||||||||||||||||||||
| string staff_id = 1; | ||||||||||||||||||||||||||||||||||||
| string school_year = 2; | ||||||||||||||||||||||||||||||||||||
| int32 semester = 3; | ||||||||||||||||||||||||||||||||||||
| string gender = 4; | ||||||||||||||||||||||||||||||||||||
| int32 grade = 5; | ||||||||||||||||||||||||||||||||||||
| float height = 6; | ||||||||||||||||||||||||||||||||||||
| float weight = 7; | ||||||||||||||||||||||||||||||||||||
| float bmi = 8; | ||||||||||||||||||||||||||||||||||||
| float run_50m = 9; | ||||||||||||||||||||||||||||||||||||
| float standing_long_jump = 10; | ||||||||||||||||||||||||||||||||||||
| float sit_and_reach = 11; | ||||||||||||||||||||||||||||||||||||
| float run_800m = 12; | ||||||||||||||||||||||||||||||||||||
| float run_1000m = 13; | ||||||||||||||||||||||||||||||||||||
| int32 sit_ups = 14; | ||||||||||||||||||||||||||||||||||||
| int32 pull_ups = 15; | ||||||||||||||||||||||||||||||||||||
| int32 lung_capacity = 16; | ||||||||||||||||||||||||||||||||||||
| float total_score = 17; | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,16 @@ | ||
| package teachingv1 | ||
|
|
||
| import "github.com/hduhelp/api_open_sdk/campusapis/staff" | ||
| import ( | ||
| "github.com/hduhelp/api_open_sdk/campusapis/staff" | ||
| "github.com/hduhelp/api_open_sdk/schoolConst" | ||
| ) | ||
|
|
||
| func (x *Courses) ToGetScheduleResponse() *GetScheduleResponse { | ||
| return &GetScheduleResponse{ | ||
| Data: x.GetScheduleResponseCourse(), | ||
| Data: &ScheduleResponseData{ | ||
| Course: x.GetScheduleResponseCourse(), | ||
| SemesterStartTimestamp: schoolConst.SemesterStartTimestamp, | ||
| }, | ||
|
Comment on lines
+3
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ Verification inconclusiveScript executed: find . -type f -name "courses.go" | grep -E "teaching/v1|campusapis" | head -5Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: git ls-files | grep -E "courses\.go|schoolConst" | head -20Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: find . -type f -name "*.go" | grep -v vendor | head -30Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: cat -n ./campusapis/teaching/v1/courses.go | head -50Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: cat -n ./schoolConst/const.go | head -100Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: rg "GetScheduleRequest" --type go | head -20Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: rg "ToGetScheduleResponse" --type go -B 2 -A 2 | head -40Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: rg "SchoolYear\|Semester" --type go | grep -E "\.SchoolYear|\.Semester|x\." | head -30Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk Script executed: rg "type GetScheduleRequest struct" --type go -A 15Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: rg "GetSchedule.*Request" --type go -A 10 | head -50Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: grep -n "SchoolYear\|Semester" ./campusapis/teaching/v1/teaching.pb.go | head -30Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: rg "\.ToGetScheduleResponse\(\)" --type go -B 3 -A 3 | head -50Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk Script executed: rg "type ScheduleResponseData" --type go -A 10Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: rg "type Courses struct" --type go -A 15Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: rg "GetScheduleRequest" --type go -A 15 | grep -E "Semester|SchoolYear|Week" | head -20Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: cat -n ./campusapis/teaching/v1/teaching.pb.go | sed -n '30,50p'Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: rg "func.*GetSchedule\(" --type go -B 2 -A 20 | head -100Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: rg "type CourseItem struct" --type go -A 20Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: rg "type SchoolYear" --type go -B 2 -A 10 | head -50Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: rg "ToGetScheduleResponse\(" --type go -B 5 -A 2Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: rg "type Semester struct" --type go -A 10 | head -30Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: rg "SemesterStartTimestamp" --type go | head -20Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: find . -type f -name "*.proto" | xargs grep -l "GetScheduleRequest\|GetScheduleResponse" 2>/dev/null | head -5Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: cat -n ./campusapis/teaching/v1/teaching.proto | grep -A 10 -B 10 "SemesterStartTimestamp\|GetScheduleRequest\|GetScheduleResponse" | head -80Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: rg "func.*GetSchedule" --type go -B 5 | grep -E "func|GetSchedule|Request|server" | head -40Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: find . -type f -name "*.go" -path "*/teaching/*" | xargs grep -l "GetScheduleRequest" | grep -v "pb.go" | grep -v "test"Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: rg "TeachingServiceServer" --type go -A 30 | grep -A 30 "GetSchedule.*Request" | head -60Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: grep -n "ToGetScheduleResponse\|\.GetSchedule\|TeachingServiceServer" ./campusapis/teaching/v1/teaching.pb.gw.go | head -30Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: find . -type f -name "*.go" -path "*/teaching/*" ! -name "*pb.go" ! -name "*test*" -exec grep -l "GetScheduleRequest\|GetScheduleResponse" {} \;Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: cat -n ./campusapis/teaching/v1/teaching.pb.gw.go | sed -n '52,75p'Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: Script executed: rg "server\.GetSchedule\|\.ToGetScheduleResponse" --type go -B 5 -A 10 | head -80Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk Script executed: find . -type f -name "*.go" ! -name "*pb*" ! -name "*test*" -exec grep -l "GetSchedule\|ToGetScheduleResponse" {} \; | head -10Repository: hduhelp/api_open_sdk Repository: hduhelp/api_open_sdk stdout: SemesterStartTimestamp 使用固定常量,查询其他学期时会返回错误的时间戳
🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: hduhelp/api_open_sdk
Length of output: 184
🌐 Web query:
Go modules proto go_package relative path import valid💡 Result:
Short answer: With Go modules you must use module-aware (fully qualified) Go import paths in proto go_package values or supply equivalent mappings to protoc. Relative import paths (./ or ../) in go_package are not valid in module mode.
Why and options:
References:
[1] Protobuf Go generated code guide — packages, go_package, paths/module flags.
[2] Discussion / Q&A: relative imports in protobuf + Go modules (StackOverflow + community guidance).
[3] protoc-gen-go / release notes and module/paths behavior.
🌐 Web query:
protobuf go_package option best practices Go modules💡 Result:
Short best-practices for option go_package when using Go modules
Always declare go_package inside the .proto. Use the full Go module import path (module path + package directory) so generated code has a stable import path. Example:
option go_package = "github.com/acme/project/api/proto/v1;apipb". [1][3]
Include an explicit package name after a semicolon when the directory tail is not the desired Go package identifier:
option go_package = "github.com/acme/project/api/proto/v1;apipb". [1][3]
Version your proto package paths for breaking changes (v1, v2…) consistent with Go module semantics (so import paths remain unique). [1][5]
Prefer a central module that publishes generated Go packages for widely‑shared protos rather than generating copies in many modules. This avoids duplicate protobuf descriptors and runtime global-registry conflicts. If you must generate in-repo, keep generated Go code in an internal/ package or a clearly isolated module. [1][2][5]
If you cannot edit upstream .proto files, map proto→Go import paths at generation time with protoc’s M flag (e.g. --go_opt=Mpath/to.proto=github.com/you/module/apipb). Prefer adding go_package upstream when possible. [1][4]
Pick unique proto package names (proto package and go package) — avoid generic names to prevent name collisions across repos. Coordinate with proto owners for a canonical go_package if the proto is shared. [1][2]
Don’t rely on implicit filesystem layout or GOPATH heuristics; be explicit in the .proto or with --go_opt mappings so builds are reproducible across modules/CI. [1][3]
Sources
go_package 相对路径在 Go modules 中无效,需修改为完整 import path
option go_package = "./campusapis/fitness/v1";中的相对路径不符合 Go modules 规范。protoc-gen-go 要求 go_package 使用完整的 Go import path(例如github.com/hduhelp/api_open_sdk/campusapis/fitness/v1),相对路径会导致生成的代码无法正常导入和使用。建议改为完整 module path + 可选别名的形式,如
module/path/fitness/v1;fitnessv1pb,并与仓库其他 proto 文件保持一致。🤖 Prompt for AI Agents