package model

import (
	v1 "github.com/go-nunu/nunu-layout-advanced/api/v1"
	"go.mongodb.org/mongo-driver/bson/primitive"
	"time"
)

type WebForwarding struct {
	Id                   int `gorm:"primary"`
	HostId               int `gorm:"not null"`
	CdnWebId            int `gorm:"not null"`
	Port                 string `gorm:"not null"`
	Domain               string `gorm:"null"`
	IsHttps              int `gorm:"null"`
	Comment              string `gorm:"null"`
	HttpsCert             string `gorm:"null"`
	HttpsKey             string `gorm:"null"`
	SslCertId 			int `gorm:"null"`
	SslPolicyId               int
	Proxy 				bool `gorm:"null"`
	Cc                   bool
	ThresholdMethod      string
	Level                string
	Limit5s              int
	Limit60s             int
	Limit300s            int
	CreatedAt            time.Time
	UpdatedAt            time.Time
}

func (m *WebForwarding) TableName() string {
    return "shd_waf_web"
}

// WebForwardingRule 用于存储Web转发规则
type WebForwardingRule struct {
	ID          primitive.ObjectID `bson:"_id,omitempty"`
	Uid         int                `bson:"uid" json:"uid"`
	HostId      int                `bson:"host_id" json:"host_id"`
	WebId       int                `bson:"web_id" json:"web_id"`
	CdnOriginIds map[string]int64  `bson:"cdn_origin_ids" json:"cdn_origin_ids"`
	BackendList []v1.BackendList   `bson:"backend_list" json:"backend_list"`
	CreatedAt   time.Time          `bson:"created_at" json:"created_at"`
	UpdatedAt   time.Time          `bson:"updated_at" json:"updated_at"`
}


func (m *WebForwardingRule) CollectionName() string {
	return "web_forwarding_rules"
}
