[feat] 新增 SetOption

This commit is contained in:
2024-05-09 10:35:14 +08:00
parent 37018837d1
commit a871ccfa75
2 changed files with 17 additions and 15 deletions
+8 -7
View File
@@ -213,6 +213,13 @@ func (this Condition) GetFields(operator ConditionOperator, types ...ConditionTo
return result
}
func (this *Condition) SetOption(opts ...Option) *Condition {
for i := 0; i < len(opts); i++ {
opts[i](this)
}
return this
}
type Option func(option *Condition)
func Type(v ConditionType) Option {
@@ -229,12 +236,6 @@ func Describe(v string) Option {
func New(opts ...Option) *Condition {
cond := &Condition{typ: AND}
if l := len(opts); l > 0 {
for i := 0; i < l; i++ {
opts[i](cond)
}
}
cond.SetOption(opts...)
return cond
}