// Find all details by StockTransferId

package repositories

import (
	"context"

	"gitlab.com/mbugroup/lti-api.git/internal/common/repository"
	entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
	"gorm.io/gorm"
)

type StockTransferDetailRepository interface {
	repository.BaseRepository[entity.StockTransferDetail]
	FindByTransferId(ctx context.Context, transferId uint64, out *[]entity.StockTransferDetail) error
}

type StockTransferDetailRepositoryImpl struct {
	*repository.BaseRepositoryImpl[entity.StockTransferDetail]
}

func NewStockTransferDetailRepository(db *gorm.DB) StockTransferDetailRepository {
	return &StockTransferDetailRepositoryImpl{
		BaseRepositoryImpl: repository.NewBaseRepository[entity.StockTransferDetail](db),
	}
}
func (r *StockTransferDetailRepositoryImpl) FindByTransferId(ctx context.Context, transferId uint64, out *[]entity.StockTransferDetail) error {
	return r.DB().WithContext(ctx).Where("stock_transfer_id = ?", transferId).Find(out).Error
}
