FIX[BE]: adjust response on proudctwarehouses

This commit is contained in:
aguhh18
2025-10-20 08:45:31 +07:00
parent 4218298234
commit 5c3787886b
8 changed files with 291 additions and 122 deletions
@@ -9,6 +9,7 @@ import (
)
type ProjectFlockKandangRepository interface {
GetByID(ctx context.Context, id uint) (*entity.ProjectFlockKandang, error)
CreateMany(ctx context.Context, records []*entity.ProjectFlockKandang) error
MarkDetached(ctx context.Context, projectFlockID uint, kandangIDs []uint, detachedAt time.Time) error
GetAll(ctx context.Context) ([]entity.ProjectFlockKandang, error)
@@ -62,3 +63,16 @@ func (r *projectFlockKandangRepositoryImpl) WithTx(tx *gorm.DB) ProjectFlockKand
func (r *projectFlockKandangRepositoryImpl) DB() *gorm.DB {
return r.db
}
func (r *projectFlockKandangRepositoryImpl) GetByID(ctx context.Context, id uint) (*entity.ProjectFlockKandang, error) {
record := new(entity.ProjectFlockKandang)
if err := r.db.WithContext(ctx).
Preload("ProjectFlock").
Preload("ProjectFlock.Flock").
Preload("Kandang").
Preload("CreatedUser").
First(record, id).Error; err != nil {
return nil, err
}
return record, nil
}