23 lines
571 B
Go
23 lines
571 B
Go
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)
|
|
}
|