Skip to content

Commit

Permalink
refactor: clean unnecesssary ctx (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiuxia211 authored Jan 20, 2025
1 parent 12991c0 commit c5afa48
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 60 deletions.
8 changes: 0 additions & 8 deletions api/handler/api/academic_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ import (

"github.com/west2-online/fzuhelper-server/api/rpc"
"github.com/west2-online/fzuhelper-server/kitex_gen/academic"
"github.com/west2-online/fzuhelper-server/kitex_gen/model"
"github.com/west2-online/fzuhelper-server/pkg/base/login_data"
)

func TestGetPlan(t *testing.T) {
Expand Down Expand Up @@ -84,12 +82,6 @@ func TestGetPlan(t *testing.T) {
for _, tc := range testCases {
mockey.PatchConvey(tc.Name, t, func() {
// 模拟RPC调用
mockey.Mock(login_data.GetLoginData).To(func(ctx context.Context) (*model.LoginData, error) {
return &model.LoginData{
Id: "20250000102301000",
Cookies: "ASP",
}, nil
}).Build()
mockey.Mock(rpc.GetCultivatePlanRPC).To(func(ctx context.Context, req *academic.GetPlanRequest) (*[]byte, error) {
if tc.ExpectedError {
// 根据测试用例的不同,可以自定义返回不同的错误信息
Expand Down
5 changes: 0 additions & 5 deletions api/mw/get_header.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/west2-online/fzuhelper-server/api/pack"
"github.com/west2-online/fzuhelper-server/kitex_gen/model"
metainfoContext "github.com/west2-online/fzuhelper-server/pkg/base/context"
"github.com/west2-online/fzuhelper-server/pkg/base/login_data"
"github.com/west2-online/fzuhelper-server/pkg/errno"
)

Expand All @@ -38,10 +37,6 @@ func GetHeaderParams() app.HandlerFunc {
c.Abort()
return
}
ctx = login_data.NewContext(ctx, &model.LoginData{
Id: id,
Cookies: cookies,
})

// 实现规范化服务透传,不需要中间进行编解码
ctx = metainfoContext.WithLoginData(ctx, &model.LoginData{
Expand Down
4 changes: 3 additions & 1 deletion kitex_gen/course/course.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions kitex_gen/course/courseservice/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions kitex_gen/course/courseservice/courseservice.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions kitex_gen/course/courseservice/server.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion kitex_gen/model/model.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 0 additions & 45 deletions pkg/base/login_data/login_data.go

This file was deleted.

0 comments on commit c5afa48

Please sign in to comment.