From 069f1ed9a4651dd2598a513d94278a400a04e5a7 Mon Sep 17 00:00:00 2001 From: Joe Chen Date: Wed, 23 Aug 2023 00:15:30 -0400 Subject: db: migrate `admin.go` to `notices.go` with GORM (#7536) --- internal/route/admin/notice.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'internal/route/admin') diff --git a/internal/route/admin/notice.go b/internal/route/admin/notice.go index 5e1f377f..87d9920c 100644 --- a/internal/route/admin/notice.go +++ b/internal/route/admin/notice.go @@ -25,14 +25,14 @@ func Notices(c *context.Context) { c.Data["PageIsAdmin"] = true c.Data["PageIsAdminNotices"] = true - total := db.CountNotices() + total := db.Notices.Count(c.Req.Context()) page := c.QueryInt("page") if page <= 1 { page = 1 } c.Data["Page"] = paginater.New(int(total), conf.UI.Admin.NoticePagingNum, page, 5) - notices, err := db.Notices(page, conf.UI.Admin.NoticePagingNum) + notices, err := db.Notices.List(c.Req.Context(), page, conf.UI.Admin.NoticePagingNum) if err != nil { c.Error(err, "list notices") return @@ -53,7 +53,7 @@ func DeleteNotices(c *context.Context) { } } - if err := db.DeleteNoticesByIDs(ids); err != nil { + if err := db.Notices.DeleteByIDs(c.Req.Context(), ids...); err != nil { c.Flash.Error("DeleteNoticesByIDs: " + err.Error()) c.Status(http.StatusInternalServerError) } else { @@ -63,7 +63,7 @@ func DeleteNotices(c *context.Context) { } func EmptyNotices(c *context.Context) { - if err := db.DeleteNotices(0, 0); err != nil { + if err := db.Notices.DeleteAll(c.Req.Context()); err != nil { c.Error(err, "delete notices") return } -- cgit v1.2.3