♻️ Brand new user center
This commit is contained in:
@ -76,11 +76,11 @@ func editUserinfo(c *fiber.Ctx) error {
|
||||
user := c.Locals("principal").(models.Account)
|
||||
|
||||
var data struct {
|
||||
Nick string `json:"nick" validate:"required,min=4,max=24"`
|
||||
FirstName string `json:"first_name"`
|
||||
MiddleName string `json:"middle_name"`
|
||||
LastName string `json:"last_name"`
|
||||
Birthday time.Time `json:"birthday"`
|
||||
Nick string `json:"nick" validate:"required,min=4,max=24"`
|
||||
Description string `json:"description"`
|
||||
FirstName string `json:"first_name"`
|
||||
LastName string `json:"last_name"`
|
||||
Birthday time.Time `json:"birthday"`
|
||||
}
|
||||
|
||||
if err := BindAndValidate(c, &data); err != nil {
|
||||
@ -96,8 +96,8 @@ func editUserinfo(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
account.Nick = data.Nick
|
||||
account.Description = data.Description
|
||||
account.Profile.FirstName = data.FirstName
|
||||
account.Profile.MiddleName = data.MiddleName
|
||||
account.Profile.LastName = data.LastName
|
||||
account.Profile.Birthday = &data.Birthday
|
||||
|
||||
|
@ -14,17 +14,21 @@ func getNotifications(c *fiber.Ctx) error {
|
||||
take := c.QueryInt("take", 0)
|
||||
offset := c.QueryInt("offset", 0)
|
||||
|
||||
only_unread := c.QueryBool("only_unread", true)
|
||||
|
||||
tx := database.C.Where(&models.Notification{RecipientID: user.ID}).Model(&models.Notification{})
|
||||
if only_unread {
|
||||
tx = tx.Where("read_at IS NULL")
|
||||
}
|
||||
|
||||
var count int64
|
||||
var notifications []models.Notification
|
||||
if err := database.C.
|
||||
Where(&models.Notification{RecipientID: user.ID}).
|
||||
Model(&models.Notification{}).
|
||||
if err := tx.
|
||||
Count(&count).Error; err != nil {
|
||||
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||||
}
|
||||
|
||||
if err := database.C.
|
||||
Where(&models.Notification{RecipientID: user.ID}).
|
||||
if err := tx.
|
||||
Limit(take).
|
||||
Offset(offset).
|
||||
Order("read_at desc").
|
||||
|
Reference in New Issue
Block a user