Wallet/pkg/internal/server/api/wallet_api.go

23 lines
571 B
Go
Raw Normal View History

2025-01-25 18:33:11 +08:00
package api
import (
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"git.solsynth.dev/hypernet/wallet/pkg/internal/database"
"git.solsynth.dev/hypernet/wallet/pkg/internal/models"
"github.com/gofiber/fiber/v2"
)
func getMyWallet(c *fiber.Ctx) error {
if err := sec.EnsureAuthenticated(c); err != nil {
return err
}
user := c.Locals("user").(*sec.UserInfo)
var wallet models.Wallet
if err := database.C.Where("account_id = ?", user.ID).First(&wallet).Error; err != nil {
return fiber.NewError(fiber.StatusNotFound, err.Error())
}
return c.JSON(wallet)
}