feat(database): support postgres (#43)

Co-authored-by: Li4n0 <[email protected]>
This commit is contained in:
becivells
2021-12-24 22:05:12 +08:00
committed by GitHub
co-authored by Li4n0
parent 3242a49b27
commit 8b30f83075
18 changed files with 224 additions and 51 deletions
+11 -10
View File
@@ -14,16 +14,17 @@ type Rule interface {
}
type BaseRule struct {
Rule `gorm:"-" json:"-" yaml:"-"`
ID uint `gorm:"primarykey" form:"id" json:"id" yaml:"-"`
CreatedAt time.Time `json:"created_at" yaml:"-"`
UpdatedAt time.Time `json:"updated_at" yaml:"-"`
Name string `gorm:"index;unique;not null;" form:"name" json:"name"`
FlagFormat string `gorm:"unique;not null;" form:"flag_format" json:"flag_format" yaml:"flag_format"`
flagCatcher *regexp.Regexp `gorm:"-" json:"-"`
Rank int `gorm:"default:0" json:"rank" form:"rank"`
PushToClient bool `gorm:"default:false;not null;" form:"push_to_client" json:"push_to_client" yaml:"push_to_client"`
Notice bool `gorm:"default:false;not null;" form:"notice" json:"notice"`
Rule `gorm:"-" json:"-" yaml:"-"`
ID uint `gorm:"primarykey" form:"id" json:"id" yaml:"-"`
CreatedAt time.Time `json:"created_at" yaml:"-"`
UpdatedAt time.Time `json:"updated_at" yaml:"-"`
Name string `gorm:"index;unique;not null;" form:"name" json:"name"`
FlagFormat string `gorm:"unique;not null;" form:"flag_format" json:"flag_format" yaml:"flag_format"`
flagCatcher *regexp.Regexp `gorm:"-" json:"-"`
// base_bank 解决 mysql 中关键字 rank 冲突和 pg 下不能使用 ``
Rank int `gorm:"default:0;column:base_rank" json:"rank" form:"rank"`
PushToClient bool `gorm:"default:false;not null;" form:"push_to_client" json:"push_to_client" yaml:"push_to_client"`
Notice bool `gorm:"default:false;not null;" form:"notice" json:"notice"`
}
func (br BaseRule) Match(s string) (flag, flagGroup string, vars map[string]string) {