2024-06-22 10:05:41 +00:00
|
|
|
package api
|
2024-03-26 15:05:13 +00:00
|
|
|
|
|
|
|
import (
|
2024-09-11 15:54:18 +00:00
|
|
|
"git.solsynth.dev/hydrogen/dealer/pkg/hyper"
|
2024-06-22 10:05:41 +00:00
|
|
|
"git.solsynth.dev/hydrogen/messaging/pkg/internal/database"
|
2024-06-22 10:29:41 +00:00
|
|
|
"git.solsynth.dev/hydrogen/messaging/pkg/internal/gap"
|
2024-06-22 10:05:41 +00:00
|
|
|
"git.solsynth.dev/hydrogen/messaging/pkg/internal/models"
|
2024-03-26 15:05:13 +00:00
|
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
func getUserinfo(c *fiber.Ctx) error {
|
2024-06-22 10:29:41 +00:00
|
|
|
if err := gap.H.EnsureAuthenticated(c); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2024-06-22 12:15:01 +00:00
|
|
|
user := c.Locals("user").(models.Account)
|
2024-03-26 15:05:13 +00:00
|
|
|
|
|
|
|
var data models.Account
|
|
|
|
if err := database.C.
|
2024-09-11 15:54:18 +00:00
|
|
|
Where(&hyper.BaseModel{ID: user.ID}).
|
2024-03-26 15:05:13 +00:00
|
|
|
First(&data).Error; err != nil {
|
|
|
|
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
return c.JSON(data)
|
|
|
|
}
|
|
|
|
|
|
|
|
func getOthersInfo(c *fiber.Ctx) error {
|
|
|
|
accountId := c.Params("accountId")
|
|
|
|
|
|
|
|
var data models.Account
|
|
|
|
if err := database.C.
|
2024-09-11 15:54:18 +00:00
|
|
|
Where(&hyper.BaseUser{Name: accountId}).
|
2024-03-26 15:05:13 +00:00
|
|
|
First(&data).Error; err != nil {
|
|
|
|
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
return c.JSON(data)
|
|
|
|
}
|