Feat[BE-222,223,224]: creating So create delete patch update get getall approval API

This commit is contained in:
aguhh18
2025-11-12 11:28:18 +07:00
parent 762dfa9fb9
commit 0a0c3f869b
24 changed files with 1688 additions and 82 deletions
@@ -0,0 +1,21 @@
package repository
import (
"gitlab.com/mbugroup/lti-api.git/internal/common/repository"
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
"gorm.io/gorm"
)
type MarketingDeliveryProductRepository interface {
repository.BaseRepository[entity.MarketingDeliveryProduct]
}
type MarketingDeliveryProductRepositoryImpl struct {
*repository.BaseRepositoryImpl[entity.MarketingDeliveryProduct]
}
func NewMarketingDeliveryProductRepository(db *gorm.DB) MarketingDeliveryProductRepository {
return &MarketingDeliveryProductRepositoryImpl{
BaseRepositoryImpl: repository.NewBaseRepository[entity.MarketingDeliveryProduct](db),
}
}
@@ -0,0 +1,35 @@
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"
)
type MarketingProductRepository interface {
repository.BaseRepository[entity.MarketingProduct]
GetByMarketingID(ctx context.Context, marketingID uint) ([]entity.MarketingProduct, error)
}
type MarketingProductRepositoryImpl struct {
*repository.BaseRepositoryImpl[entity.MarketingProduct]
}
func NewMarketingProductRepository(db *gorm.DB) MarketingProductRepository {
return &MarketingProductRepositoryImpl{
BaseRepositoryImpl: repository.NewBaseRepository[entity.MarketingProduct](db),
}
}
func (r *MarketingProductRepositoryImpl) GetByMarketingID(ctx context.Context, marketingID uint) ([]entity.MarketingProduct, error) {
var products []entity.MarketingProduct
if err := r.DB().WithContext(ctx).Where("marketing_id = ?", marketingID).Find(&products).Error; err != nil {
return nil, err
}
if len(products) == 0 {
return products, gorm.ErrRecordNotFound
}
return products, nil
}
@@ -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,7 @@ import (
type MarketingRepository interface {
repository.BaseRepository[entity.Marketing]
IdExists(ctx context.Context, id uint) (bool, error)
}
type MarketingRepositoryImpl struct {
@@ -19,3 +22,7 @@ func NewMarketingRepository(db *gorm.DB) MarketingRepository {
BaseRepositoryImpl: repository.NewBaseRepository[entity.Marketing](db),
}
}
func (r *MarketingRepositoryImpl) IdExists(ctx context.Context, id uint) (bool, error) {
return repository.Exists[entity.Marketing](ctx, r.DB(), id)
}