feat: get news by slug and and author detail

This commit is contained in:
ericprd
2025-03-06 11:06:06 +08:00
parent d217ec8a62
commit 85247643e6
9 changed files with 76 additions and 1 deletions
+17
View File
@@ -0,0 +1,17 @@
package newsrepository
import newsdomain "legalgo-BE-go/internal/domain/news"
func (a *accessor) GetBySlug(slug string) (*newsdomain.News, error) {
var news newsdomain.News
if err := a.db.
Preload("Tags").
Preload("Categories").
Preload("Author").
First(&news, "slug = ?", slug).Error; err != nil {
return nil, err
}
return &news, nil
}