From 52d6d17bf6e7eec11348e2a9d6017f4c4721b33c Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 29 Jan 2025 14:01:34 +0800 Subject: [PATCH] :bug: Fix panics --- pkg/internal/server/api/index.go | 4 ++-- pkg/internal/server/api/transaction_api.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/internal/server/api/index.go b/pkg/internal/server/api/index.go index 6cf84df..a1346c6 100644 --- a/pkg/internal/server/api/index.go +++ b/pkg/internal/server/api/index.go @@ -7,13 +7,13 @@ import ( func MapAPIs(app *fiber.App, baseURL string) { api := app.Group(baseURL).Name("API") { - wallet := api.Group("/wallet").Name("Wallet API") + wallet := api.Group("/wallets").Name("Wallet API") { wallet.Post("/me", createWallet) wallet.Get("/me", getMyWallet) } - transaction := api.Group("/transaction").Name("Transaction API") + transaction := api.Group("/transactions").Name("Transaction API") { transaction.Get("/me", getTransaction) transaction.Get("/:id", getTransactionByID) diff --git a/pkg/internal/server/api/transaction_api.go b/pkg/internal/server/api/transaction_api.go index bcbcdd8..368b883 100644 --- a/pkg/internal/server/api/transaction_api.go +++ b/pkg/internal/server/api/transaction_api.go @@ -14,7 +14,7 @@ func getTransaction(c *fiber.Ctx) error { if err := sec.EnsureAuthenticated(c); err != nil { return err } - user := c.Locals("user").(*sec.UserInfo) + user := c.Locals("nex_user").(*sec.UserInfo) var wallet models.Wallet if err := database.C.Where("account_id = ?", user.ID).First(&wallet).Error; err != nil { @@ -46,7 +46,7 @@ func getTransactionByID(c *fiber.Ctx) error { if err := sec.EnsureAuthenticated(c); err != nil { return err } - user := c.Locals("user").(*sec.UserInfo) + user := c.Locals("nex_user").(*sec.UserInfo) var transaction models.Transaction if err := database.C.Where("id = ?", id).