From 802873c40120f3dfc85eebea6252436a7e1b02ed Mon Sep 17 00:00:00 2001 From: rogerogers Date: Sat, 27 Jan 2024 13:43:41 +0800 Subject: [PATCH] fix: pass context Signed-off-by: rogerogers --- easy_note/cmd/api/hertz_handler/demoapi/api_service.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/easy_note/cmd/api/hertz_handler/demoapi/api_service.go b/easy_note/cmd/api/hertz_handler/demoapi/api_service.go index 67ef038d..b4fccea8 100644 --- a/easy_note/cmd/api/hertz_handler/demoapi/api_service.go +++ b/easy_note/cmd/api/hertz_handler/demoapi/api_service.go @@ -41,7 +41,7 @@ func CreateUser(ctx context.Context, c *app.RequestContext) { SendResponse(c, errno.ConvertErr(err), nil) return } - err = rpc.CreateUser(context.Background(), &demouser.CreateUserRequest{ + err = rpc.CreateUser(ctx, &demouser.CreateUserRequest{ Username: req.Username, Password: req.Password, }) @@ -69,7 +69,7 @@ func CreateNote(ctx context.Context, c *app.RequestContext) { return } v, _ := c.Get(consts.IdentityKey) - err = rpc.CreateNote(context.Background(), &demonote.CreateNoteRequest{ + err = rpc.CreateNote(ctx, &demonote.CreateNoteRequest{ Title: req.Title, Content: req.Content, UserId: v.(*demoapi.User).UserID, @@ -92,7 +92,7 @@ func QueryNote(ctx context.Context, c *app.RequestContext) { return } v, _ := c.Get(consts.IdentityKey) - notes, total, err := rpc.QueryNotes(context.Background(), &demonote.QueryNoteRequest{ + notes, total, err := rpc.QueryNotes(ctx, &demonote.QueryNoteRequest{ UserId: v.(*demoapi.User).UserID, SearchKey: req.SearchKey, Offset: req.Offset, @@ -119,7 +119,7 @@ func UpdateNote(ctx context.Context, c *app.RequestContext) { return } v, _ := c.Get(consts.IdentityKey) - err = rpc.UpdateNote(context.Background(), &demonote.UpdateNoteRequest{ + err = rpc.UpdateNote(ctx, &demonote.UpdateNoteRequest{ NoteId: req.NoteID, UserId: v.(*demoapi.User).UserID, Title: req.Title, @@ -143,7 +143,7 @@ func DeleteNote(ctx context.Context, c *app.RequestContext) { return } v, _ := c.Get(consts.IdentityKey) - err = rpc.DeleteNote(context.Background(), &demonote.DeleteNoteRequest{ + err = rpc.DeleteNote(ctx, &demonote.DeleteNoteRequest{ NoteId: req.NoteID, UserId: v.(*demoapi.User).UserID, })