🐛 Fix querystring naming issue

This commit is contained in:
LittleSheep 2024-07-26 16:15:08 +08:00
parent ee62f3bef8
commit 37aa69e6ca
2 changed files with 5 additions and 4 deletions

View File

@ -46,9 +46,9 @@ func listPost(c *fiber.Ctx) error {
}
}
if len(c.Query("authorId")) > 0 {
if len(c.Query("author")) > 0 {
var author models.Account
if err := database.C.Where(&models.Account{Name: c.Query("authorId")}).First(&author).Error; err != nil {
if err := database.C.Where(&models.Account{Name: c.Query("author")}).First(&author).Error; err != nil {
return fiber.NewError(fiber.StatusNotFound, err.Error())
}
tx = tx.Where("author_id = ?", author.ID)

View File

@ -2,6 +2,7 @@ package api
import (
"fmt"
"git.solsynth.dev/hydrogen/interactive/pkg/internal/database"
"git.solsynth.dev/hydrogen/interactive/pkg/internal/models"
"git.solsynth.dev/hydrogen/interactive/pkg/internal/services"
@ -20,9 +21,9 @@ func listPostReplies(c *fiber.Ctx) error {
tx = services.FilterPostReply(tx, post.ID)
}
if len(c.Query("authorId")) > 0 {
if len(c.Query("author")) > 0 {
var author models.Account
if err := database.C.Where(&models.Account{Name: c.Query("authorId")}).First(&author).Error; err != nil {
if err := database.C.Where(&models.Account{Name: c.Query("author")}).First(&author).Error; err != nil {
return fiber.NewError(fiber.StatusNotFound, err.Error())
}
tx = tx.Where("author_id = ?", author.ID)