-
Notifications
You must be signed in to change notification settings - Fork 1
/
sensitive.go
49 lines (40 loc) · 1.02 KB
/
sensitive.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
package sensitive
import (
"github.com/webx-top/db"
"github.com/webx-top/echo"
"github.com/admpub/webx/application/dbschema"
)
func NewSensitive(ctx echo.Context) *Sensitive {
return &Sensitive{
OfficialCommonSensitive: dbschema.NewOfficialCommonSensitive(ctx),
}
}
type Sensitive struct {
*dbschema.OfficialCommonSensitive
}
func (f *Sensitive) Exists(words string) (bool, error) {
return f.OfficialCommonSensitive.Exists(nil, db.Cond{`words`: words})
}
func (f *Sensitive) ExistsOther(words string, id uint) (bool, error) {
return f.OfficialCommonSensitive.Exists(nil, db.And(
db.Cond{`words`: words},
db.Cond{`id <>`: id},
))
}
func (f *Sensitive) check() error {
return nil
}
func (f *Sensitive) Add() (pk interface{}, err error) {
err = f.check()
if err != nil {
return
}
return f.OfficialCommonSensitive.Insert()
}
func (f *Sensitive) Edit(mw func(db.Result) db.Result, args ...interface{}) error {
err := f.check()
if err != nil {
return err
}
return f.OfficialCommonSensitive.Update(mw, args...)
}