From ea5b739df3f74303ba765818681a5e8472cf2d4d Mon Sep 17 00:00:00 2001 From: bmf-san Date: Sat, 4 May 2024 11:20:10 +0900 Subject: [PATCH] [update] changed order --- app/interfaces/repository/category.go | 2 +- app/interfaces/repository/comment.go | 2 +- app/interfaces/repository/post.go | 10 +++++----- app/interfaces/repository/tag.go | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/interfaces/repository/category.go b/app/interfaces/repository/category.go index 8e3c6e8..fb9b7fb 100644 --- a/app/interfaces/repository/category.go +++ b/app/interfaces/repository/category.go @@ -36,7 +36,7 @@ func (cr *Category) FindAll(page int, limit int) (domain.Categories, error) { * FROM categories - ORDER BY id + ORDER BY created_at DESC LIMIT ?, ? `, page*limit-limit, limit) diff --git a/app/interfaces/repository/comment.go b/app/interfaces/repository/comment.go index 2b2bbbb..e0c139c 100644 --- a/app/interfaces/repository/comment.go +++ b/app/interfaces/repository/comment.go @@ -37,7 +37,7 @@ func (cr *Comment) FindAll(page int, limit int) (domain.Comments, error) { * FROM comments - ORDER BY id + ORDER BY created_at DESC LIMIT ?, ? `, page*limit-limit, limit) diff --git a/app/interfaces/repository/post.go b/app/interfaces/repository/post.go index 90d0f3e..2f4b268 100644 --- a/app/interfaces/repository/post.go +++ b/app/interfaces/repository/post.go @@ -130,7 +130,7 @@ func (pr *Post) FindAllPublic(page int, limit int) (domain.Posts, error) { view_posts WHERE status = "public" - ORDER BY id + ORDER BY created_at DESC LIMIT ?, ? `, page*limit-limit, limit) @@ -367,7 +367,7 @@ func (pr *Post) FindAllPublicByKeyword(page int, limit int, keyword string) (dom AGAINST (? IN BOOLEAN MODE) AND status = "public" - ORDER BY id + ORDER BY created_at DESC LIMIT ?, ? `, keyword, page*limit-limit, limit) @@ -603,7 +603,7 @@ func (pr *Post) FindAllPublicByCategory(page int, limit int, name string) (domai WHERE status = "public" AND category_name = ? - ORDER BY id + ORDER BY created_at DESC LIMIT ?, ? `, name, page*limit-limit, limit) @@ -850,7 +850,7 @@ func (pr *Post) FindAllPublicByTag(page int, limit int, name string) (domain.Pos WHERE tags.name = ? ) - ORDER BY id + ORDER BY created_at DESC LIMIT ?, ? `, name, page*limit-limit, limit) @@ -1092,7 +1092,7 @@ func (pr *Post) FindAll(page int, limit int) (domain.Posts, error) { * FROM view_posts - ORDER BY id + ORDER BY created_at DESC LIMIT ?, ? `, page*limit-limit, limit) diff --git a/app/interfaces/repository/tag.go b/app/interfaces/repository/tag.go index e1a7633..55b8abe 100644 --- a/app/interfaces/repository/tag.go +++ b/app/interfaces/repository/tag.go @@ -37,7 +37,7 @@ func (tr *Tag) FindAll(page int, limit int) (domain.Tags, error) { * FROM tags - ORDER BY id + ORDER BY created_at DESC LIMIT ?, ? `, page*limit-limit, limit)