This commit is contained in:
@@ -17,13 +17,21 @@ func NewSportRepository(db *gorm.DB) *SportRepository {
|
||||
return repo
|
||||
}
|
||||
|
||||
func (repository *SportRepository) FindAll(context context.Context) ([]models.Sport, error) {
|
||||
var sports []models.Sport
|
||||
func (repository *SportRepository) FindAll(page int, limit int, context context.Context) (sports []models.Sport, total int64, err error) {
|
||||
offset := (page - 1) * limit
|
||||
|
||||
result := repository.db.Find(&sports)
|
||||
slog.Info("SportRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return sports, nil
|
||||
err = repository.db.
|
||||
Model(&models.Sport{}).
|
||||
Count(&total).
|
||||
Limit(limit).
|
||||
Offset(offset).
|
||||
Order("id asc").
|
||||
Find(&sports).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
slog.Info("SportRepository#FindAll", "total", total)
|
||||
return
|
||||
}
|
||||
|
||||
func (repository *SportRepository) GetById(context context.Context, id string) (models.Sport, error) {
|
||||
|
||||
Reference in New Issue
Block a user