Feat[BE-222]: Completed SO and DO API

This commit is contained in:
aguhh18
2025-11-17 07:16:07 +07:00
parent 903b114315
commit 7905bdb0d7
16 changed files with 600 additions and 1011 deletions
@@ -11,6 +11,7 @@ import (
type MarketingRepository interface {
repository.BaseRepository[entity.Marketing]
IdExists(ctx context.Context, id uint) (bool, error)
GetNextSequence(ctx context.Context) (uint, error)
}
type MarketingRepositoryImpl struct {
@@ -26,3 +27,11 @@ func NewMarketingRepository(db *gorm.DB) MarketingRepository {
func (r *MarketingRepositoryImpl) IdExists(ctx context.Context, id uint) (bool, error) {
return repository.Exists[entity.Marketing](ctx, r.DB(), id)
}
func (r *MarketingRepositoryImpl) GetNextSequence(ctx context.Context) (uint, error) {
var maxID uint
if err := r.DB().WithContext(ctx).Model(&entity.Marketing{}).Select("COALESCE(MAX(id), 0)").Scan(&maxID).Error; err != nil {
return 0, err
}
return maxID + 1, nil
}