More work on the new people search
This commit is contained in:
parent
fac4e695fc
commit
e6eec0dfaf
6 changed files with 337 additions and 121 deletions
|
|
@ -297,3 +297,25 @@ func FieldMoveDown(c *fiber.Ctx) error {
|
|||
|
||||
return c.Redirect("/admin/fields")
|
||||
}
|
||||
|
||||
func FieldJSON(c *fiber.Ctx) error {
|
||||
id := c.Params("id")
|
||||
|
||||
db, err := helpers.GetDatabase()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var field models.Field
|
||||
result := db.Preload("List").Preload("List.ListItems").Find(&field, "id = ?", id)
|
||||
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
|
||||
if result.RowsAffected < 1 {
|
||||
return fiber.NewError(fiber.StatusNotFound, "Not found")
|
||||
}
|
||||
|
||||
return c.JSON(field)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue