Upgraded to the latest go-web-kit.

This commit is contained in:
Zed A. Shaw 2025-11-03 14:09:57 -05:00
parent 051474bdc9
commit 41f31a621f
14 changed files with 124 additions and 142 deletions

View file

@ -9,6 +9,7 @@ import (
)
func SearchTable(search string, table string, the_type reflect.Type, limit uint64, page uint64) ([]any, error) {
var results []any
like := fmt.Sprint("%", search, "%")
@ -132,6 +133,7 @@ func Update(table string, value reflect.Value) error {
builder = builder.Where(sq.Eq{"id": value.FieldByName("Id").Interface()})
sql_query, args, err := builder.ToSql()
fmt.Println("UPDATE QUERY", sql_query, args)
if err != nil { return err}
_, err = data.DB.Exec(sql_query, args...)

View file

@ -6,12 +6,12 @@ import (
"fmt"
"github.com/gofiber/fiber/v2"
"MY/webapp/data"
"MY/webapp/api"
. "MY/webapp/common"
"MY/webapp/auth"
)
func GetApiTableIndex(c *fiber.Ctx) error {
_, err := api.CheckAuthed(c, true)
_, err := auth.Check(c, true)
if err != nil { return c.Redirect("/") }
var tables []string
@ -24,7 +24,7 @@ func GetApiTableIndex(c *fiber.Ctx) error {
}
func GetApiSelectAll(c *fiber.Ctx) error {
_, err := api.CheckAuthed(c, true)
_, err := auth.Check(c, true)
if err != nil { return c.Redirect("/") }
table := c.Params("table")
@ -50,14 +50,14 @@ func GetApiSelectAll(c *fiber.Ctx) error {
}
func GetPageSelectAll(c *fiber.Ctx) error {
_, err := api.CheckAuthed(c, true)
_, err := auth.Check(c, true)
if err != nil { return c.Redirect("/") }
return c.Render("admin/table/contents", fiber.Map{"Table": c.Params("table")})
}
func GetApiSelectOne(c *fiber.Ctx) error {
_, err := api.CheckAuthed(c, true)
_, err := auth.Check(c, true)
if err != nil { return c.Redirect("/") }
table := c.Params("table")
@ -73,7 +73,7 @@ func GetApiSelectOne(c *fiber.Ctx) error {
}
func GetPageSelectOne(c *fiber.Ctx) error {
_, err := api.CheckAuthed(c, true)
_, err := auth.Check(c, true)
if err != nil { return c.Redirect("/") }
table := c.Params("table")
@ -87,7 +87,7 @@ func GetPageSelectOne(c *fiber.Ctx) error {
}
func PostApiUpdate(c *fiber.Ctx) error {
_, err := api.CheckAuthed(c, true)
_, err := auth.Check(c, true)
if err != nil { return c.Redirect("/") }
table := c.Params("table")
@ -102,7 +102,7 @@ func PostApiUpdate(c *fiber.Ctx) error {
}
func GetPageInsert(c *fiber.Ctx) error {
_, err := api.CheckAuthed(c, true)
_, err := auth.Check(c, true)
if err != nil { return c.Redirect("/") }
table := c.Params("table")
@ -110,7 +110,7 @@ func GetPageInsert(c *fiber.Ctx) error {
}
func GetApiInsert(c *fiber.Ctx) error {
_, err := api.CheckAuthed(c, true)
_, err := auth.Check(c, true)
if err != nil { return c.Redirect("/") }
table := c.Params("table")
@ -120,7 +120,7 @@ func GetApiInsert(c *fiber.Ctx) error {
}
func PostApiInsert(c *fiber.Ctx) error {
_, err := api.CheckAuthed(c, true)
_, err := auth.Check(c, true)
if err != nil { return c.Redirect("/") }
table := c.Params("table")
@ -136,7 +136,7 @@ func PostApiInsert(c *fiber.Ctx) error {
}
func DeleteApi(c *fiber.Ctx) error {
_, err := api.CheckAuthed(c, true)
_, err := auth.Check(c, true)
if err != nil { return c.Redirect("/") }
table := c.Params("table")
@ -151,7 +151,7 @@ func DeleteApi(c *fiber.Ctx) error {
}
func GetPageAdminIndex(c *fiber.Ctx) error {
_, err := api.CheckAuthed(c, true)
_, err := auth.Check(c, true)
if err != nil { return c.Redirect("/") }
return c.Render("admin/table/index", fiber.Map{})