-
Notifications
You must be signed in to change notification settings - Fork 1
/
invitation_customer.go
42 lines (35 loc) · 1.31 KB
/
invitation_customer.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
package customer
import (
"github.com/webx-top/db"
"github.com/webx-top/db/lib/sqlbuilder"
"github.com/webx-top/echo"
"github.com/admpub/nging/v5/application/library/common"
"github.com/admpub/webx/application/dbschema"
)
func NewInvitationCustomer(ctx echo.Context) *InvitationCustomer {
m := &InvitationCustomer{
OfficialCustomerInvitationUsed: dbschema.NewOfficialCustomerInvitationUsed(ctx),
}
return m
}
type InvitationCustomer struct {
*dbschema.OfficialCustomerInvitationUsed
}
func (f *InvitationCustomer) ListCustomer(cond *db.Compounds, orderby ...interface{}) ([]*InvitationCustomerExt, error) {
list := []*InvitationCustomerExt{}
err := f.listPage(&list, cond, orderby...)
return list, err
}
func (f *InvitationCustomer) ListCustomerWithCode(cond *db.Compounds, orderby ...interface{}) ([]*InvitationCustomerWithCode, error) {
list := []*InvitationCustomerWithCode{}
err := f.listPage(&list, cond, orderby...)
return list, err
}
func (f *InvitationCustomer) listPage(recv interface{}, cond *db.Compounds, orderby ...interface{}) error {
_, err := common.NewLister(f, recv, func(r db.Result) db.Result {
return r.OrderBy(orderby...).Relation(`Customer`, func(sel sqlbuilder.Selector) sqlbuilder.Selector {
return sel.Columns(CusomterSafeFields...)
})
}, cond.And()).Paging(f.Context())
return err
}