Self Order
This commit is contained in:
@@ -138,3 +138,15 @@ func (r *CustomerRepository) GetByEmail(ctx context.Context, email string, organ
|
||||
}
|
||||
return &customer, nil
|
||||
}
|
||||
|
||||
func (r *CustomerRepository) GetByPhoneNumber(ctx context.Context, phoneNumber string) (*entities.Customer, error) {
|
||||
var customer entities.Customer
|
||||
err := r.db.WithContext(ctx).Where("phone_number = ?", phoneNumber).First(&customer).Error
|
||||
if err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
return &customer, nil
|
||||
}
|
||||
|
||||
@@ -170,3 +170,16 @@ func (r *TableRepository) GetByOrderID(ctx context.Context, orderID uuid.UUID) (
|
||||
}
|
||||
return &table, nil
|
||||
}
|
||||
|
||||
func (r *TableRepository) GetByToken(ctx context.Context, token string) (*entities.Table, error) {
|
||||
var table entities.Table
|
||||
err := r.db.WithContext(ctx).
|
||||
Preload("Organization").
|
||||
Preload("Outlet").
|
||||
Where("token = ? AND is_active = ?", token, true).
|
||||
First(&table).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &table, nil
|
||||
}
|
||||
|
||||
@@ -23,4 +23,5 @@ type TableRepositoryInterface interface {
|
||||
OccupyTable(ctx context.Context, tableID, orderID uuid.UUID, startTime *time.Time) error
|
||||
ReleaseTable(ctx context.Context, tableID uuid.UUID, paymentAmount float64) error
|
||||
GetByOrderID(ctx context.Context, orderID uuid.UUID) (*entities.Table, error)
|
||||
GetByToken(ctx context.Context, token string) (*entities.Table, error)
|
||||
}
|
||||
|
||||
@@ -99,6 +99,17 @@ func (r *UserRepositoryImpl) List(ctx context.Context, filters map[string]interf
|
||||
return users, total, err
|
||||
}
|
||||
|
||||
func (r *UserRepositoryImpl) GetAdminByOrganizationID(ctx context.Context, organizationID uuid.UUID) (*entities.User, error) {
|
||||
var user entities.User
|
||||
err := r.db.WithContext(ctx).
|
||||
Where("organization_id = ? AND role = ? AND is_active = ?", organizationID, entities.RoleAdmin, true).
|
||||
First(&user).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &user, nil
|
||||
}
|
||||
|
||||
func (r *UserRepositoryImpl) Count(ctx context.Context, filters map[string]interface{}) (int64, error) {
|
||||
var count int64
|
||||
query := r.db.WithContext(ctx).Model(&entities.User{})
|
||||
|
||||
Reference in New Issue
Block a user