mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
feat/BE/US-76/US-78/US-79/TASK-112,120,133,121-Recording growing/TASK-187,189,202,190-Recording Laying/TASK-191,192,194,197,203-Grading Telur
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
type FlockRepository interface {
|
||||
repository.BaseRepository[entity.Flock]
|
||||
NameExists(ctx context.Context, name string, excludeID *uint) (bool, error)
|
||||
GetByName(ctx context.Context, name string) (*entity.Flock, error)
|
||||
}
|
||||
|
||||
type FlockRepositoryImpl struct {
|
||||
@@ -28,3 +29,15 @@ func NewFlockRepository(db *gorm.DB) FlockRepository {
|
||||
func (r *FlockRepositoryImpl) NameExists(ctx context.Context, name string, excludeID *uint) (bool, error) {
|
||||
return repository.ExistsByName[entity.Flock](ctx, r.db, name, excludeID)
|
||||
}
|
||||
|
||||
func (r *FlockRepositoryImpl) GetByName(ctx context.Context, name string) (*entity.Flock, error) {
|
||||
var flock entity.Flock
|
||||
err := r.db.WithContext(ctx).
|
||||
Where("LOWER(name) = LOWER(?)", name).
|
||||
Where("deleted_at IS NULL").
|
||||
First(&flock).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &flock, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user