-
Notifications
You must be signed in to change notification settings - Fork 0
/
property.go
70 lines (56 loc) · 1.5 KB
/
property.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package listener
import (
"database/sql"
"github.com/webx-top/db"
"github.com/webx-top/db/lib/factory"
)
type Property struct {
embedded sql.NullBool // 是否为嵌入图片
seperator sql.NullString // 文件字段中多个文件路径之间的分隔符,空字符串代表为单个文件
updater func(event string, content string) error
exit bool
}
func NewProperty() *Property {
return &Property{}
}
func NewProUP(m factory.Model, cond db.Compound) *Property {
return NewProperty().GenUpdater(m, cond)
}
func (pro *Property) GenUpdater(m factory.Model, cond db.Compound) *Property {
pro.updater = func(field string, content string) error {
err := m.EventOFF().SetField(nil, field, content, cond)
m.EventON()
return err
}
return pro
}
func (pro *Property) SetUpdater(updater func(field string, content string) error) *Property {
pro.updater = updater
return pro
}
func (pro *Property) Updater() func(field string, content string) error {
return pro.updater
}
func (pro *Property) Embedded() bool {
return pro.embedded.Bool
}
func (pro *Property) Seperator() string {
return pro.seperator.String
}
func (pro *Property) Exit() bool {
return pro.exit
}
func (pro *Property) SetExit(exit bool) *Property {
pro.exit = exit
return pro
}
func (pro *Property) SetEmbedded(on bool) *Property {
pro.embedded.Bool = on
pro.embedded.Valid = true
return pro
}
func (pro *Property) SetSeperator(sep string) *Property {
pro.seperator.String = sep
pro.seperator.Valid = true
return pro
}