34 lines
799 B
Go
34 lines
799 B
Go
|
package server
|
||
|
|
||
|
import (
|
||
|
"git.solsynth.dev/hydrogen/messaging/pkg/database"
|
||
|
"git.solsynth.dev/hydrogen/messaging/pkg/models"
|
||
|
"github.com/gofiber/fiber/v2"
|
||
|
)
|
||
|
|
||
|
func getUserinfo(c *fiber.Ctx) error {
|
||
|
user := c.Locals("principal").(models.Account)
|
||
|
|
||
|
var data models.Account
|
||
|
if err := database.C.
|
||
|
Where(&models.Account{BaseModel: models.BaseModel{ID: user.ID}}).
|
||
|
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.
|
||
|
Where(&models.Account{Name: accountId}).
|
||
|
First(&data).Error; err != nil {
|
||
|
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||
|
}
|
||
|
|
||
|
return c.JSON(data)
|
||
|
}
|