// ================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// You can delete these comments if you wish manually maintain this interface file.
// ================================================================================

package service

import (
	"context"
	"kami/internal/consts"
	"kami/internal/model"
	"kami/internal/model/do"
	"kami/internal/model/entity"

	"github.com/gogf/gf/v2/database/gdb"
)

type (
	IRestriction interface {
		// SaveDeviceInfo 存储现有的设备
		SaveDeviceInfo(ctx context.Context, input *model.RestrictionDeviceInput) (id int64, err error)
		// SaveDeviceIPRelation 保存IP关联关系
		SaveDeviceIPRelation(ctx context.Context, ip string, isRemoteIP bool, accessId int, sessionId string, tx gdb.TX) (err error)
		GetOrSetAccessRecord(ctx context.Context, input do.V1RestrictClientAccessRecord, tx gdb.TX) (accessId int, err error)
		// CheckIsDeviceUseProxy 判断使用当前IP访问时候是不是使用代理，取最后一次
		CheckIsDeviceUseProxy(ctx context.Context, deviceId string, ip string) (isUse bool)
		// GetOrSetIPRecord 获取或设置IP记录
		GetOrSetIPRecord(ctx context.Context, ip string, tx gdb.TX) (m *model.RestrictionIPRecordOutput, err error)
		GetAllProvince(ctx context.Context) []string
		CheckIPIsAllowed(ctx context.Context, ip string, area []string) (isAllowed bool, err error)
		// AddToRestrictIP 把当前IP加入限制IP中
		AddToRestrictIP(ctx context.Context, input model.AddRestrictionRecordInput) (err error)
		// SetCurrentOrderDisable 拉黑当前订单
		SetCurrentOrderDisable(ctx context.Context, orderNo string, status consts.RestrictStatus, tx gdb.TX) (err error)
		// GetLocationWithProxyByIP 查看当前IP是否是代理
		GetLocationWithProxyByIP(ctx context.Context, ip string) (data *model.RestrictionIPRecordOutput, err error)
		// IsInProvince 判断当前IP是否是下面省份
		IsInProvince(ctx context.Context, ip string, province []string) (isin bool, m *model.RestrictionIPRecordOutput, err error)
		// GetRestrictRecordByCardPass 查找当前卡密所有的限制记录
		GetRestrictRecordByCardPass(ctx context.Context, cardPass string) (dataList []entity.V1RestrictIpOrderAccess, err error)
		// GetRestrictRecordByIP 查找当前卡密所有的限制记录
		GetRestrictRecordByIP(ctx context.Context, ip string) (dataList []model.RestrictWithIPRecordOutput, err error)
		GetIPOrderAccessByCardPass(ctx context.Context, cardPass string) (data []entity.V1RestrictIpOrderAccess, err error)
		// IsRestrictExistByCardPass 判断是否存在IP有限制记录
		IsRestrictExistByCardPass(ctx context.Context, cardPass string) (isExist bool)
		// IsRestrictExistByIP 判断是否存在IP有限制记录
		IsRestrictExistByIP(ctx context.Context, ip string) (isExist bool)
		// IsRestrictDevice 判断是否禁用设备
		IsRestrictDevice(ctx context.Context, deviceId string) (isRestrict bool)
	}
)

var (
	localRestriction IRestriction
)

func Restriction() IRestriction {
	if localRestriction == nil {
		panic("implement not found for interface IRestriction, forgot register?")
	}
	return localRestriction
}

func RegisterRestriction(i IRestriction) {
	localRestriction = i
}
