From e050ae96695b70b87c9652c79124e259c2352498 Mon Sep 17 00:00:00 2001 From: jasinco Date: Wed, 11 Jun 2025 08:05:46 +0800 Subject: [PATCH] correct wrong sql query --- admin_panel/src/Panel.tsx | 6 +++--- nimdb/query.sql.go | 2 +- server.go | 5 +---- sql/query.sql | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/admin_panel/src/Panel.tsx b/admin_panel/src/Panel.tsx index 55f0d10..2997e6c 100644 --- a/admin_panel/src/Panel.tsx +++ b/admin_panel/src/Panel.tsx @@ -36,13 +36,13 @@ const Panel = () => { if ((val.status == 401 || val.status == 400) && await val.text() == "missing or malformvald JWT") { window.location.href = "/admin/login" } else if (val.status == 200) { - setPosts((await val.json() as Array).map(post => POST.parse(post)).filter(e => verifyli.findIndex(x => x.id == e.id) == -1)) + setPosts((await val.json() as Array).map(post => POST.parse(post)).filter(e => verifyli.findIndex(x => x.post == e.id) == -1)) } }).finally(() => { setLoading(false) }) } const verify = (check: boolean, post: number) => { - setVerifyli([...verifyli, { ck: check, id: post }]) + setVerifyli([...verifyli, { check: check, post: post }]) setPosts(posts.filter(v => v.id != post)) } @@ -91,7 +91,7 @@ const Panel = () => {
{posts.length > 0 ? posts.map(post => { return (
-

+

{post.content}

diff --git a/nimdb/query.sql.go b/nimdb/query.sql.go index 817591d..d67733c 100644 --- a/nimdb/query.sql.go +++ b/nimdb/query.sql.go @@ -130,7 +130,7 @@ func (q *Queries) AdminLoginGetTOTP(ctx context.Context, arg AdminLoginGetTOTPPa } const adminUpdateImage = `-- name: AdminUpdateImage :exec -UPDATE media SET visible = false WHERE post_id=$1 +UPDATE media SET visible = true WHERE post_id=$1 ` func (q *Queries) AdminUpdateImage(ctx context.Context, postID pgtype.Int4) error { diff --git a/server.go b/server.go index 233e191..ca36311 100644 --- a/server.go +++ b/server.go @@ -37,10 +37,7 @@ func main() { } app := fiber.New(fiber.Config{Prefork: internal.PREFORK}) - - app.Get("/", func(c *fiber.Ctx) error { - return c.SendString("Hello, World!") - }) + app.Static("/", "./static/webpage/") app.Use(limiter.New(limiter.Config{ Next: func(c *fiber.Ctx) bool { diff --git a/sql/query.sql b/sql/query.sql index 419c5b9..d92a07e 100644 --- a/sql/query.sql +++ b/sql/query.sql @@ -73,7 +73,7 @@ UPDATE posts SET phase = $1 WHERE id=$2 AND phase = 'pending' RETURNING id; UPDATE posts SET phase = $1 WHERE id=$2 AND (phase = 'pending' OR phase = 'rejected') RETURNING id; -- name: AdminUpdateImage :exec -UPDATE media SET visible = false WHERE post_id=$1; +UPDATE media SET visible = true WHERE post_id=$1; -- name: AdminLoginGetTOTP :one SELECT totp, super FROM admin WHERE username = $1 AND password = $2;