|
@@ -7,15 +7,16 @@ import (
|
|
|
|
|
|
type GameShieldRepository interface {
|
|
|
GetGameShieldById(ctx context.Context, id int64) (*model.GameShield, error)
|
|
|
- GetGameShieldDuplicateName(ctx context.Context, appName string) (int64, error)
|
|
|
+ GetGameShieldDuplicateName(ctx context.Context, appName string, uid int) (int64, error)
|
|
|
AddGameShield(ctx context.Context, gameShield *model.GameShield) error
|
|
|
UpdateGameShield(ctx context.Context, gameShield *model.GameShield) error
|
|
|
DeleteGameShield(ctx context.Context, ruleId int) error
|
|
|
GetGameShieldIsBuy(ctx context.Context, uid int64) (int64, error)
|
|
|
GetGameShieldNextduedate(ctx context.Context, uid int64, productID string) (string, error)
|
|
|
GetGameShieldExistingIps(ctx context.Context, ip string) ([]string, error)
|
|
|
- GetGameShieldNameByAppName(ctx context.Context, appName string) (string, error)
|
|
|
- GetGameShieldIdByAppName(ctx context.Context, id int64) (string, error)
|
|
|
+ GetGameShieldNameByDunName(ctx context.Context, appName string) (string, error)
|
|
|
+ GetGameShieldIdByDunName(ctx context.Context, id int64) (string, error)
|
|
|
+ GetGameShieldRuleIdByAppName(ctx context.Context, appName string) (int, error)
|
|
|
}
|
|
|
|
|
|
func NewGameShieldRepository(
|
|
@@ -38,9 +39,9 @@ func (r *gameShieldRepository) GetGameShieldById(ctx context.Context, id int64)
|
|
|
return &res, nil
|
|
|
}
|
|
|
|
|
|
-func (r *gameShieldRepository) GetGameShieldDuplicateName(ctx context.Context, appName string) (int64, error) {
|
|
|
+func (r *gameShieldRepository) GetGameShieldDuplicateName(ctx context.Context, appName string, uid int) (int64, error) {
|
|
|
var count int64
|
|
|
- if err := r.DB(ctx).Model(&model.GameShield{}).Where("app_name = ?", appName).Count(&count).Error; err != nil {
|
|
|
+ if err := r.DB(ctx).Model(&model.GameShield{}).Where("app_name = ?", appName).Where("uid = ?", uid).Count(&count).Error; err != nil {
|
|
|
return 0, err
|
|
|
}
|
|
|
return count, nil
|
|
@@ -103,7 +104,7 @@ func (r *gameShieldRepository) GetGameShieldExistingIps(ctx context.Context, ip
|
|
|
return res, nil
|
|
|
}
|
|
|
|
|
|
-func (r *gameShieldRepository) GetGameShieldNameByAppName(ctx context.Context, appName string) (string, error) {
|
|
|
+func (r *gameShieldRepository) GetGameShieldNameByDunName(ctx context.Context, appName string) (string, error) {
|
|
|
var res string
|
|
|
if err := r.DB(ctx).Model(&model.GameShield{}).
|
|
|
Where("app_name = ?", appName).
|
|
@@ -113,7 +114,7 @@ func (r *gameShieldRepository) GetGameShieldNameByAppName(ctx context.Context, a
|
|
|
return res, nil
|
|
|
}
|
|
|
|
|
|
-func (r *gameShieldRepository) GetGameShieldIdByAppName(ctx context.Context, id int64) (string, error) {
|
|
|
+func (r *gameShieldRepository) GetGameShieldIdByDunName(ctx context.Context, id int64) (string, error) {
|
|
|
var res string
|
|
|
if err := r.DB(ctx).Model(&model.GameShield{}).
|
|
|
Where("id = ?", id).
|
|
@@ -122,3 +123,13 @@ func (r *gameShieldRepository) GetGameShieldIdByAppName(ctx context.Context, id
|
|
|
}
|
|
|
return res, nil
|
|
|
}
|
|
|
+
|
|
|
+func (r *gameShieldRepository) GetGameShieldRuleIdByAppName(ctx context.Context, appName string) (int, error) {
|
|
|
+ var res int
|
|
|
+ if err := r.DB(ctx).Model(&model.GameShield{}).
|
|
|
+ Where("app_name = ?", appName).
|
|
|
+ Pluck("rule_id", &res).Error; err != nil {
|
|
|
+ return 0, err
|
|
|
+ }
|
|
|
+ return res, nil
|
|
|
+}
|