-
Notifications
You must be signed in to change notification settings - Fork 1
/
group.go
34 lines (26 loc) · 803 Bytes
/
group.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
package official
import (
"github.com/webx-top/db"
"github.com/webx-top/echo"
"github.com/admpub/webx/application/dbschema"
)
func NewGroup(ctx echo.Context) *Group {
return &Group{
OfficialCommonGroup: dbschema.NewOfficialCommonGroup(ctx),
}
}
type Group struct {
*dbschema.OfficialCommonGroup
}
func (f *Group) Exists(name string) (bool, error) {
return f.OfficialCommonGroup.Exists(nil, db.Cond{`name`: name})
}
func (f *Group) ExistsOther(name string, id uint) (bool, error) {
return f.OfficialCommonGroup.Exists(nil, db.Cond{`name`: name, `id <>`: id})
}
func (f *Group) Add() (pk interface{}, err error) {
return f.OfficialCommonGroup.Insert()
}
func (f *Group) Edit(mw func(db.Result) db.Result, args ...interface{}) error {
return f.OfficialCommonGroup.Update(mw, args...)
}