✨ Allow filter post via tags
This commit is contained in:
parent
9dd03e0734
commit
2c138d06ee
@ -47,6 +47,10 @@ func universalPostFilter(c *fiber.Ctx, tx *gorm.DB) (*gorm.DB, error) {
|
|||||||
tx = services.FilterPostWithTag(tx, c.Query("tag"))
|
tx = services.FilterPostWithTag(tx, c.Query("tag"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(c.Query("type")) > 0 {
|
||||||
|
tx = services.FilterPostWithType(tx, c.Query("type"))
|
||||||
|
}
|
||||||
|
|
||||||
return tx, nil
|
return tx, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,6 +68,10 @@ func FilterPostWithTag(tx *gorm.DB, alias string) *gorm.DB {
|
|||||||
Where("tags.alias = ?", alias)
|
Where("tags.alias = ?", alias)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func FilterPostWithType(tx *gorm.DB, t string) *gorm.DB {
|
||||||
|
return tx.Where("type = ?", t)
|
||||||
|
}
|
||||||
|
|
||||||
func FilterPostWithRealm(tx *gorm.DB, id uint) *gorm.DB {
|
func FilterPostWithRealm(tx *gorm.DB, id uint) *gorm.DB {
|
||||||
if id > 0 {
|
if id > 0 {
|
||||||
return tx.Where("realm_id = ?", id)
|
return tx.Where("realm_id = ?", id)
|
||||||
|
Loading…
Reference in New Issue
Block a user