mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-24 15:25:43 +00:00
FIX[BE]: Fix Delete one on chickin match with BE standard
This commit is contained in:
+25
@@ -1,6 +1,8 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlab.com/mbugroup/lti-api.git/internal/common/repository"
|
||||
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
|
||||
"gorm.io/gorm"
|
||||
@@ -8,6 +10,10 @@ import (
|
||||
|
||||
type ProjectChickinDetailRepository interface {
|
||||
repository.BaseRepository[entity.ProjectChickinDetail]
|
||||
CreateOne(ctx context.Context, entity *entity.ProjectChickinDetail, modifier func(*gorm.DB) *gorm.DB) error
|
||||
DeleteMany(ctx context.Context, modifier func(*gorm.DB) *gorm.DB) error
|
||||
GetByProjectChickinID(ctx context.Context, projectChickinID uint) ([]entity.ProjectChickinDetail, error)
|
||||
WithTxRepo(tx *gorm.DB) ProjectChickinDetailRepository
|
||||
}
|
||||
|
||||
type ChickinDetailRepositoryImpl struct {
|
||||
@@ -19,3 +25,22 @@ func NewChickinDetailRepository(db *gorm.DB) ProjectChickinDetailRepository {
|
||||
BaseRepositoryImpl: repository.NewBaseRepository[entity.ProjectChickinDetail](db),
|
||||
}
|
||||
}
|
||||
|
||||
func (r *ChickinDetailRepositoryImpl) WithTxRepo(tx *gorm.DB) ProjectChickinDetailRepository {
|
||||
return &ChickinDetailRepositoryImpl{BaseRepositoryImpl: repository.NewBaseRepository[entity.ProjectChickinDetail](tx)}
|
||||
}
|
||||
|
||||
func (r *ChickinDetailRepositoryImpl) DB() *gorm.DB {
|
||||
return r.BaseRepositoryImpl.DB()
|
||||
}
|
||||
|
||||
func (r *ChickinDetailRepositoryImpl) GetByProjectChickinID(ctx context.Context, projectChickinID uint) ([]entity.ProjectChickinDetail, error) {
|
||||
var records []entity.ProjectChickinDetail
|
||||
if err := r.DB().WithContext(ctx).Where("project_chickin_id = ?", projectChickinID).Find(&records).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(records) == 0 {
|
||||
return nil, gorm.ErrRecordNotFound
|
||||
}
|
||||
return records, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user