新增访客黑名单:支持拉黑 IP/设备并管理列表
工作台可按 IP 或设备拉黑并填写释放时间与原因;侧栏黑名单页查看与解除;进线自动拦截。
This commit is contained in:
@@ -35,6 +35,7 @@ func Migrate(db *gorm.DB) error {
|
||||
&Customer{},
|
||||
&CustomerTag{},
|
||||
&CustomerContact{},
|
||||
&BlacklistEntry{},
|
||||
&Session{},
|
||||
&VisitorPageView{},
|
||||
&Message{},
|
||||
|
||||
@@ -76,6 +76,22 @@ type CustomerTag struct {
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// BlacklistEntry 租户级访客黑名单(按 IP 或设备指纹拦截)。
|
||||
// ExpiresAt 为空表示长期有效;允许多条历史记录,拦截时取未过期的最新一条。
|
||||
type BlacklistEntry struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
TenantID uint `gorm:"index:idx_bl_lookup;not null" json:"tenant_id"`
|
||||
Kind string `gorm:"size:20;index:idx_bl_lookup;not null" json:"kind"` // ip | device
|
||||
Value string `gorm:"size:200;index:idx_bl_lookup;not null" json:"value"`
|
||||
Reason string `gorm:"size:500" json:"reason"`
|
||||
ExpiresAt *time.Time `json:"expires_at"` // nil = 长期
|
||||
OperatorID uint `gorm:"index" json:"operator_id"`
|
||||
SessionID *uint `json:"session_id"`
|
||||
CustomerID *uint `json:"customer_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type Session struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
TenantID uint `gorm:"index;not null" json:"tenant_id"`
|
||||
@@ -86,6 +102,8 @@ type Session struct {
|
||||
VisitorIP string `gorm:"size:64" json:"visitor_ip"`
|
||||
VisitorRegion string `gorm:"size:100" json:"visitor_region"`
|
||||
UserAgent string `gorm:"size:500" json:"user_agent"`
|
||||
// DeviceKey 访客端持久设备指纹(localStorage),用于设备级拉黑
|
||||
DeviceKey string `gorm:"size:64;index" json:"device_key"`
|
||||
// 落地页 / 当前页(访客浏览轨迹)
|
||||
LandingURL string `gorm:"size:1000" json:"landing_url"`
|
||||
LandingTitle string `gorm:"size:200" json:"landing_title"`
|
||||
|
||||
Reference in New Issue
Block a user