mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-25 15:55:44 +00:00
first commit add master data kandang group
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"gitlab.com/mbugroup/lti-api.git/internal/common/repository"
|
||||
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
|
||||
)
|
||||
|
||||
type KandangGroupRepository interface {
|
||||
repository.BaseRepository[entity.KandangGroup]
|
||||
LocationExists(ctx context.Context, locationId uint) (bool, error)
|
||||
PicExists(ctx context.Context, picId uint) (bool, error)
|
||||
NameExists(ctx context.Context, name string, excludeID *uint) (bool, error)
|
||||
}
|
||||
|
||||
type KandangGroupRepositoryImpl struct {
|
||||
*repository.BaseRepositoryImpl[entity.KandangGroup]
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func NewKandangGroupRepository(db *gorm.DB) KandangGroupRepository {
|
||||
return &KandangGroupRepositoryImpl{
|
||||
BaseRepositoryImpl: repository.NewBaseRepository[entity.KandangGroup](db),
|
||||
db: db,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *KandangGroupRepositoryImpl) LocationExists(ctx context.Context, locationId uint) (bool, error) {
|
||||
return repository.Exists[entity.Location](ctx, r.db, locationId)
|
||||
}
|
||||
|
||||
func (r *KandangGroupRepositoryImpl) PicExists(ctx context.Context, picId uint) (bool, error) {
|
||||
return repository.Exists[entity.User](ctx, r.db, picId)
|
||||
}
|
||||
|
||||
func (r *KandangGroupRepositoryImpl) NameExists(ctx context.Context, name string, excludeID *uint) (bool, error) {
|
||||
return repository.ExistsByName[entity.KandangGroup](ctx, r.db, name, excludeID)
|
||||
}
|
||||
Reference in New Issue
Block a user