|
@@ -14,7 +14,6 @@ type GlobalLimitRepository interface {
|
|
|
GetGlobalLimit(ctx context.Context, id int64) (*model.GlobalLimit, error)
|
|
|
AddGlobalLimit(ctx context.Context, req *model.GlobalLimit) error
|
|
|
UpdateGlobalLimitByHostId(ctx context.Context, req *model.GlobalLimit) error
|
|
|
- DeleteGlobalLimitByHostId(ctx context.Context, hostId int64) error
|
|
|
IsGlobalLimitExistByHostId(ctx context.Context, hostId int64) (bool, error)
|
|
|
GetGlobalLimitByHostId(ctx context.Context, hostId int64) (*model.GlobalLimit, error)
|
|
|
GetGlobalLimitAllExpired(ctx context.Context,ids []int) ([]v1.GlobalLimitExpiredByHost, error)
|
|
@@ -61,16 +60,9 @@ func (r *globalLimitRepository) UpdateGlobalLimitByHostId(ctx context.Context, r
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-func (r *globalLimitRepository) DeleteGlobalLimitByHostId(ctx context.Context, hostId int64) error {
|
|
|
- if err := r.DB(ctx).Where("host_id = ?", hostId).Delete(&model.GlobalLimit{}).Error; err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- return nil
|
|
|
-}
|
|
|
-
|
|
|
func (r *globalLimitRepository) IsGlobalLimitExistByHostId(ctx context.Context, hostId int64) (bool, error) {
|
|
|
var count int64
|
|
|
- err := r.DB(ctx).Model(&model.GlobalLimit{}).Where("host_id = ?", hostId).Count(&count).Error
|
|
|
+ err := r.DB(ctx).Model(&model.GlobalLimit{}).Where("host_id = ? AND state = 1", hostId).Count(&count).Error
|
|
|
|
|
|
if err != nil {
|
|
|
return false, err
|