feat: get news by slug and and author detail
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user