🐛 Fix fixes on listing attachments and improve performance
This commit is contained in:
parent
f91143ce9a
commit
168c089456
@ -18,12 +18,14 @@ func listAttachment(c *fiber.Ctx) error {
|
|||||||
|
|
||||||
tx := database.C
|
tx := database.C
|
||||||
|
|
||||||
|
if len(c.Query("author")) > 0 {
|
||||||
var author models.Account
|
var author models.Account
|
||||||
if err := database.C.Where("name = ?", c.Query("author")).Error; err != nil {
|
if err := database.C.Where("name = ?", c.Query("author")).First(&author).Error; err != nil {
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||||
} else {
|
} else {
|
||||||
tx = tx.Where("account_id = ?", author.ID)
|
tx = tx.Where("account_id = ?", author.ID)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if usage := strings.Split(c.Query("usage"), " "); len(usage) > 0 {
|
if usage := strings.Split(c.Query("usage"), " "); len(usage) > 0 {
|
||||||
tx = tx.Where("usage IN ?", usage)
|
tx = tx.Where("usage IN ?", usage)
|
||||||
|
Loading…
Reference in New Issue
Block a user